From 1b0f3ba4aca60d7770f46604308e201f9fab0425 Mon Sep 17 00:00:00 2001 From: jameshall03885 Date: Mon, 16 Jun 2014 10:07:44 -0400 Subject: [PATCH 001/285] Eclipse Build Errors - moved generated source for build-helper Also removed a version override on maven-bundle-plugin Change-Id: Ia22f3d3c60cbe1ff9c8f096c52c897eb7fc5fb2b Signed-off-by: jameshall03885 --- .gitignore | 5 ++++- openflow-protocol-api/pom.xml | 20 +------------------- openflow-protocol-impl/pom.xml | 4 ++-- openflow-protocol-spi/pom.xml | 4 ++-- pom.xml | 28 +++++++++++++++++++++++++++- 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 4f9b87b8..6eda0829 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ target/ .project .settings/ .externalToolBuilders/ -maven-eclipse.xml \ No newline at end of file +maven-eclipse.xml +yang-gen-config +yang-gen-sal +.checkstyle diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index bb85ec56..d7cdea82 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -35,7 +35,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - target/generated-sources/sal + ${salGeneratorPath} @@ -57,24 +57,6 @@ - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - generate-sources - - add-source - - - - target/generated-sources/sal - - - - - diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index a33a649a..daee93f0 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -48,7 +48,7 @@ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - ${project.build.directory}/generated-sources/config + ${jmxGeneratorPath} urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang @@ -59,7 +59,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - ${project.build.directory}/generated-sources/sal + ${salGeneratorPath} org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 3ead6626..21b2fbda 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -43,7 +43,7 @@ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - ${project.build.directory}/generated-sources/config + ${jmxGeneratorPath} urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang @@ -54,7 +54,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - ${project.build.directory}/generated-sources/sal + ${salGeneratorPath} org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl diff --git a/pom.xml b/pom.xml index 67b61712..6a3869c1 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,8 @@ 3.0.0 1.5.0 1.26.2 + src/main/yang-gen-config + src/main/yang-gen-sal ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 1.0.9 @@ -197,7 +199,6 @@ org.apache.felix maven-bundle-plugin - ${maven.bundle.version} true @@ -234,6 +235,10 @@ + + org.codehaus.mojo + build-helper-maven-plugin + @@ -267,6 +272,27 @@ maven-bundle-plugin ${maven.bundle.version} + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + + add-source + + generate-sources + + + src/main/yang + ${jmxGeneratorPath} + ${salGeneratorPath} + + + + + From ef115663e48d79a0a7a31d333af2017062223fa7 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Sun, 29 Jun 2014 17:24:53 -0500 Subject: [PATCH 002/285] Fix Eclipse errors Copied in the m2e section from controller. Change-Id: I19694b87833f44d39433dc05ae4e88932b56fc2e Signed-off-by: Ed Warnicke --- pom.xml | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/pom.xml b/pom.xml index 6a3869c1..99c9e048 100644 --- a/pom.xml +++ b/pom.xml @@ -293,6 +293,126 @@ + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + properties-maven-plugin + [0.0,) + + set-system-properties + + + + + + + + + org.codehaus.enunciate + maven-enunciate-plugin + [0.0,) + + docs + + + + + + + + + org.jacoco + jacoco-maven-plugin + [0.0,) + + prepare-agent + pre-test + post-test + + + + + + + + + org.ops4j.pax.exam + maven-paxexam-plugin + [1.2.4,) + + generate-depends-file + + + + + false + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + [2.0,) + + check + + + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + [0.5,) + + generate-sources + + + + + + + + + org.codehaus.groovy.maven + gmaven-plugin + 1.0 + + execute + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${enforcer.version} + + enforce + + + + + + + + + + From 2ba191317709b89f69d13f2bcf95b6b04395b143 Mon Sep 17 00:00:00 2001 From: jameshall03885 Date: Mon, 23 Jun 2014 12:54:43 -0400 Subject: [PATCH 003/285] TLS support TLS is configured in 42-openflowplugin.xml (openflowplugin) Added tests for: - pipeline components - TLS classes - updated integration test Added new yang file: openflow-configuration.yang (contains generated classes for library configuration) Logging updated Change-Id: I5480b01760377db7de7791594a3b541338a1b43a Signed-off-by: jameshall03885 Signed-off-by: Michal Polkorab --- .../connection/ConnectionConfiguration.java | 18 +- .../api/connection/TlsConfiguration.java | 50 ++++ .../api/connection/TlsConfigurationImpl.java | 76 ++++++ .../src/main/yang/openflow-configuration.yang | 42 +++ .../connection/ConnectionAdapterFactory.java | 6 +- .../ConnectionAdapterFactoryImpl.java | 29 ++ .../SwitchConnectionProviderImpl.java | 25 +- .../protocol/impl/core/OFDecoder.java | 7 +- .../protocol/impl/core/OFFrameDecoder.java | 20 +- .../protocol/impl/core/OFVersionDetector.java | 9 +- .../core/PublishingChannelInitializer.java | 93 +++++-- .../PublishingChannelInitializerFactory.java | 77 ++++++ .../protocol/impl/core/SslContextFactory.java | 107 +++++--- .../protocol/impl/core/SslKeyStore.java | 46 +++- .../protocol/impl/core/TcpHandler.java | 88 +----- .../protocol/impl/core/TlsDetector.java | 107 -------- .../SwitchConnectionProviderModule.java | 37 ++- .../src/main/resources/ctlKeystore | Bin 0 -> 2254 bytes .../src/main/resources/ctlTrustStore | Bin 0 -> 957 bytes .../src/main/resources/key.raw | 258 ------------------ .../src/main/resources/selfSignedController | Bin 0 -> 1351 bytes .../src/main/resources/selfSignedSwitch | Bin 0 -> 1348 bytes ...nflow-switch-connection-provider-impl.yang | 30 +- .../core/DelegatingInboundHandlerTest.java | 72 +++++ .../protocol/impl/core/IdleHandlerTest.java | 110 ++++++++ .../protocol/impl/core/OFDecoderTest.java | 114 ++++++++ .../protocol/impl/core/OFEncoderTest.java | 101 +++++++ .../impl/core/OFFrameDecoderTest.java | 98 +++++-- .../impl/core/OFVersionDetectorTest.java | 35 +++ ...blishingChannelInitializerFactoryTest.java | 62 +++++ .../PublishingChannelInitializerTest.java | 171 ++++++++++++ .../impl/core/SslContextFactoryTest.java | 54 ++++ .../protocol/impl/core/SslKeyStoreTest.java | 65 +++++ .../impl/core/SslTrustManagerFactoryTest.java | 70 +++++ .../protocol/impl/core/TcpHandlerTest.java | 171 ++++++++++++ .../protocol/impl/core/TlsDetectorTest.java | 51 ---- .../impl/integration/IntegrationTest.java | 149 ---------- .../ConnectionConfigurationImpl.java} | 25 +- .../it/integration/IntegrationTest.java | 208 ++++++++++++++ .../{impl => it}/integration/MockPlugin.java | 42 +-- .../impl/clients/ClientSslContextFactory.java | 69 +++++ .../impl/clients/ClientSslKeyStore.java | 48 ++++ .../impl/clients/ClientSslTrustStore.java | 48 ++++ .../impl/clients/SimpleClientInitializer.java | 4 +- .../src/main/resources/selfSignedController | Bin 0 -> 1351 bytes .../src/main/resources/selfSignedSwitch | Bin 0 -> 1348 bytes 46 files changed, 2051 insertions(+), 841 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java create mode 100644 openflow-protocol-api/src/main/yang/openflow-configuration.yang create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetector.java create mode 100644 openflow-protocol-impl/src/main/resources/ctlKeystore create mode 100644 openflow-protocol-impl/src/main/resources/ctlTrustStore delete mode 100644 openflow-protocol-impl/src/main/resources/key.raw create mode 100644 openflow-protocol-impl/src/main/resources/selfSignedController create mode 100644 openflow-protocol-impl/src/main/resources/selfSignedSwitch create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetectorTest.java delete mode 100644 openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java rename openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/{impl/integration/TestingConnConfigImpl.java => it/integration/ConnectionConfigurationImpl.java} (69%) create mode 100644 openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java rename openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/{impl => it}/integration/MockPlugin.java (85%) create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java create mode 100644 simple-client/src/main/resources/selfSignedController create mode 100644 simple-client/src/main/resources/selfSignedSwitch diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index c5ca795c..d877c0cc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -20,19 +20,7 @@ * */ public interface ConnectionConfiguration { - - /** - * connection functionality support types - */ - public enum FEATURE_SUPPORT { - /** feature is not supported at all */ - NOT_SUPPORTED, - /** feature is supported */ - SUPPORTED, - /** feature is supported and has to be used by clients */ - REQUIRED - } - + /** * @return address to bind, if null, all available interfaces will be used */ @@ -49,9 +37,9 @@ public enum FEATURE_SUPPORT { public Object getTransferProtocol(); /** - * @return encryption feature support + * @return TLS configuration object */ - public FEATURE_SUPPORT getTlsSupport(); + public TlsConfiguration getTlsConfiguration(); /** * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java new file mode 100644 index 00000000..54298294 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + + +/** + * @author michal.polkorab + * + */ +public interface TlsConfiguration { + + /** + * @return keystore location + */ + public String getTlsKeystore(); + + /** + * @return keystore type + */ + public KeystoreType getTlsKeystoreType(); + + /** + * @return truststore location + */ + public String getTlsTruststore(); + + /** + * @return truststore type + */ + public KeystoreType getTlsTruststoreType(); + + /** + * @return keystore path type (classpath or path) + */ + public PathType getTlsKeystorePathType(); + + /** + * @return truststore path type (classpath or path) + */ + public PathType getTlsTruststorePathType(); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java new file mode 100644 index 00000000..d0bafdd4 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * @author michal.polkorab + * + */ +public class TlsConfigurationImpl implements TlsConfiguration { + + private KeystoreType trustStoreType; + private String trustStore; + private KeystoreType keyStoreType; + private String keyStore; + private PathType keystorePathType; + private PathType truststorePathType; + + /** + * Default constructor + * @param trustStoreType JKS or PKCS12 + * @param trustStore path to trustStore file + * @param trustStorePathType truststore path type (classpath or path) + * @param keyStoreType JKS or PKCS12 + * @param keyStore path to keyStore file + * @param keyStorePathType keystore path type (classpath or path) + */ + public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, + PathType trustStorePathType, KeystoreType keyStoreType, + String keyStore, PathType keyStorePathType) { + this.trustStoreType = trustStoreType; + this.trustStore = trustStore; + this.truststorePathType = trustStorePathType; + this.keyStoreType = keyStoreType; + this.keyStore = keyStore; + this.keystorePathType = keyStorePathType; + } + + @Override + public KeystoreType getTlsTruststoreType() { + return trustStoreType; + } + + @Override + public String getTlsTruststore() { + return trustStore; + } + + @Override + public KeystoreType getTlsKeystoreType() { + return keyStoreType; + } + + @Override + public String getTlsKeystore() { + return keyStore; + } + + @Override + public PathType getTlsKeystorePathType() { + return keystorePathType; + } + + @Override + public PathType getTlsTruststorePathType() { + return truststorePathType; + } +} diff --git a/openflow-protocol-api/src/main/yang/openflow-configuration.yang b/openflow-protocol-api/src/main/yang/openflow-configuration.yang new file mode 100644 index 00000000..36b163cb --- /dev/null +++ b/openflow-protocol-api/src/main/yang/openflow-configuration.yang @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + module openflow-configuration { + namespace "urn:opendaylight:openflow:config"; + prefix "of-config"; + + revision "2014-06-30" { + description "Library configuration classes"; + } + + typedef path-type { + type enumeration { + enum CLASSPATH { + value 0; + description "Keystore file is located on classpath."; + } + enum PATH { + value 1; + description "Keystore file is located on absolute or relative path."; + } + } + } + + typedef keystore-type { + type enumeration { + enum JKS { + value 0; + description "Keystore type - JKS."; + } + enum PKCS12 { + value 1; + description "Keystore type - PKCS12."; + } + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java index a3897e93..3070aba8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java @@ -15,14 +15,12 @@ * @author mirehak * @author michal.polkorab */ -public abstract class ConnectionAdapterFactory { +public interface ConnectionAdapterFactory { /** * @param ch * @return connection adapter tcp-implementation */ - public static ConnectionFacade createConnectionFacade(SocketChannel ch) { - return new ConnectionAdapterImpl(ch); - } + public ConnectionFacade createConnectionFacade(SocketChannel ch) ; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java new file mode 100644 index 00000000..fda222ce --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.channel.socket.SocketChannel; + +/** + * @author mirehak + * @author michal.polkorab + */ +public class ConnectionAdapterFactoryImpl implements ConnectionAdapterFactory { + + /** + * @param ch + * @return connection adapter tcp-implementation + */ + @Override + public ConnectionFacade createConnectionFacade(SocketChannel ch) { + return new ConnectionAdapterImpl(ch); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index e1dabb49..cd864bd4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -10,19 +10,19 @@ package org.opendaylight.openflowjava.protocol.impl.connection; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration.FEATURE_SUPPORT; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializerFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; @@ -112,12 +112,13 @@ public ListenableFuture startup() { private TcpHandler createAndConfigureServer() { LOGGER.debug("Configuring .."); TcpHandler server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); - server.setSwitchConnectionHandler(switchConnectionHandler); - server.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout()); - boolean tlsSupported = FEATURE_SUPPORT.REQUIRED.equals(connConfig.getTlsSupport()); - server.setEncryption(tlsSupported); - server.setSerializationFactory(serializationFactory); - server.setDeserializationFactory(deserializationFactory); + PublishingChannelInitializerFactory factory = new PublishingChannelInitializerFactory(); + factory.setSwitchConnectionHandler(switchConnectionHandler); + factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout()); + factory.setTlsConfig(connConfig.getTlsConfiguration()); + factory.setSerializationFactory(serializationFactory); + factory.setDeserializationFactory(deserializationFactory); + server.setChannelInitializer(factory.createPublishingChannelInitializer()); return server; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index a1f9fb94..ee578046 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -38,10 +38,9 @@ public OFDecoder() { @Override protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List out) throws Exception { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("VersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); - } + LOGGER.debug("VersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + DataObject dataObject = null; try { dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index dab263a2..d074e93e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -15,6 +15,7 @@ import java.util.List; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,12 +30,16 @@ 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); + private ConnectionFacade connectionFacade; + private boolean started = false; /** * Constructor of class. + * @param connectionFacade */ - public OFFrameDecoder() { + public OFFrameDecoder(ConnectionFacade connectionFacade) { LOGGER.trace("Creating OFFrameDecoder"); + this.connectionFacade = connectionFacade; } @Override @@ -45,9 +50,14 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E @Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) throws Exception { + if (!started) { + connectionFacade.fireConnectionReadyNotification(); + started = true; + } int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bb - too few data for header: " + readableBytes); + LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); + LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); return; } @@ -55,11 +65,9 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) LOGGER.debug("length of actual message: {}", length); if (readableBytes < length) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bb - too few data for msg: " + + LOGGER.debug("skipping bytebuf - too few bytes for msg: " + readableBytes + " < " + length); - LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); - } + LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 719965b9..2160a85e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -47,15 +47,12 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) byte version = bb.readByte(); if ((version == OF13_VERSION_ID) || (version == OF10_VERSION_ID)) { LOGGER.debug("detected version: " + version); + ByteBuf messageBuffer = bb.slice(); + list.add(new VersionMessageWrapper(version, messageBuffer)); + messageBuffer.retain(); } else { LOGGER.warn("detected version: " + version + " - currently not supported"); - bb.skipBytes(bb.readableBytes()); - return; } - - ByteBuf messageBuffer = bb.slice(); - list.add(new VersionMessageWrapper(version, messageBuffer)); - messageBuffer.retain(); bb.skipBytes(bb.readableBytes()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java index cc245974..5d29e4be 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java @@ -12,15 +12,19 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.group.DefaultChannelGroup; import io.netty.channel.socket.SocketChannel; +import io.netty.handler.ssl.SslHandler; import java.net.InetAddress; import java.util.Iterator; import java.util.concurrent.TimeUnit; +import javax.net.ssl.SSLEngine; + import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.slf4j.Logger; @@ -32,22 +36,71 @@ */ public class PublishingChannelInitializer extends ChannelInitializer { + /** + * Enum used for storing names of used components (in pipeline). + */ + public static enum COMPONENT_NAMES { + + /** + * Detects switch idle state + */ + IDLE_HANDLER, + /** + * Detects 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 byte messages into POJOs + */ + OF_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol byte messages + */ + OF_ENCODER, + /** + * Delegates translated POJOs into MessageConsumer + */ + DELEGATING_INBOUND_HANDLER, + } + private static final Logger LOGGER = LoggerFactory .getLogger(PublishingChannelInitializer.class); private final DefaultChannelGroup allChannels; private SwitchConnectionHandler switchConnectionHandler; private long switchIdleTimeout; - private boolean encryption; private SerializationFactory serializationFactory; private DeserializationFactory deserializationFactory; + private ConnectionAdapterFactory connectionAdapterFactory; + private TlsConfiguration tlsConfiguration ; /** * default ctor */ public PublishingChannelInitializer() { - allChannels = new DefaultChannelGroup("netty-receiver", null); + this( new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl() ); } + /** + * Testing Constructor + * + */ + protected PublishingChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) { + allChannels = channelGroup ; + connectionAdapterFactory = connAdaptorFactory ; + } + @Override protected void initChannel(final SocketChannel ch) { InetAddress switchAddress = ch.remoteAddress().getAddress(); @@ -63,19 +116,22 @@ protected void initChannel(final SocketChannel ch) { LOGGER.info("Incoming connection accepted - building pipeline"); allChannels.add(ch); ConnectionFacade connectionFacade = null; - connectionFacade = ConnectionAdapterFactory.createConnectionFacade(ch); + connectionFacade = connectionAdapterFactory.createConnectionFacade(ch); try { - LOGGER.debug("calling plugin: "+switchConnectionHandler); + LOGGER.debug("calling plugin: " + switchConnectionHandler); switchConnectionHandler.onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); - TlsDetector tlsDetector; ch.pipeline().addLast(COMPONENT_NAMES.IDLE_HANDLER.name(), new IdleHandler(switchIdleTimeout, TimeUnit.MILLISECONDS)); - if (encryption) { - tlsDetector = new TlsDetector(); - tlsDetector.setConnectionFacade(connectionFacade); - ch.pipeline().addLast(COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector); + + // If this channel is configured to support SSL it will only support SSL + if (tlsConfiguration != null) { + SslContextFactory sslFactory = new SslContextFactory(tlsConfiguration); + SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); + engine.setNeedClientAuth(true); + engine.setUseClientMode(false); + ch.pipeline().addLast(COMPONENT_NAMES.SSL_HANDLER.name(), new SslHandler(engine)); } - ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder()); + ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade)); ch.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector()); OFDecoder ofDecoder = new OFDecoder(); ofDecoder.setDeserializationFactory(deserializationFactory); @@ -84,7 +140,7 @@ protected void initChannel(final SocketChannel ch) { ofEncoder.setSerializationFactory(serializationFactory); ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), ofEncoder); ch.pipeline().addLast(COMPONENT_NAMES.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); - if (!encryption) { + if (tlsConfiguration == null) { connectionFacade.fireConnectionReadyNotification(); } } catch (Exception e) { @@ -121,13 +177,6 @@ public void setSwitchIdleTimeout(final long switchIdleTimeout) { this.switchIdleTimeout = switchIdleTimeout; } - /** - * @param tlsSupported - */ - public void setEncryption(final boolean tlsSupported) { - encryption = tlsSupported; - } - /** * @param serializationFactory */ @@ -142,4 +191,10 @@ public void setDeserializationFactory(final DeserializationFactory deserializati this.deserializationFactory = deserializationFactory; } + /** + * @param tlsConfiguration + */ + public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { + this.tlsConfiguration = tlsConfiguration; + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java new file mode 100644 index 00000000..90351dc1 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @author michal.polkorab + * + */ +public class PublishingChannelInitializerFactory { + + private long switchIdleTimeOut; + private DeserializationFactory deserializationFactory; + private SerializationFactory serializationFactory; + private TlsConfiguration tlsConfig; + private SwitchConnectionHandler switchConnectionHandler; + + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public PublishingChannelInitializer createPublishingChannelInitializer() { + PublishingChannelInitializer initializer = new PublishingChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setTlsConfiguration(tlsConfig); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + + /** + * @param switchIdleTimeOut + */ + public void setSwitchIdleTimeout(long switchIdleTimeOut) { + this.switchIdleTimeOut = switchIdleTimeOut; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param tlsConfig + */ + public void setTlsConfig(TlsConfiguration tlsConfig) { + this.tlsConfig = tlsConfig; + } + + /** + * @param switchConnectionHandler + */ + public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } + + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java index 08272188..8deb4aa0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java @@ -8,74 +8,93 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import java.io.IOException; import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; import java.security.Security; +import java.security.cert.CertificateException; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Class for setting up TLS connection. - * + * * @author michal.polkorab */ -public final class SslContextFactory { +public 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; + private String keystore; + private KeystoreType keystoreType; + private String truststore; + private KeystoreType truststoreType; + private PathType keystorePathType; + private PathType truststorePathType; + + private static final Logger LOGGER = LoggerFactory + .getLogger(SslContextFactory.class); + + /** + * @param tlsConfig + * TLS configuration object, contains keystore locations + + * keystore types + */ + public SslContextFactory(TlsConfiguration tlsConfig) { + keystore = tlsConfig.getTlsKeystore(); + keystoreType = tlsConfig.getTlsKeystoreType(); + keystorePathType = tlsConfig.getTlsKeystorePathType(); + truststore = tlsConfig.getTlsTruststore(); + truststoreType = tlsConfig.getTlsTruststoreType(); + truststorePathType = tlsConfig.getTlsTruststorePathType(); + } - static { - String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm"); + /** + * @return servercontext + */ + public SSLContext getServerContext() { + String algorithm = Security + .getProperty("ssl.KeyManagerFactory.algorithm"); if (algorithm == null) { algorithm = "SunX509"; } - - SSLContext serverContext; - SSLContext clientContext; + SSLContext serverContext = null; try { - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(SslKeyStore.asInputStream(), + KeyStore ks = KeyStore.getInstance(keystoreType.name()); + ks.load(SslKeyStore.asInputStream(keystore, keystorePathType), SslKeyStore.getKeyStorePassword()); - KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(ks, SslKeyStore.getCertificatePassword()); + KeyStore ts = KeyStore.getInstance(truststoreType.name()); + ts.load(SslKeyStore.asInputStream(truststore, truststorePathType), + SslKeyStore.getKeyStorePassword()); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); + tmf.init(ts); + serverContext = SSLContext.getInstance(PROTOCOL); - serverContext.init(kmf.getKeyManagers(), null, null); - } catch (RuntimeException e) { - throw new Error( - "Failed to initialize the server-side SSLContext", e); + serverContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + } catch (IOException e) { + LOGGER.warn("IOException - Failed to load keystore / truststore." + + " Failed to initialize the server-side SSLContext", e); + } catch (NoSuchAlgorithmException e) { + LOGGER.warn("NoSuchAlgorithmException - Unsupported algorithm." + + " Failed to initialize the server-side SSLContext", e); + } catch (CertificateException e) { + LOGGER.warn("CertificateException - Unable to access certificate (check password)." + + " Failed to initialize the server-side SSLContext", e); } catch (Exception e) { - throw new Error( - "Failed to initialize the server-side SSLContext", e); + LOGGER.warn("Exception - 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; - } - - /** - * @return servercontext - */ - public static SSLContext getServerContext() { - return SERVER_CONTEXT; - } - - /** - * @return cliencontext - */ - public static SSLContext getClientContext() { - return CLIENT_CONTEXT; + return serverContext; } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java index 3868e734..b5fdab1a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java @@ -8,8 +8,15 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.InputStream; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Class for storing keys * @@ -17,17 +24,38 @@ */ public final class SslKeyStore { - private static final String filename = "/key.bin"; + private static final Logger LOGGER = LoggerFactory.getLogger(SslKeyStore.class); /** - * InputStream instance of key + * InputStream instance of key - key location is on classpath + * @param filename keystore location + * @param pathType keystore location type - "classpath" or "path" * * @return key as InputStream */ - public static InputStream asInputStream() { - InputStream in = SslKeyStore.class.getResourceAsStream(filename); - if (in == null) { - throw new IllegalStateException("KeyStore file not found: " + filename); + public static InputStream asInputStream(String filename, PathType pathType) { + InputStream in; + switch (pathType) { + case CLASSPATH: + in = SslKeyStore.class.getResourceAsStream(filename); + if (in == null) { + throw new IllegalStateException("KeyStore file not found: " + + filename); + } + break; + case PATH: + LOGGER.debug("Current dir using System:" + + System.getProperty("user.dir")); + File keystorefile = new File(filename); + try { + in = new FileInputStream(keystorefile); + } catch (FileNotFoundException e) { + throw new IllegalStateException("KeyStore file not found: " + + filename); + } + break; + default: + throw new IllegalArgumentException("Unknown path type: " + pathType); } return in; } @@ -36,13 +64,13 @@ public static InputStream asInputStream() { * @return certificate password as char[] */ public static char[] getCertificatePassword() { - return "secret".toCharArray(); + return "opendaylight".toCharArray(); } /** * @return KeyStore password as char[] */ public static char[] getKeyStorePassword() { - return "secret".toCharArray(); + return "opendaylight".toCharArray(); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 9a346b07..77e1bce6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -21,10 +21,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,47 +54,7 @@ public class TcpHandler implements ServerFacade { private NioEventLoopGroup bossGroup; private final SettableFuture isOnlineFuture; - private final PublishingChannelInitializer channelInitializer; - - /** - * Enum used for storing names of used components (in pipeline). - */ - public static enum COMPONENT_NAMES { - - /** - * Detects switch idle state - */ - IDLE_HANDLER, - /** - * Detects 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 byte messages into POJOs - */ - OF_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol byte messages - */ - OF_ENCODER, - /** - * Delegates translated POJOs into MessageConsumer - */ - DELEGATING_INBOUND_HANDLER, - } - + private PublishingChannelInitializer channelInitializer; /** * Constructor of TCPHandler that listens on selected port. @@ -116,7 +73,6 @@ public TcpHandler(final int port) { public TcpHandler(final InetAddress address, final int port) { this.port = port; this.startupAddress = address; - channelInitializer = new PublishingChannelInitializer(); isOnlineFuture = SettableFuture.create(); } @@ -212,13 +168,6 @@ public int getNumberOfConnections() { return channelInitializer.size(); } - /** - * @return channelInitializer providing channels - */ - public PublishingChannelInitializer getChannelInitializer() { - return channelInitializer; - } - @Override public ListenableFuture getIsOnlineFuture() { return isOnlineFuture; @@ -239,39 +188,10 @@ public String getAddress() { } /** - * @param switchConnectionHandler - */ - public void setSwitchConnectionHandler( - final SwitchConnectionHandler switchConnectionHandler) { - channelInitializer.setSwitchConnectionHandler(switchConnectionHandler); - } - - /** - * @param switchIdleTimeout in milliseconds - */ - public void setSwitchIdleTimeout(final long switchIdleTimeout) { - channelInitializer.setSwitchIdleTimeout(switchIdleTimeout); - } - - /** - * @param tlsSupported - */ - public void setEncryption(final boolean tlsSupported) { - channelInitializer.setEncryption(tlsSupported); - } - - /** - * @param sf serialization factory - */ - public void setSerializationFactory(final SerializationFactory sf) { - channelInitializer.setSerializationFactory(sf); - } - - /** - * @param factory + * @param channelInitializer */ - public void setDeserializationFactory(final DeserializationFactory factory) { - channelInitializer.setDeserializationFactory(factory); + public void setChannelInitializer(PublishingChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetector.java deleted file mode 100644 index 75ce2cc8..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetector.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.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.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; - -/** - * 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); - - private ConnectionFacade connectionFacade; - - /** - * Constructor of class - */ - public TlsDetector() { - LOGGER.trace("Creating TLS Detector"); - detectSsl = true; - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { - LOGGER.warn("Unexpected exception from downstream.", - cause); - ctx.close(); - } - - private boolean isSsl(ByteBuf bb) { - if (detectSsl) { - LOGGER.trace("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.trace("Engaging TLS handler"); - ChannelPipeline p = ctx.channel().pipeline(); - SSLEngine engine = SslContextFactory.getServerContext() - .createSSLEngine(); - engine.setUseClientMode(false); - p.addAfter(COMPONENT_NAMES.TLS_DETECTOR.name(), COMPONENT_NAMES.SSL_HANDLER.name(), - new SslHandler(engine)); - } - } - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf bb, - List list) throws Exception { - if (bb.readableBytes() < 5) { - return; - } - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(ByteBufUtils.byteBufToHexString(bb)); - } - if (isSsl(bb)) { - LOGGER.debug("Connection is encrypted"); - enableSsl(ctx); - } else { - LOGGER.debug("Connection is not encrypted"); - } - - if (connectionFacade != null) { - LOGGER.trace("Firing onConnectionReady notification"); - connectionFacade.fireConnectionReadyNotification(); - } - - ctx.pipeline().remove(COMPONENT_NAMES.TLS_DETECTOR.name()); - } - - /** - * @param connectionFacade the connectionFacade to set - */ - public void setConnectionFacade(ConnectionFacade connectionFacade) { - this.connectionFacade = connectionFacade; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 6dbdef09..45fed553 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -13,11 +13,15 @@ import java.net.UnknownHostException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Objects; + /** * */ @@ -65,13 +69,14 @@ public java.lang.AutoCloseable createInstance() { } /** - * @return + * @return instance configuration object * @throws UnknownHostException */ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException { final InetAddress address = extractIpAddressBin(getAddress()); final Integer port = getPort(); final long switchIdleTimeout = getSwitchIdleTimeout(); + final Tls tlsConfig = getTls(); return new ConnectionConfiguration() { @Override @@ -88,9 +93,33 @@ public Object getTransferProtocol() { return null; } @Override - public FEATURE_SUPPORT getTlsSupport() { - // TODO Auto-generated method stub - return null; + public TlsConfiguration getTlsConfiguration() { + return new TlsConfiguration() { + @Override + public KeystoreType getTlsTruststoreType() { + return Objects.firstNonNull(tlsConfig.getTruststoreType(), null); + } + @Override + public String getTlsTruststore() { + return Objects.firstNonNull(tlsConfig.getTruststore(), null); + } + @Override + public KeystoreType getTlsKeystoreType() { + return Objects.firstNonNull(tlsConfig.getKeystoreType(), null); + } + @Override + public String getTlsKeystore() { + return Objects.firstNonNull(tlsConfig.getKeystore(), null); + } + @Override + public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() { + return Objects.firstNonNull(tlsConfig.getKeystorePathType(), null); + } + @Override + public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() { + return Objects.firstNonNull(tlsConfig.getTruststorePathType(), null); + } + }; } @Override public long getSwitchIdleTimeout() { diff --git a/openflow-protocol-impl/src/main/resources/ctlKeystore b/openflow-protocol-impl/src/main/resources/ctlKeystore new file mode 100644 index 0000000000000000000000000000000000000000..c7310975775cf0418464970fb3f0922901437077 GIT binary patch literal 2254 zcma)-cTkh*7RK`>0VGn5G!YDoQUsPS2?RqEh%{-kfD!2liPX@GG$C{mR1iTa0s)m? zlq>F~cMvIxARR=SEJ#~0AaHSaobk{5$C-JbbKaTvcb<9YoP(8v6$k_ZJqqBT0MJJ# zo$$x6Dj*OR0HnkBK`vH=3@ZQ!&O>VK$b z_R`hrv$J6bYr^W2H~F3Y=}YdOR5m zZ#5$6IgrDJOHUn?j{)}eHos1n&1wc;7L%8JHmt4!(>z zUYol{!>N~xilt?Dyh^`ft3yJ^0>!?LBogZm^KP?w; z$ITKRIPDpt*@OJ&pES4gJo4r|On;RK;ZsicQ`32H?cBi5} z7<&=J(dF;YnKKP&k%bE=}Y(u+~j21X01t*yC+6fmGoYDnP1{GBBli3JUr9$wC*zrI4N*0`29D)S8sP`5~Od+ZSh z6#ByC;(tjkC{&tR;Q{x+?G zyDo-#Y4G9xo>Vf9mZ=pzJSJ|BvS4JqtBca{h(b#hCNHC`1-o$*u`NfmvkPU2{+8Cl|0loH++YKk(1 zyU0dn2WV^tWj}UnY8lK~#Mo5d2h}KbjM|8p@2&2V8%y!HjI_hKMGMVORK9J3qCoU; zdj+|xNApqXhW;25;C3m#we@5m)Z=isQX_qf-MszI8big7;<&DepfpNx%Ou&W{Z0<( zG(iv5wf6N8rkY+>!Y8Mbdd-bp1j54rA*bvEk<8-n4|A^HiY`@=Tq>qw=&IB8d$HCF zW4^(osVhSR%C-I%Dv>v6oPA50JzppYqD!VT-}kIhLF8tnm1~|CS7K$gd9;|9c%YH> zGOj&ou$T9Jkg%f!HN(`ri9vpoM=;*;K+8)`->Do}YuBCas45vvGztK1aPuE_ zqF$P3!$!Cb3?R%T^PsP5^+jK){H2^l^}#6=nfvMM5pieu`sAC_xj=2O@t|5J(Oa zPYMm?Zx-O}OLqF1K91xdd(eEnJ>1+V-ed>#MNsX>Z5R?~a@7p=YY9crL=h<7zRpx< zvV$)LC4~Xe7?iPxKMD(?Fc@VlMp*$P4T=hIq7^_Kh)08p7&LhONGkp!!HBq@c>h1^ z8BpX0)Nv&LuPva+|I$#rj~>MQOD#k8bwfEjDm&sRBn%d>Acs-F;^h=DRJ#%d+2>(N1P8 z2&t|%IW z&0Zp^0Et(%G0aZ0Rw|{Ry?w~wxwLu(>oKdZmvUolGPQQo@`cfheQkcl&PzH;(lGS7 zbOE`}Gfm?Xx#7Kzjovh0J#?UOglEMOe(H; zgx|77)%RYcwLM>I)SQr0Nm{uboFTsXRbA7M*dd5+DdG%)8JpOZtzb^~!*54mjVlI? zy8rl+@7*dAJ3BLS=FI_^#dlNO_CPCWvqFhTNlc_^c305TQY`6hdycA4%TDqepdcN{ z)%?s?%|$vJ>yBplo$rqICv_6GPcnBrnWMVY!D5ozyLVn4;r3YEVuNFAtFs!l7TqP) z17}OT{4f+#OQJP1czCqMm{Sy-9Tl8Yi%K%nGLsWaQWZ3e3=EAF z{PN2bj13fwjI4}}tW1nF4dldm4NVM8jm!d9G}_)hK(_wz4rORao*HT4}m9Z1HCYw)QWfA(> zv2v!$r%2mH;vt74Q!kYt+qYuf-5-+=9;*yH&QvXXFst&_V?ZRk3!e|(#1Zb8?*bBk^;`g~ZBzdAYU zp~Smur<0B*Xk5Q(7Tx@7{`{Rq>RXkx{io}NPB?yewT6Di!if=Xj~?mSPql5?dQ`(p z`Pi1gkEiqgn_Zk*z3<|dbPnk|hocM3Kic_Q9Qkj?zs7S7XL;YM zMNh@`zNY5Lrv5j1m*IHDT4J|#u8q*mw@l2842;Mj1Wa7O5MpGA-KBVcr}pxFm+e#f z-zBa0Q8*y`t9{Dkzxi`lIft~~b=$K#@6zl*(_7Bx!=7>9o-Vn|?aEHnte z^oMJ;MClK2D-Fmp5Sxshd!8eD}UvHL#Tj$y^k~=jLs|K4yApHWoLT;^rM|tv(lgxjt)_R3^a-hx7S~qXeak0g z)|>s{-JT2g|L@rvC2vx8mT88(Z2RhMt0cmfzfC^9y{7YY&Q7tkO?GcSq_3@wxj8>) zMb1RFur<>{Se!F8rEWJdZ`dO6qvlc5Bu~p74}WVsX}+@2Ipb5s-HtWk`}MqTY`5C)Rg4>ypp2)oSf7mprl*D`44}9biY9pW48ex z8<#d4BMYMzlOQ7_D+5atW4Yvn%f|g`Cp1&TuWyQzzMQcv^XY+v%}dX%-6&Vdy42}Y zW&Md6=BGC+9-G9G-f{T*-v=}9R>p2pd60GZRFmngy_`j5xr*LNt4#OT)!F5VskSSe zdwe>u_~8G80l5sbjm7epvc_L;@i-Iw+^oUKvF`Kp-8T|FC(dQu?)x$?N}qQz--BbB zp09UpJ!5X-v_RzW*XC;t(I)m87b{L(`qp-Q|KDp@r>L;9zAgZA?x_I z9~(bO`MEFQVIThZiZQ_-Kd;Z$Hmz)N^9l zLmRQG?vR>ZjR%X@$!Tw1Ryr|naXt4hMbo5@zmuvMRjkh}`M7UI;DpW<&G#QhJ)O@s zsXHyMp*mDGh0(|Q-+50h=EfEVrp5*#kEWuH-;QN$_%rE%an3c{^`%DKGD@no-cR2x zX;KoCZg-e-@8r?{{SLNVFH{$#8NIn~*cY&fgDZWf;ntrHj~qBBW^9@D=Bz~iz*@?WHo-ph3UQE;v?Vjnn^Z3&ao!}p~`kPp`aVbeTkog-jGV z=kq^seAlyVjs?S^)VkbSU|_fHyj-E(HaWk5Kkjds!bbBM9(xy7N3467aZAQq?4-8b MR!6VGPUY390E5dNe*gdg literal 0 HcmV?d00001 diff --git a/openflow-protocol-impl/src/main/resources/selfSignedSwitch b/openflow-protocol-impl/src/main/resources/selfSignedSwitch new file mode 100644 index 0000000000000000000000000000000000000000..645ac44243d3a8af51fa012f7879d245d05c1054 GIT binary patch literal 1348 zcmezO_TO6u1_mY|W&~q_;?$h9;>`5C)Rf}#%#!2`poCk&^&f|T^aO(@#vTJcHZE;8 zMixdbCP79z z{vL2FH)cr72==#S)LUgc(PHjlri(wOALuim?f*=E<7+PNT*lcA@mu-6lmw(yh4<-L}h-Y&+z{I!>H?Z#{ZQ!{7(h^Pn5o=`((rK^)eF|8BY8l9%L)92pnUq z5qhQumJAHc$p%f#@jxuQfSHMriHXIvf&YmCHygWFo5wi|7G_okgT@9!ZUas>=1>+k zVWwbjLs0`^5QjsUC%+&yFD0=uCo?^x1SZUmU6>2IFgJE#W>jGVIdNV?69Y2?GebiI zBO`+-FxS$+1j-!@PHbY_0ZiyRuz+I(a^#sB8yWuA2RF)=3TX!2_nM>k=E?JKg4=^^ z-n%dyma}iz7O0l#8tb4G_&d_JH{#d+qhEI!d^66fYKrV-7ByE+kQ;?hjsY#V=I=4^0WMI{&xAO++ilu5aB4XiALW_Kd;kHysq{B zlM=J!+>0KJ$C*SKrY8jSiz;)U*)(Zq)1ucc+#e!jzJi?g{o#VvYqM?do!+xL#%xFU z&dMq4cmJ|_)$}vmhufCDDLpVUyl>Z)NdISr>;jDqTRg=Im0$R1hzV~$&uP?iV%b9* zv8wKnnqG|ui`U6%Z(de9F>i4__b)}$q>sOosu)$Q&n)@4Z$;pQ&K1q~A4WZ$&o-$$ zEv}(DR5gXs$NJxSPc7!gRtAtewrlO0Rieb17@)L6(p79twcpl?#C@I554~EPbX71u zXj7qobZC$7{mwmB+n?xVA1pbf{Ih^p{C3LK>~A|SvX(1(l`mOPwn4?{^H!~D%kwuU zp6UMdurtVJ$FDU{j@`=9tc{kvCOd)GtJS)vX7~U1e-GbY{(AC#)8lfpCs;3g|8BYJ zVnqXa16g32mgQp+V-fki@~qY6YpgvUy*{(v?mKM|ZLgw$k|UV)84ProL@H7mGR;I& zb1vSVr#Pp#c-;qWu?I{dz73Wqi_+Zp9Q~<%o^R5#J)YMMmR^YWQ7f+gl<8W)zE1Om KmC%%2<4FL78zvqA literal 0 HcmV?d00001 diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index ddd6ebd1..0abc830a 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -6,6 +6,7 @@ module openflow-switch-connection-provider-impl { import config {prefix config; revision-date 2013-04-05; } import openflow-switch-connection-provider {prefix openflow-switch-connection-provider; revision-date 2014-03-28; } import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; } + import openflow-configuration {prefix of-config; revision-date 2014-06-30; } description "openflow-switch-connection-provider"; @@ -40,10 +41,31 @@ module openflow-switch-connection-provider-impl { type uint32; mandatory true; } - leaf tls-support { - description "tls support enabled (requires SSL-context / keystore)"; - type boolean; - default false; + container tls { + leaf keystore { + description "keystore location"; + type string; + } + leaf keystore-type { + description "keystore type (JKS or PKCS12)"; + type of-config:keystore-type; + } + leaf keystore-path-type { + description "keystore path type (classpath or path)"; + type of-config:path-type; + } + leaf truststore { + description "truststore location"; + type string; + } + leaf truststore-type { + description "truststore type (JKS or PKCS12)"; + type of-config:keystore-type; + } + leaf truststore-path-type { + description "truststore path type (classpath or path)"; + type of-config:path-type; + } } } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java new file mode 100644 index 00000000..cc3d30c7 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.channel.ChannelHandlerContext; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author jameshall + */ +public class DelegatingInboundHandlerTest { + + @Mock ChannelHandlerContext mockChHndlrCtx ; + @Mock MessageConsumer mockMsgConsumer ; + @Mock DataObject mockDataObject ; + + DelegatingInboundHandler dih ; + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + dih = new DelegatingInboundHandler(mockMsgConsumer) ; + } + + /** + * + */ + @Test + public void testChannelReadSuccess() { + dih.channelRead(mockChHndlrCtx, mockDataObject) ; + + // Verify that the message buf was released... + verify( mockMsgConsumer, times(1)).consume(mockDataObject); + } + /** + * + */ + @Test + public void testChannelInactive() { + dih.channelInactive(mockChHndlrCtx); + + verify( mockMsgConsumer, times(1)).consume(any(DataObject.class)); + } + + /** + * ChannelUnregistered + */ + @Test + public void testChannelUnregistered() { + dih.channelUnregistered(mockChHndlrCtx); + + verify( mockMsgConsumer, times(1)).consume(any(DataObject.class)); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java new file mode 100644 index 00000000..aa08feb5 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.channel.ChannelHandlerContext; + +import java.util.concurrent.TimeUnit; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; + +/** + * + * @author jameshall + */ +public class IdleHandlerTest { + + @Mock ChannelHandlerContext mockChHndlrCtx ; + + IdleHandler idleHandler ; + + /** + * Sets up test environment + * + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + idleHandler = new IdleHandler(60L, TimeUnit.MINUTES ) ; + } + + /** + * Test message passing on channel read + */ + @Test + public void testChannelRead() { + try { + idleHandler.channelRead(mockChHndlrCtx, new Object() ); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that a read was fired for the next handler ... + verify(mockChHndlrCtx, times(1)).fireChannelRead(any(SwitchIdleEvent.class)) ; + } + + /** + * Test channel read timeout + */ + @Test + public void testReadTimedOut() { + try { + idleHandler.readTimedOut( mockChHndlrCtx ); + } catch (Exception e) { + Assert.fail(); + } + + // Verify a read was fired for the next handler to process ... + verify(mockChHndlrCtx, times(1)).fireChannelRead(any(SwitchIdleEvent.class)) ; + } + + /** + * Test only one timeout notification + */ + @Test + public void testReadTimedOutNoOpNotFirst() { + try { + idleHandler.readTimedOut(mockChHndlrCtx); + idleHandler.readTimedOut(mockChHndlrCtx); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that only one notification was sent to the next handler ... + verify(mockChHndlrCtx, times(1)).fireChannelRead(any(Object.class)) ; + } + + /** + * Test two timeout notifications + */ + @Test + public void testReadTimedOutTwice() { + try { + idleHandler.readTimedOut(mockChHndlrCtx); + verify(mockChHndlrCtx, times(1)).fireChannelRead(any(Object.class)) ; + + idleHandler.channelRead(mockChHndlrCtx, new String() ); + verify(mockChHndlrCtx, times(2)).fireChannelRead(any(Object.class)) ; + + idleHandler.readTimedOut(mockChHndlrCtx); + verify(mockChHndlrCtx, times(3)).fireChannelRead(any(Object.class)) ; + } catch (Exception e) { + Assert.fail(); + } + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java new file mode 100644 index 00000000..8337b792 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyShort; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * + * @author jameshall + */ +public class OFDecoderTest { + + @Mock ChannelHandlerContext mockChHndlrCtx ; + @Mock DeserializationFactory mockDeserializationFactory ; + @Mock DataObject mockDataObject ; + + OFDecoder ofDecoder ; + private ByteBuf writeObj; + private VersionMessageWrapper inMsg; + private List outList; + + /** + * Sets up test environment + * + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + ofDecoder = new OFDecoder() ; + ofDecoder.setDeserializationFactory( mockDeserializationFactory ) ; + writeObj = ByteBufUtils.hexStringToByteBuf("16 03 01 00"); + inMsg = new VersionMessageWrapper( (short)8, writeObj ); + outList = new ArrayList<>(); + } + + /** + * + */ + @Test + public void testDecode() { + when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )).thenReturn(mockDataObject); + try { + ofDecoder.decode(mockChHndlrCtx, inMsg, outList); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that the message buf was released... + assertEquals( mockDataObject, outList.get(0) ) ; + assertEquals( 0, writeObj.refCnt() ) ; + } + + /** + * + */ + @Test + public void testDecodeDeserializeException() { + when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )) + .thenThrow(new IllegalArgumentException()) ; + + try { + ofDecoder.decode(mockChHndlrCtx, inMsg, outList); + } catch (Exception e) { + System.out.println("a"); + Assert.fail(); + } + + // Verify that the message buf was released... + assertEquals( 0, outList.size() ) ; + assertEquals( 1, writeObj.refCnt() ) ; + } + + /** + * + */ + @Test + public void testDecodeDeserializeNull() { + when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )) + .thenReturn(null) ; + + try { + ofDecoder.decode(mockChHndlrCtx, inMsg, outList); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that the message buf was released... + assertEquals( 0, outList.size() ) ; + assertEquals( 1, writeObj.refCnt() ) ; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java new file mode 100644 index 00000000..11d2098a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyShort; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * + * @author jameshall + */ +public class OFEncoderTest { + + @Mock ChannelHandlerContext mockChHndlrCtx ; + @Mock SerializationFactory mockSerializationFactory ; + @Mock OfHeader mockMsg ; + @Mock ByteBuf mockOut ; + + OFEncoder ofEncoder = new OFEncoder() ; + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + ofEncoder = new OFEncoder() ; + ofEncoder.setSerializationFactory( mockSerializationFactory ) ; + } + + /** + * Test successful write (no clear) + */ + @Test + public void testEncodeSuccess() { + when(mockOut.readableBytes()).thenReturn(1); + try { + ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that the channel was flushed after the ByteBuf was retained. + verify(mockOut, times(0)).clear(); + } + + /** + * Test Bytebuf clearing after serialization failure + */ + @Test + public void testEncodeSerializationException() { + doThrow(new IllegalArgumentException()).when(mockSerializationFactory).messageToBuffer(anyShort(),any(ByteBuf.class), any(DataObject.class)); + try { + ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that the output message buf was cleared... + verify(mockOut, times(1)).clear(); + } + + /** + * Test no action on empty bytebuf + */ + @Test + public void testEncodeSerializesNoBytes() { + when(mockOut.readableBytes()).thenReturn(0); + try { + ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + } catch (Exception e) { + Assert.fail(); + } + + // Verify that the output message buf was cleared... + verify(mockOut, times(0)).clear(); + verify(mockChHndlrCtx, times(0)).writeAndFlush(mockOut); + verify(mockOut, times(0)).retain(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java index d758ab8f..786a0d88 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; @@ -19,7 +20,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; /** @@ -33,6 +36,8 @@ public class OFFrameDecoderTest { @Mock ChannelHandlerContext channelHandlerContext; + @Mock + ConnectionFacade connectionFacade; private OFFrameDecoder decoder; private List list = new ArrayList<>(); @@ -41,69 +46,104 @@ public class OFFrameDecoderTest { */ @Before public void setUp() { + MockitoAnnotations.initMocks(this); + decoder = new OFFrameDecoder(connectionFacade); list.clear(); - decoder = new OFFrameDecoder(); + } /** * Test of decoding * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} - * - * @throws Exception */ @Test - public void testDecode8BMessage() throws Exception { - decoder.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"), - list); + public void testDecode8BMessage() { + try { + decoder.decode(channelHandlerContext, + ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"), + list); + } catch (Exception e) { + Assert.fail(); + } + + assertEquals(8, ((ByteBuf) list.get(0)).readableBytes()); + } - Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes()); + /** + * Test of decoding + * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} + */ + @Test + public void testDecode16BMessage() { + ByteBuf byteBuffer = ByteBufUtils + .hexStringToByteBuf("04 00 00 10 00 00 00 00 00 00 00 00 00 00 00 42"); + try { + decoder.decode(channelHandlerContext, byteBuffer, list); + } catch (Exception e) { + Assert.fail(); + } + + assertEquals(16, ((ByteBuf) list.get(0)).readableBytes()); + assertEquals(0, byteBuffer.readableBytes()); } /** * Test of decoding * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} - * - * @throws Exception */ @Test - public void testDecode16BMessage() throws Exception { - decoder.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("04 00 00 10 00 00 00 00 00 00 00 00 00 00 00 42"), - list); + public void testDecode5BIncompleteMessage() { + ByteBuf byteBuffer = ByteBufUtils.hexStringToByteBuf("04 00 00 08 00"); + try { + decoder.decode(channelHandlerContext, byteBuffer, list); + } catch (Exception e) { + Assert.fail(); + } - Assert.assertEquals(16, ((ByteBuf) list.get(0)).readableBytes()); + Assert.assertEquals("List is not empty", 0, list.size()); + assertEquals(5, byteBuffer.readableBytes()); } /** * Test of decoding * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} - * - * @throws Exception */ @Test - public void testDecodeIncompleteMessage() throws Exception { - decoder.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("04 00 00 08 00"), - list); + public void testDecode16BIncompleteMessage() { + ByteBuf byteBuffer = ByteBufUtils + .hexStringToByteBuf("04 00 00 11 00 00 00 00 00 00 00 00 00 00 00 42"); + try { + decoder.decode(channelHandlerContext, byteBuffer, list); + } catch (Exception e) { + Assert.fail(); + } Assert.assertEquals("List is not empty", 0, list.size()); + assertEquals(16, byteBuffer.readableBytes()); } /** * Test of decoding * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} - * - * @throws Exception */ @Test - public void testDecodeCompleteAndPartialMessage() throws Exception { - decoder.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01 04 00 00 08 00"), - list); + public void testDecodeCompleteAndPartialMessage() { + ByteBuf byteBuffer = ByteBufUtils + .hexStringToByteBuf("04 00 00 08 00 00 00 01 04 00 00 08 00"); + try { + decoder.decode(channelHandlerContext, byteBuffer, list); + } catch (Exception e) { + Assert.fail(); + } Assert.assertEquals(8, ((ByteBuf) list.get(0)).readableBytes()); Assert.assertEquals(1, list.size()); + assertEquals(5, byteBuffer.readableBytes()); + + } + + @Test + public void testExceptionCaught() throws Exception { + decoder.exceptionCaught(channelHandlerContext, new Throwable()); } - -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java index fb3369bf..0f1d87d0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java @@ -8,12 +8,14 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import java.util.ArrayList; import java.util.List; import org.junit.Assert; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -60,6 +62,39 @@ public void testDecode13ProtocolMessage() throws Exception { .getMessageBuffer().readableBytes()); } + /** + * Test of decode + * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) + * } + * @throws Exception + */ + @Test + public void testDecode10ProtocolMessage() throws Exception { + detector.decode(channelHandlerContext, + ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01"), + list); + + Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)) + .getMessageBuffer().readableBytes()); + } + + /** + * Test of decode + * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) + * } + * @throws Exception + */ + @Test + public void testDecodeEmptyProtocolMessage() throws Exception { + ByteBuf byteBuffer = ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01").skipBytes(8); + detector.decode(channelHandlerContext, + byteBuffer, + list); + + assertEquals( 0, byteBuffer.refCnt() ) ; + + } + /** * Test of decode * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java new file mode 100644 index 00000000..c6ececd8 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * + * @author jameshall + */ +public class PublishingChannelInitializerFactoryTest { + + TlsConfiguration tlsConfiguration ; + PublishingChannelInitializerFactory factory; + private final long switchIdleTimeOut = 60; + @Mock SwitchConnectionHandler switchConnectionHandler ; + @Mock SerializationFactory serializationFactory; + @Mock DeserializationFactory deserializationFactory ; + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + factory = new PublishingChannelInitializerFactory(); + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/ctlTrustStore", + PathType.CLASSPATH, KeystoreType.JKS, "/ctlKeystore", PathType.CLASSPATH); + factory.setDeserializationFactory(deserializationFactory); + factory.setSerializationFactory(serializationFactory); + factory.setSwitchConnectionHandler(switchConnectionHandler); + factory.setSwitchIdleTimeout(switchIdleTimeOut); + factory.setTlsConfig(tlsConfiguration); + } + + /** + * Test {@link PublishingChannelInitializer} creation + */ + @Test + public void testCreatePublishingChannelInitializer() { + PublishingChannelInitializer initializer = factory.createPublishingChannelInitializer() ; + assertNotNull( initializer ); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java new file mode 100644 index 00000000..55b13552 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.group.DefaultChannelGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.ssl.SslHandler; + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.UnknownHostException; + +import javax.net.ssl.SSLEngine; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializer.COMPONENT_NAMES; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.Tls; + +/** + * + * @author james.hall + */ +public class PublishingChannelInitializerTest { + + @Mock SocketChannel mockSocketCh ; + @Mock ChannelPipeline mockChPipeline ; + @Mock SwitchConnectionHandler mockSwConnHandler ; + @Mock ConnectionAdapterFactory mockConnAdaptorFactory; + @Mock DefaultChannelGroup mockChGrp ; + @Mock ConnectionFacade mockConnFacade ; + @Mock Tls mockTls ; + SSLEngine sslEngine ; + + @Mock SerializationFactory mockSerializationFactory ; + @Mock DeserializationFactory mockDeserializationFactory ; + + TlsConfiguration tlsConfiguration ; + InetSocketAddress inetSockAddr; + PublishingChannelInitializer pubChInitializer ; + + /** + * Sets up test environment + * @throws Exception + */ + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + pubChInitializer= new PublishingChannelInitializer(mockChGrp, mockConnAdaptorFactory) ; + pubChInitializer.setSerializationFactory(mockSerializationFactory); + pubChInitializer.setDeserializationFactory(mockDeserializationFactory); + pubChInitializer.setSwitchIdleTimeout(1) ; + pubChInitializer.getConnectionIterator() ; + + when( mockChGrp.size()).thenReturn(1) ; + pubChInitializer.setSwitchConnectionHandler( mockSwConnHandler ) ; + + inetSockAddr = new InetSocketAddress(InetAddress.getLocalHost(), 8675 ) ; + + when(mockConnAdaptorFactory.createConnectionFacade(mockSocketCh)) + .thenReturn(mockConnFacade); + when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ; + when(mockSocketCh.localAddress()).thenReturn(inetSockAddr) ; + when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ; + when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(true) ; + when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ; + + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/selfSignedSwitch", PathType.PATH, + KeystoreType.JKS, "src/main/resources/selfSignedController", PathType.PATH); + } + + + /** + * Test channel initialization with encryption config set + */ + @Test + public void testinitChannelEncryptionSet() { + pubChInitializer.setTlsConfiguration(tlsConfiguration); + pubChInitializer.initChannel(mockSocketCh) ; + + verifyCommonHandlers(); + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.SSL_HANDLER.name()),any(SslHandler.class)) ; + } + + /** + * Test channel initialization with null encryption config + */ + @Test + public void testinitChannelEncryptionSetNullTls() { + pubChInitializer.setTlsConfiguration(null); + pubChInitializer.initChannel(mockSocketCh) ; + + verifyCommonHandlers(); + verify(mockChPipeline, times(0)).addLast(eq(COMPONENT_NAMES.SSL_HANDLER.name()),any(SslHandler.class)) ; + } + + /** + * Test channel initialization without setting the encryption + */ + @Test + public void testinitChannelEncryptionNotSet() { + // Without encryption, only the common + pubChInitializer.initChannel(mockSocketCh) ; + + verifyCommonHandlers(); + } + + /** + * Test disconnect on new connection rejected + * @throws UnknownHostException + */ + @Test + public void testinitChannelNoEncryptionAcceptFails() throws UnknownHostException { + when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(false) ; + pubChInitializer.initChannel(mockSocketCh) ; + + verify(mockSocketCh, times(1)).disconnect(); + verify(mockChPipeline, times(0)) + .addLast( any(String.class), any(ChannelHandler.class) ) ; + } + + /** + * Test channel close on exception during initialization + */ + @Test + public void testExceptionThrown() { + doThrow(new IllegalArgumentException()).when(mockSocketCh).pipeline() ; + pubChInitializer.initChannel(mockSocketCh); + + verify( mockSocketCh, times(1)).close() ; + } + + /** + * All paths should install these six handlers: + */ + private void verifyCommonHandlers() { + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.IDLE_HANDLER.name()),any(IdleHandler.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_DECODER.name()),any(OFDecoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_ENCODER.name()),any(OFEncoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_FRAME_DECODER.name()),any(OFFrameDecoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_VERSION_DETECTOR.name()),any(OFVersionDetector.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.DELEGATING_INBOUND_HANDLER.name()),any(DelegatingInboundHandler.class)); + assertEquals(1, pubChInitializer.size()) ; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java new file mode 100644 index 00000000..2457fd33 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertNotNull; + +import javax.net.ssl.SSLContext; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * + * @author jameshall + */ +public class SslContextFactoryTest { + + SslContextFactory sslContextFactory; + TlsConfiguration tlsConfiguration ; + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/ctlTrustStore", + PathType.PATH, KeystoreType.JKS, "src/main/resources/ctlKeystore", PathType.PATH) ; + sslContextFactory = new SslContextFactory(tlsConfiguration); + } + + /** + * @throws Exception + */ + @Test + public void testGetServerContext() throws Exception { + SSLContext context = sslContextFactory.getServerContext() ; + + assertNotNull( context ); + } + +} + diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java new file mode 100644 index 00000000..7c871bbd --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * + * @author jameshall + */ +public class SslKeyStoreTest { + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test keystore file access + * @throws Exception + */ + @Test + public void testAsInputStream() throws Exception { + InputStream inputStream = SslKeyStore.asInputStream("src/main/resources/key.bin", PathType.PATH); + assertNotNull( inputStream ); + inputStream.close(); + } + + /** + * Test certificate password retrieval + */ + @Test + public void testGetCertificatePassword() { + char[] password = SslKeyStore.getCertificatePassword(); + assertNotNull(password); + assertTrue (password.length>0) ; + } + + /** + * Test keystore password retrieval + */ + @Test + public void testGetKeyStorePassword() { + char[] password = SslKeyStore.getKeyStorePassword() ; + assertNotNull(password); + assertTrue (password.length>0) ; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java new file mode 100644 index 00000000..23362840 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.security.cert.X509Certificate; + +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; + +/** + * + * @author jameshall + */ +public class SslTrustManagerFactoryTest { + + /** + * Sets up test environment + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * + */ + @Test + public void testGetTrustManagers() throws Exception { + TrustManager[] tmArray = SslTrustManagerFactory.getTrustManagers() ; + + assertNotNull( tmArray ); + for ( TrustManager tm : tmArray ) { + if ( tm.getClass() == X509TrustManager.class ) { + X509Certificate[] certsArray = ((X509TrustManager)tm).getAcceptedIssuers() ; + assertTrue( certsArray.length > 0 ) ; + + // Boolean caught = false; + // try { + // ((X509TrustManager)tm).checkClientTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; + // } catch (CertificateException ce) { + // caught = true ; + // } + // assertTrue( caught ) ; + // + // caught = false; + // try { + // ((X509TrustManager)tm).checkServerTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; + // } catch (CertificateException ce) { + // caught = true ; + // } + // assertTrue( caught ) ; + // } + } + } + } +} + diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java new file mode 100644 index 00000000..7092922f --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.junit.Assert.assertEquals; +import io.netty.channel.ChannelHandlerContext; + +import java.io.IOException; +import java.net.BindException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.concurrent.ExecutionException; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * + * @author jameshall + */ +public class TcpHandlerTest { + + private InetAddress serverAddress = InetAddress.getLoopbackAddress() ; + @Mock ChannelHandlerContext mockChHndlrCtx ; + @Mock PublishingChannelInitializer mockChannelInitializer; + @Mock SwitchConnectionHandler mockSwitchConnHndler ; + @Mock SerializationFactory mockSerializationFactory ; + @Mock DeserializationFactory mockDeserializationFactory ; + + TcpHandler tcpHandler ; + + /** + * Initialize mocks + */ + public TcpHandlerTest() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test run with null address set + * @throws IOException + * @throws InterruptedException + * @throws ExecutionException + */ + @Test + public void testRunWithNullAddress() throws IOException, InterruptedException, ExecutionException { + + tcpHandler = new TcpHandler(null, 0); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + assertEquals("failed to start server", true, startupServer()) ; + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; + shutdownServer(); + } + + /** + * Test run with address set + * @throws IOException + * @throws InterruptedException + * @throws ExecutionException + */ + @Test + public void testRunWithAddress() throws IOException, InterruptedException, ExecutionException { + + tcpHandler = new TcpHandler(serverAddress, 0); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + assertEquals("failed to start server", true, startupServer()) ; + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; + shutdownServer(); + } + + /** + * Test run with encryption + * @throws InterruptedException + * @throws IOException + * @throws ExecutionException + */ + @Test + public void testRunWithEncryption () throws InterruptedException, IOException, ExecutionException { + int serverPort = 28001; + tcpHandler = new TcpHandler(serverAddress, serverPort); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + assertEquals( "failed to start server", true, startupServer()) ; + assertEquals( "wrong connection count", 0, tcpHandler.getNumberOfConnections() ); + assertEquals( "wrong port", serverPort, tcpHandler.getPort() ); + assertEquals( "wrong address", serverAddress.getHostAddress(), tcpHandler.getAddress()) ; + + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; + + shutdownServer(); + } + + /** + * Test run on already used port + * @throws IOException + */ + @Test + public void testSocketAlreadyInUse() throws IOException { + int serverPort = 28001; + Socket firstBinder = new Socket(); + boolean exceptionThrown = false; + try { + firstBinder.bind(new InetSocketAddress(serverAddress, serverPort)); + } catch (Exception e) { + Assert.fail("Test precondition failed - not able to bind socket to port " + serverPort); + } + try { + tcpHandler = new TcpHandler(serverAddress, serverPort); + tcpHandler.setChannelInitializer(mockChannelInitializer); + tcpHandler.run(); + } catch (Exception e) { + if (e instanceof BindException) { + exceptionThrown = true; + } + } + firstBinder.close(); + Assert.assertTrue("Expected BindException has not been thrown", exceptionThrown == true); + } + + /** + * Trigger the server shutdown and wait 2 seconds for completion + */ + private void shutdownServer() throws InterruptedException, ExecutionException { + ListenableFuture shutdownRet = tcpHandler.shutdown() ; + while ( shutdownRet.isDone() != true ) + Thread.sleep(100) ; + assertEquals("shutdown failed", true, shutdownRet.get()); + } + + /** + * @throws InterruptedException + * @throws IOException + * @throws ExecutionException + */ + private Boolean startupServer() throws InterruptedException, IOException, ExecutionException { + ListenableFuture online = tcpHandler.getIsOnlineFuture(); + + (new Thread(tcpHandler)).start(); + int retry = 0; + while (online.isDone() != true && retry++ < 20) { + Thread.sleep(100); + } + return online.isDone() ; + } + /** + * @throws IOException + */ + private static Boolean clientConnection(int port) throws IOException { + // Connect, and disconnect + Socket socket = new Socket(InetAddress.getLoopbackAddress(), port ); + Boolean result = socket.isConnected(); + socket.close() ; + return result ; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetectorTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetectorTest.java deleted file mode 100644 index 32685846..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TlsDetectorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.embedded.EmbeddedChannel; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler.COMPONENT_NAMES; - -/** - * - * @author michal.polkorab - */ -public class TlsDetectorTest { - - private EmbeddedChannel embch; - - /** - * Sets up test environment - */ - @Before - public void setUp() { - TlsDetector tlsDetector = new TlsDetector(); - embch = new EmbeddedChannel(new DummyDecoder()); - embch.pipeline().addFirst(TcpHandler.COMPONENT_NAMES.TLS_DETECTOR.name(), tlsDetector); - } - - /** - * Test of decode {@link TlsDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) } - * @throws Exception - */ - @Test - public void testDecodeNotEncryptedMessage() throws Exception { - byte[] msgs = new byte[]{0x04, 0x0, 0x0, 0x08, 0x0, 0x0, 0x0, 0x01}; - ByteBuf writeObj = embch.alloc().buffer(64); - writeObj.writeBytes(msgs); - embch.writeInbound(writeObj); - - Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.TLS_DETECTOR.name())); - Assert.assertNull(embch.pipeline().get(COMPONENT_NAMES.SSL_HANDLER.name())); - } -} \ No newline at end of file diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java deleted file mode 100644 index 7cbae3f0..00000000 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.integration; - -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration.FEATURE_SUPPORT; -import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent; -import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory; -import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler; -import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent; -import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient; -import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent; -import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; -import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; -import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class IntegrationTest { - - private static final Logger LOGGER = LoggerFactory - .getLogger(IntegrationTest.class); - private static int port; - private static final FEATURE_SUPPORT DEFAULT_TLS_SUPPORT = FEATURE_SUPPORT.NOT_SUPPORTED; - private static final int SWITCH_IDLE_TIMEOUT = 2000; - private static final long CONNECTION_TIMEOUT = 2000; - private InetAddress startupAddress; - private MockPlugin mockPlugin; - private SwitchConnectionProviderImpl scpimpl; - private TestingConnConfigImpl configs; - - /** - * @throws Exception - */ - @Before - public void setUp() throws Exception { - LOGGER.debug("\n\nstarting test -------------------------------"); - startupAddress = InetAddress.getLocalHost(); - mockPlugin = new MockPlugin(); - scpimpl = new SwitchConnectionProviderImpl(); - scpimpl.setSwitchConnectionHandler(mockPlugin); - configs = new TestingConnConfigImpl(startupAddress, 0, DEFAULT_TLS_SUPPORT, SWITCH_IDLE_TIMEOUT); - scpimpl.setConfiguration(configs); - scpimpl.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); - TcpHandler server = (TcpHandler) scpimpl.getServerFacade(); - port = server.getPort(); - } - - /** - * @throws Exception - */ - @After - public void tearDown() throws Exception { - Thread.sleep(500); - } - - /** - * Library integration and communication test with handshake - * @throws Exception - */ - @Test - public void testHandshake() throws Exception { - int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler); - SimpleClient firstClient = clients.get(0); - firstClient.getScenarioDone().get(); - mockPlugin.shutdown(); - mockPlugin.getFinishedFuture().get(); - } - - /** - * Library integration and communication test with handshake + echo exchange - * @throws Exception - */ - @Test - public void testHandshakeAndEcho() throws Exception { - int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); - scenario.add(0, new SleepEvent(100)); - scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); - scenario.add(0, new SleepEvent(100)); - scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler); - SimpleClient firstClient = clients.get(0); - firstClient.getScenarioDone().get(); - mockPlugin.shutdown(); - mockPlugin.getFinishedFuture().get(); - } - - /** - * Library integration and communication test (with virtual machine) - * @throws Exception - */ - //@Test - public void testCommunicationWithVM() throws Exception { - mockPlugin.getFinishedFuture().get(); - } - - /** - * @param amountOfCLients - * @return new clients up and running - * @throws ExecutionException if some client could not start - */ - private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler) - throws ExecutionException { - List clientsHorde = new ArrayList<>(); - for (int i = 0; i < amountOfCLients; i++) { - LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress()); - SimpleClient sc = new SimpleClient(startupAddress.getHostAddress(), port); - sc.setSecuredClient(false); - sc.setScenarioHandler(scenarioHandler); - clientsHorde.add(sc); - sc.start(); - } - for (SimpleClient sc : clientsHorde) { - try { - sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (Exception e) { - LOGGER.error(e.getMessage(), e); - throw new ExecutionException(e); - } - } - return clientsHorde; - } - -} diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/TestingConnConfigImpl.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java similarity index 69% rename from openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/TestingConnConfigImpl.java rename to openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java index 578001d4..17058269 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/TestingConnConfigImpl.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java @@ -6,35 +6,36 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.integration; +package org.opendaylight.openflowjava.protocol.it.integration; import java.net.InetAddress; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; /** * @author michal.polkorab * */ -public class TestingConnConfigImpl implements ConnectionConfiguration { +public class ConnectionConfigurationImpl implements ConnectionConfiguration { private InetAddress address; private int port; private Object transferProtocol; - private FEATURE_SUPPORT tlsSupport; + private TlsConfiguration tlsConfig; private long switchIdleTimeout; /** - * Creates {@link TestingConnConfigImpl} + * Creates {@link ConnectionConfigurationImpl} * @param address * @param port - * @param tlsSupport + * @param tlsConfig * @param switchIdleTimeout */ - public TestingConnConfigImpl(InetAddress address, int port, FEATURE_SUPPORT tlsSupport, long switchIdleTimeout) { + public ConnectionConfigurationImpl(InetAddress address, int port, TlsConfiguration tlsConfig, long switchIdleTimeout) { this.address = address; this.port = port; - this.tlsSupport = tlsSupport; + this.tlsConfig = tlsConfig; this.switchIdleTimeout = switchIdleTimeout; } @@ -53,11 +54,6 @@ public Object getTransferProtocol() { return transferProtocol; } - @Override - public FEATURE_SUPPORT getTlsSupport() { - return tlsSupport; - } - @Override public long getSwitchIdleTimeout() { return switchIdleTimeout; @@ -69,4 +65,9 @@ public Object getSslContext() { return null; } + @Override + public TlsConfiguration getTlsConfiguration() { + return tlsConfig; + } + } diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java new file mode 100644 index 00000000..8a391dfa --- /dev/null +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.it.integration; + +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +import org.junit.After; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory; +import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler; +import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient; +import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; +import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; +import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * @author timotej.kubas + */ +public class IntegrationTest { + + private static final Logger LOGGER = LoggerFactory + .getLogger(IntegrationTest.class); + + private static int port; + private TlsConfiguration tlsConfiguration ; + private static final int SWITCH_IDLE_TIMEOUT = 2000; + private static final long CONNECTION_TIMEOUT = 2000; + private InetAddress startupAddress; + private MockPlugin mockPlugin; + private SwitchConnectionProviderImpl switchConnectionProvider; + private ConnectionConfigurationImpl connConfig; + + /** + * @param secured true if an encrypted connection should be used + * @throws Exception + */ + public void setUp(boolean secured) throws Exception { + LOGGER.debug("\n starting test -------------------------------"); + + String currentDir = System.getProperty("user.dir"); + LOGGER.debug("Current dir using System:" +currentDir); + startupAddress = InetAddress.getLocalHost(); + if (secured) { + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, + "../openflow-protocol-impl/src/main/resources/selfSignedSwitch", PathType.PATH, KeystoreType.JKS, + "../openflow-protocol-impl/src/main/resources/selfSignedController", PathType.PATH) ; + connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + } else { + connConfig = new ConnectionConfigurationImpl(startupAddress, 0, null, SWITCH_IDLE_TIMEOUT); + } + mockPlugin = new MockPlugin(); + + switchConnectionProvider = new SwitchConnectionProviderImpl(); + switchConnectionProvider.setSwitchConnectionHandler(mockPlugin); + switchConnectionProvider.setConfiguration(connConfig); + switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); + TcpHandler tcpHandler = (TcpHandler) switchConnectionProvider.getServerFacade(); + port = tcpHandler.getPort(); + } + + /** + * @throws Exception + */ + @After + public void tearDown() throws Exception { + switchConnectionProvider.close(); + LOGGER.debug("\n ending test -------------------------------"); + + } + + /** + * Library integration and communication test with handshake + * @throws Exception + */ + @Test + public void testHandshake() throws Exception { + setUp(false); + int amountOfCLients = 1; + Stack scenario = ScenarioFactory.createHandshakeScenario(); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(amountOfCLients, handler, false); + SimpleClient firstClient = clients.get(0); + firstClient.getScenarioDone().get(); + Thread.sleep(1000); + + LOGGER.debug("testHandshake() Finished") ; + } + + /** + * Library integration and communication test with handshake + * @throws Exception + */ + @Test + public void testTlsHandshake() throws Exception { + setUp(true); + int amountOfCLients = 1; + Stack scenario = ScenarioFactory.createHandshakeScenario(); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(amountOfCLients, handler, true); + SimpleClient firstClient = clients.get(0); + firstClient.getScenarioDone().get(); + Thread.sleep(1000); + + LOGGER.debug("testTlsHandshake() Finished") ; + } + + /** + * Library integration and communication test with handshake + echo exchange + * @throws Exception + */ + @Test + public void testHandshakeAndEcho() throws Exception { + setUp(false); + int amountOfCLients = 1; + Stack scenario = ScenarioFactory.createHandshakeScenario(); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(amountOfCLients, handler, false); + SimpleClient firstClient = clients.get(0); + firstClient.getScenarioDone().get(); + + LOGGER.debug("testHandshakeAndEcho() Finished") ; + } + + /** + * Library integration and communication test with handshake + echo exchange + * @throws Exception + */ + @Test + public void testTlsHandshakeAndEcho() throws Exception { + setUp(true); + int amountOfCLients = 1; + Stack scenario = ScenarioFactory.createHandshakeScenario(); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(amountOfCLients, handler, true); + SimpleClient firstClient = clients.get(0); + firstClient.getScenarioDone().get(); + + LOGGER.debug("testTlsHandshakeAndEcho() Finished") ; + } + + /** + * Library integration and communication test (with virtual machine) + * @throws Exception + */ + //@Test + public void testCommunicationWithVM() throws Exception { + mockPlugin.getFinishedFuture().get(); + } + + /** + * @param amountOfCLients + * @param secured true if encrypted connection should be used + * @return new clients up and running + * @throws ExecutionException if some client could not start + */ + private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler, + boolean secured) throws ExecutionException { + List clientsHorde = new ArrayList<>(); + for (int i = 0; i < amountOfCLients; i++) { + LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress()); + SimpleClient sc = new SimpleClient(startupAddress.getHostAddress(), port); + sc.setSecuredClient(secured); + sc.setScenarioHandler(scenarioHandler); + clientsHorde.add(sc); + sc.start(); + } + for (SimpleClient sc : clientsHorde) { + try { + sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (Exception e) { + LOGGER.error("createAndStartClient: Something borked ... ", e.getMessage(), e); + throw new ExecutionException(e); + } + } + return clientsHorde; + } + +} diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java similarity index 85% rename from openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java rename to openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index e8834a98..b4f69bb0 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.integration; +package org.opendaylight.openflowjava.protocol.it.integration; import java.net.InetAddress; import java.util.Arrays; @@ -52,7 +52,7 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan SystemNotificationsListener, ConnectionReadyListener { protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class); - protected ConnectionAdapter adapter; + protected volatile ConnectionAdapter adapter; private SettableFuture finishedFuture; private int idleCounter = 0; @@ -74,22 +74,25 @@ public void onSwitchConnected(ConnectionAdapter connection) { @Override public boolean accept(InetAddress switchAddress) { + LOGGER.debug("MockPlugin.accept(): " + switchAddress.toString()); + return true; } @Override public void onEchoRequestMessage(final EchoRequestMessage notification) { + LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: "+adapter); new Thread(new Runnable() { @Override public void run() { - LOGGER.debug("EchoRequest message received"); + LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: "+adapter); EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder(); replyBuilder.setVersion((short) 4); replyBuilder.setXid(notification.getXid()); EchoReplyInput echoReplyInput = replyBuilder.build(); adapter.echoReply(echoReplyInput); - LOGGER.debug("EchoReplyInput sent"); - LOGGER.debug("adapter: "+adapter); + LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString()); + LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: "+adapter); } }).start(); } @@ -117,7 +120,7 @@ public void onHelloMessage(HelloMessage notification) { new Thread(new Runnable() { @Override public void run() { - LOGGER.debug("Hello message received"); + LOGGER.debug("MockPlugin.onHelloMessage().run() Hello message received"); HelloInputBuilder hib = new HelloInputBuilder(); hib.setVersion((short) 4); hib.setXid(2L); @@ -127,21 +130,21 @@ public void run() { new Thread(new Runnable() { @Override public void run() { - sendFeaturesReply(); + getSwitchFeatures(); } }).start(); - LOGGER.debug("adapter: "+adapter); } }).start(); + } - protected void sendFeaturesReply() { + protected void getSwitchFeatures() { GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder(); featuresBuilder.setVersion((short) 4); featuresBuilder.setXid(3L); GetFeaturesInput featuresInput = featuresBuilder.build(); try { - LOGGER.debug("Going to send featuresRequest"); + LOGGER.debug("Requesting features "); RpcResult rpcResult = adapter.getFeatures( featuresInput).get(2500, TimeUnit.MILLISECONDS); if (rpcResult.isSuccessful()) { @@ -154,23 +157,21 @@ protected void sendFeaturesReply() { + rpcError.getCause().getMessage(), rpcError.getCause()); } } catch (InterruptedException | ExecutionException | TimeoutException e) { - LOGGER.error(e.getMessage(), e); + LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e); } - LOGGER.debug("After FeaturesReply message"); } protected void shutdown() { - LOGGER.debug("adapter: "+adapter); try { - LOGGER.debug("mockPlugin: "+System.identityHashCode(this)); + LOGGER.debug("MockPlugin.shutdown() sleeping 5... : "+System.identityHashCode(this)); Thread.sleep(500); if (adapter != null) { Future disconnect = adapter.disconnect(); disconnect.get(); - LOGGER.debug("Disconnected"); + LOGGER.debug("MockPlugin.shutdown() Disconnected"); } } catch (Exception e) { - LOGGER.error(e.getMessage(), e); + LOGGER.error("MockPlugin.shutdown() exception caught: ", e.getMessage(), e); } finishedFuture.set(null); } @@ -196,14 +197,13 @@ public void onPacketInMessage(PacketInMessage notification) { @Override public void onPortStatusMessage(PortStatusMessage notification) { - LOGGER.debug("PortStatus message received"); + LOGGER.debug("MockPlugin.onPortStatusMessage() message received"); } @Override public void onDisconnectEvent(DisconnectEvent notification) { - LOGGER.debug("disconnection ocured: "+notification.getInfo()); - LOGGER.debug("adapter: "+adapter); + LOGGER.debug("disconnection occured: "+notification.getInfo()); } /** @@ -215,7 +215,7 @@ public SettableFuture getFinishedFuture() { @Override public void onSwitchIdleEvent(SwitchIdleEvent notification) { - LOGGER.debug("switch status: "+notification.getInfo()); + LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: "+notification.getInfo()); idleCounter ++; } @@ -228,7 +228,7 @@ public int getIdleCounter() { @Override public void onConnectionReady() { - LOGGER.debug("connection ready notification arrived"); + LOGGER.trace("MockPlugin().onConnectionReady()"); } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java new file mode 100644 index 00000000..c1199c1e --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.security.KeyStore; +import java.security.Security; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +/** + * Class for setting up TLS connection. + * + * @author michal.polkorab + */ +public final class ClientSslContextFactory { + + + // "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 CLIENT_CONTEXT; + + static { + String algorithm = Security.getProperty("ssl.KeyManagerFactory.algorithm"); + if (algorithm == null) { + algorithm = "SunX509"; + } + + SSLContext clientContext; + try { + KeyStore ks = KeyStore.getInstance("JKS"); + ks.load(ClientSslKeyStore.asInputStream(), + ClientSslKeyStore.getKeyStorePassword()); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); + kmf.init(ks, ClientSslKeyStore.getCertificatePassword()); + + KeyStore ts = KeyStore.getInstance("JKS"); + ts.load(ClientSslTrustStore.asInputStream(), + ClientSslTrustStore.getKeyStorePassword()); + + TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); + tmf.init(ts); + + clientContext = SSLContext.getInstance(PROTOCOL); + clientContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + } catch (Exception e) { + throw new Error( + "Failed to initialize the client-side SSLContext", e); + } + + CLIENT_CONTEXT = clientContext; + } + + /** + * @return cliencontext + */ + public static SSLContext getClientContext() { + return CLIENT_CONTEXT; + } +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java new file mode 100644 index 00000000..279072fa --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.io.InputStream; + +/** + * Class for storing keys + * + * @author michal.polkorab + */ +public final class ClientSslKeyStore { + + private static final String filename = "/selfSignedSwitch"; + + /** + * InputStream instance of key + * + * @return key as InputStream + */ + public static InputStream asInputStream() { + InputStream in = ClientSslKeyStore.class.getResourceAsStream(filename); + if (in == null) { + throw new IllegalStateException("KeyStore file not found: " + filename); + } + return in; + } + + /** + * @return certificate password as char[] + */ + public static char[] getCertificatePassword() { + return "opendaylight".toCharArray(); + } + + /** + * @return KeyStore password as char[] + */ + public static char[] getKeyStorePassword() { + return "opendaylight".toCharArray(); + } +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java new file mode 100644 index 00000000..1379c8dd --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.io.InputStream; + +/** + * Class for storing keys + * + * @author michal.polkorab + */ +public final class ClientSslTrustStore { + + private static final String filename = "/selfSignedController"; + + /** + * InputStream instance of key + * + * @return key as InputStream + */ + public static InputStream asInputStream() { + InputStream in = ClientSslTrustStore.class.getResourceAsStream(filename); + if (in == null) { + throw new IllegalStateException("KeyStore file not found: " + filename); + } + return in; + } + + /** + * @return certificate password as char[] + */ + public static char[] getCertificatePassword() { + return "opendaylight".toCharArray(); + } + + /** + * @return KeyStore password as char[] + */ + public static char[] getKeyStorePassword() { + return "opendaylight".toCharArray(); + } +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index bd9a911b..d557c49b 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -16,8 +16,6 @@ import javax.net.ssl.SSLEngine; -import org.opendaylight.openflowjava.protocol.impl.core.SslContextFactory; - import com.google.common.util.concurrent.SettableFuture; /** Initializes secured {@link SimpleClient} pipeline @@ -43,7 +41,7 @@ public SimpleClientInitializer(SettableFuture isOnlineFuture, boolean s public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (secured) { - SSLEngine engine = SslContextFactory.getClientContext() + SSLEngine engine = ClientSslContextFactory.getClientContext() .createSSLEngine(); engine.setUseClientMode(true); pipeline.addLast("ssl", new SslHandler(engine)); diff --git a/simple-client/src/main/resources/selfSignedController b/simple-client/src/main/resources/selfSignedController new file mode 100644 index 0000000000000000000000000000000000000000..9f4e421dad53beae6ce49b5354b57be87de93563 GIT binary patch literal 1351 zcmezO_TO6u1_mY|W&~rA;?$h9;>`5C)Rg4>ypp2)oSf7mprl*D`44}9biY9pW48ex z8<#d4BMYMzlOQ7_D+5atW4Yvn%f|g`Cp1&TuWyQzzMQcv^XY+v%}dX%-6&Vdy42}Y zW&Md6=BGC+9-G9G-f{T*-v=}9R>p2pd60GZRFmngy_`j5xr*LNt4#OT)!F5VskSSe zdwe>u_~8G80l5sbjm7epvc_L;@i-Iw+^oUKvF`Kp-8T|FC(dQu?)x$?N}qQz--BbB zp09UpJ!5X-v_RzW*XC;t(I)m87b{L(`qp-Q|KDp@r>L;9zAgZA?x_I z9~(bO`MEFQVIThZiZQ_-Kd;Z$Hmz)N^9l zLmRQG?vR>ZjR%X@$!Tw1Ryr|naXt4hMbo5@zmuvMRjkh}`M7UI;DpW<&G#QhJ)O@s zsXHyMp*mDGh0(|Q-+50h=EfEVrp5*#kEWuH-;QN$_%rE%an3c{^`%DKGD@no-cR2x zX;KoCZg-e-@8r?{{SLNVFH{$#8NIn~*cY&fgDZWf;ntrHj~qBBW^9@D=Bz~iz*@?WHo-ph3UQE;v?Vjnn^Z3&ao!}p~`kPp`aVbeTkog-jGV z=kq^seAlyVjs?S^)VkbSU|_fHyj-E(HaWk5Kkjds!bbBM9(xy7N3467aZAQq?4-8b MR!6VGPUY390E5dNe*gdg literal 0 HcmV?d00001 diff --git a/simple-client/src/main/resources/selfSignedSwitch b/simple-client/src/main/resources/selfSignedSwitch new file mode 100644 index 0000000000000000000000000000000000000000..645ac44243d3a8af51fa012f7879d245d05c1054 GIT binary patch literal 1348 zcmezO_TO6u1_mY|W&~q_;?$h9;>`5C)Rf}#%#!2`poCk&^&f|T^aO(@#vTJcHZE;8 zMixdbCP79z z{vL2FH)cr72==#S)LUgc(PHjlri(wOALuim?f*=E<7+PNT*lcA@mu-6lmw(yh4<-L}h-Y&+z{I!>H?Z#{ZQ!{7(h^Pn5o=`((rK^)eF|8BY8l9%L)92pnUq z5qhQumJAHc$p%f#@jxuQfSHMriHXIvf&YmCHygWFo5wi|7G_okgT@9!ZUas>=1>+k zVWwbjLs0`^5QjsUC%+&yFD0=uCo?^x1SZUmU6>2IFgJE#W>jGVIdNV?69Y2?GebiI zBO`+-FxS$+1j-!@PHbY_0ZiyRuz+I(a^#sB8yWuA2RF)=3TX!2_nM>k=E?JKg4=^^ z-n%dyma}iz7O0l#8tb4G_&d_JH{#d+qhEI!d^66fYKrV-7ByE+kQ;?hjsY#V=I=4^0WMI{&xAO++ilu5aB4XiALW_Kd;kHysq{B zlM=J!+>0KJ$C*SKrY8jSiz;)U*)(Zq)1ucc+#e!jzJi?g{o#VvYqM?do!+xL#%xFU z&dMq4cmJ|_)$}vmhufCDDLpVUyl>Z)NdISr>;jDqTRg=Im0$R1hzV~$&uP?iV%b9* zv8wKnnqG|ui`U6%Z(de9F>i4__b)}$q>sOosu)$Q&n)@4Z$;pQ&K1q~A4WZ$&o-$$ zEv}(DR5gXs$NJxSPc7!gRtAtewrlO0Rieb17@)L6(p79twcpl?#C@I554~EPbX71u zXj7qobZC$7{mwmB+n?xVA1pbf{Ih^p{C3LK>~A|SvX(1(l`mOPwn4?{^H!~D%kwuU zp6UMdurtVJ$FDU{j@`=9tc{kvCOd)GtJS)vX7~U1e-GbY{(AC#)8lfpCs;3g|8BYJ zVnqXa16g32mgQp+V-fki@~qY6YpgvUy*{(v?mKM|ZLgw$k|UV)84ProL@H7mGR;I& zb1vSVr#Pp#c-;qWu?I{dz73Wqi_+Zp9Q~<%o^R5#J)YMMmR^YWQ7f+gl<8W)zE1Om KmC%%2<4FL78zvqA literal 0 HcmV?d00001 From 22cae304498090f983b7affb2ed88ed59ac7e382 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 1 Jul 2014 14:08:47 +0200 Subject: [PATCH 004/285] TLS initialization fix - fixed TlsConfiguration object creation - now null instead of empty object Signed-off-by: Michal Polkorab --- .../impl/rev140328/SwitchConnectionProviderModule.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 45fed553..bf8c600f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -94,6 +94,9 @@ public Object getTransferProtocol() { } @Override public TlsConfiguration getTlsConfiguration() { + if (tlsConfig == null) { + return null; + } return new TlsConfiguration() { @Override public KeystoreType getTlsTruststoreType() { From 2a804aec954ccaaa5f3aa0bb2c22f265fdd8e6b5 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 2 Jul 2014 08:40:36 +0200 Subject: [PATCH 005/285] Extensibility fix - simplified too strict key limitation - MessageTypeKey in SwitchConnectionProvider#registerCustomSerializer was restricted to , which does not allow for use of other objects (such as descendants of BaseIdentity) Signed-off-by: Michal Polkorab --- .../protocol/impl/connection/SwitchConnectionProviderImpl.java | 2 +- .../protocol/spi/connection/SwitchConnectionProvider.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index cd864bd4..92d42626 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -130,7 +130,7 @@ public ServerFacade getServerFacade() { } @Override - public void registerCustomSerializer(MessageTypeKey key, + public void registerCustomSerializer(MessageTypeKey key, OFSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index a61f1033..abcaabac 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -54,7 +54,7 @@ public interface SwitchConnectionProvider extends AutoCloseable { * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerCustomSerializer(MessageTypeKey key, + public void registerCustomSerializer(MessageTypeKey key, OFSerializer serializer); /** From b6a9faf8517f7edbc46df110b601a00b162381ee Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 2 Jul 2014 11:05:59 +0200 Subject: [PATCH 006/285] Bug 1248 - Pyang validation fixed Signed-off-by: Michal Polkorab --- openflow-protocol-api/src/main/yang/openflow-types.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-api/src/main/yang/openflow-types.yang b/openflow-protocol-api/src/main/yang/openflow-types.yang index 669c86f0..47dc4a35 100644 --- a/openflow-protocol-api/src/main/yang/openflow-types.yang +++ b/openflow-protocol-api/src/main/yang/openflow-types.yang @@ -1645,7 +1645,7 @@ position 0; } bit no-stp { - description" Disable 802.1D spanning tree on port."; + description "Disable 802.1D spanning tree on port."; position 1; } bit no-recv { From cefe28e88cede213e06c29736027ecfecc7bb9d8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 1 Jul 2014 14:42:37 +0200 Subject: [PATCH 007/285] Simple client framing fix - fixes problem when 2 or more messages were sent simultaneously Signed-off-by: Michal Polkorab --- .../protocol/impl/clients/SimpleClientFramer.java | 4 ++-- .../protocol/impl/clients/SimpleClientInitializer.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java index 21639668..a1ade557 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java @@ -50,13 +50,13 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) return; } - int length = bb.getUnsignedShort(LENGTH_INDEX_IN_HEADER); + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { LOGGER.debug("skipping bb - too few data for msg: " + bb.readableBytes() + " < " + length); return; } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(1)); + LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index d557c49b..1d74bc0d 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -45,10 +45,10 @@ public void initChannel(SocketChannel ch) throws Exception { .createSSLEngine(); engine.setUseClientMode(true); pipeline.addLast("ssl", new SslHandler(engine)); - pipeline.addLast("framer", new SimpleClientFramer()); } SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler); simpleClientHandler.setScenario(scenarioHandler); + pipeline.addLast("framer", new SimpleClientFramer()); pipeline.addLast("handler", simpleClientHandler); isOnlineFuture = null; From 30d842262665765518551adf69d4cf2f1ff1bb44 Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Wed, 2 Jul 2014 15:36:14 +0200 Subject: [PATCH 008/285] Bug 1277 - Move ByteBuffUtils to separate bundle - bundle project directory created - added dependency on util bundle to openflow-protocol-impl Signed-off-by: Martin Bobak --- openflow-protocol-impl/pom.xml | 5 +++++ pom.xml | 1 + util/pom.xml | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 util/pom.xml diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index daee93f0..ca5eb1e9 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -98,6 +98,11 @@ openflow-protocol-spi ${project.version} + + org.opendaylight.openflowjava + util + ${project.version} + org.opendaylight.controller sal-common-util diff --git a/pom.xml b/pom.xml index 99c9e048..d79caac1 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,7 @@ openflow-protocol-api openflow-protocol-spi + util openflow-protocol-impl openflow-protocol-it feature diff --git a/util/pom.xml b/util/pom.xml new file mode 100644 index 00000000..cca28557 --- /dev/null +++ b/util/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.5-SNAPSHOT + + bundle + util + + + + junit + junit + test + + + From 10b9c3569a636b73a7dcfb88a55864df46455560 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 2 Jul 2014 16:06:40 +0200 Subject: [PATCH 009/285] Updated logging on NotSslRecordException - stackTrace was unnecessarily disruptive Signed-off-by: Michal Polkorab --- .../openflowjava/protocol/impl/core/OFFrameDecoder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index d074e93e..7e623475 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -44,7 +44,12 @@ public OFFrameDecoder(ConnectionFacade connectionFacade) { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOGGER.warn("Unexpected exception from downstream.", cause); + if (cause instanceof io.netty.handler.ssl.NotSslRecordException) { + LOGGER.warn("Not an TLS record exception - please verify TLS configuration."); + } else { + LOGGER.warn("Unexpected exception from downstream.", cause); + } + LOGGER.warn("Closing connection."); ctx.close(); } From c8e3b161e1e10753e53fbf1800bcc6e066e3d3b8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 2 Jul 2014 16:37:32 +0200 Subject: [PATCH 010/285] TLS unit test resources moved from src/main/resources to test/main/resources - TLS unit tests access resources via classpath (not relative path) Signed-off-by: Michal Polkorab --- .../core/PublishingChannelInitializerTest.java | 4 ++-- .../impl/core/SslContextFactoryTest.java | 4 ++-- .../protocol/impl/core/SslKeyStoreTest.java | 15 +++++++++++++-- .../src/{main => test}/resources/key.bin | Bin .../protocol/it/integration/IntegrationTest.java | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) rename openflow-protocol-impl/src/{main => test}/resources/key.bin (100%) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index 55b13552..6666da3d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -91,8 +91,8 @@ public void setUp() throws Exception { when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(true) ; when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ; - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/selfSignedSwitch", PathType.PATH, - KeystoreType.JKS, "src/main/resources/selfSignedController", PathType.PATH); + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, + KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index 2457fd33..2c45c0b0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -35,8 +35,8 @@ public class SslContextFactoryTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "src/main/resources/ctlTrustStore", - PathType.PATH, KeystoreType.JKS, "src/main/resources/ctlKeystore", PathType.PATH) ; + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/ctlTrustStore", + PathType.CLASSPATH, KeystoreType.JKS, "/ctlKeystore", PathType.CLASSPATH) ; sslContextFactory = new SslContextFactory(tlsConfiguration); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java index 7c871bbd..c75fdee9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java @@ -33,12 +33,23 @@ public void setUp() { } /** - * Test keystore file access + * Test keystore file access - via classpath * @throws Exception */ @Test public void testAsInputStream() throws Exception { - InputStream inputStream = SslKeyStore.asInputStream("src/main/resources/key.bin", PathType.PATH); + InputStream inputStream = SslKeyStore.asInputStream("/key.bin", PathType.CLASSPATH); + assertNotNull( inputStream ); + inputStream.close(); + } + + /** + * Test keystore file access - via relative path + * @throws Exception + */ + @Test + public void testAsInputStream2() throws Exception { + InputStream inputStream = SslKeyStore.asInputStream("src/test/resources/key.bin", PathType.PATH); assertNotNull( inputStream ); inputStream.close(); } diff --git a/openflow-protocol-impl/src/main/resources/key.bin b/openflow-protocol-impl/src/test/resources/key.bin similarity index 100% rename from openflow-protocol-impl/src/main/resources/key.bin rename to openflow-protocol-impl/src/test/resources/key.bin diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 8a391dfa..597ac978 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -64,8 +64,8 @@ public void setUp(boolean secured) throws Exception { startupAddress = InetAddress.getLocalHost(); if (secured) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, - "../openflow-protocol-impl/src/main/resources/selfSignedSwitch", PathType.PATH, KeystoreType.JKS, - "../openflow-protocol-impl/src/main/resources/selfSignedController", PathType.PATH) ; + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); } else { connConfig = new ConnectionConfigurationImpl(startupAddress, 0, null, SWITCH_IDLE_TIMEOUT); From 26aeaa7e2754b2cf4f6ad63055ab3ce34f68c961 Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Wed, 2 Jul 2014 15:46:47 +0200 Subject: [PATCH 011/285] Bug 1277 - Move ByteBuffUtils to separate bundle - constants classes moved form openflow-protocol-impl to openflow-protocol-api Signed-off-by: Martin Bobak --- .../openflowjava/protocol/api}/util/EncodeConstants.java | 2 +- .../openflowjava/protocol/api}/util/OxmMatchConstants.java | 2 +- .../openflowjava/protocol/impl/core/OFVersionDetector.java | 2 +- .../impl/deserialization/ActionDeserializerInitializer.java | 2 +- .../DefaultExperimenterDeserializerInitializer.java | 2 +- .../protocol/impl/deserialization/DeserializationFactory.java | 2 +- .../impl/deserialization/DeserializerRegistryImpl.java | 2 +- .../deserialization/InstructionDeserializerInitializer.java | 2 +- .../deserialization/MatchEntryDeserializerInitializer.java | 4 ++-- .../impl/deserialization/MessageDerializerInitializer.java | 2 +- .../impl/deserialization/TypeToClassMapInitializer.java | 2 +- .../deserialization/action/AbstractActionDeserializer.java | 2 +- .../action/AbstractEthertypeActionDeserializer.java | 2 +- .../action/AbstractHeaderActionDeserializer.java | 2 +- .../action/OF10AbstractIpAddressActionDeserializer.java | 2 +- .../action/OF10AbstractMacAddressActionDeserializer.java | 2 +- .../action/OF10AbstractPortActionDeserializer.java | 2 +- .../deserialization/action/OF10EnqueueActionDeserializer.java | 2 +- .../deserialization/action/OF10OutputActionDeserializer.java | 2 +- .../action/OF10SetNwTosActionDeserializer.java | 2 +- .../action/OF10SetVlanPcpActionDeserializer.java | 2 +- .../action/OF10SetVlanVidActionDeserializer.java | 2 +- .../deserialization/action/OF13GroupActionDeserializer.java | 2 +- .../deserialization/action/OF13OutputActionDeserializer.java | 2 +- .../action/OF13SetFieldActionDeserializer.java | 2 +- .../action/OF13SetMplsTtlActionDeserializer.java | 2 +- .../action/OF13SetNwTtlActionDeserializer.java | 2 +- .../action/OF13SetQueueActionDeserializer.java | 2 +- .../experimenters/ExperimenterActionDeserializer.java | 2 +- .../OF13ExperimenterInstructionDeserializer.java | 2 +- .../deserialization/factories/BarrierReplyMessageFactory.java | 2 +- .../deserialization/factories/EchoReplyMessageFactory.java | 2 +- .../deserialization/factories/EchoRequestMessageFactory.java | 2 +- .../impl/deserialization/factories/ErrorMessageFactory.java | 2 +- .../factories/FeaturesReplyMessageFactory.java | 2 +- .../deserialization/factories/FlowRemovedMessageFactory.java | 2 +- .../factories/GetAsyncReplyMessageFactory.java | 2 +- .../factories/GetConfigReplyMessageFactory.java | 2 +- .../impl/deserialization/factories/HelloMessageFactory.java | 2 +- .../factories/MultipartReplyMessageFactory.java | 2 +- .../factories/OF10BarrierReplyMessageFactory.java | 2 +- .../factories/OF10EchoReplyMessageFactory.java | 2 +- .../factories/OF10EchoRequestMessageFactory.java | 2 +- .../deserialization/factories/OF10ErrorMessageFactory.java | 2 +- .../factories/OF10FeaturesReplyMessageFactory.java | 2 +- .../factories/OF10FlowRemovedMessageFactory.java | 2 +- .../factories/OF10GetConfigReplyMessageFactory.java | 2 +- .../deserialization/factories/OF10HelloMessageFactory.java | 2 +- .../deserialization/factories/OF10PacketInMessageFactory.java | 2 +- .../factories/OF10PortStatusMessageFactory.java | 2 +- .../factories/OF10QueueGetConfigReplyMessageFactory.java | 2 +- .../factories/OF10StatsReplyMessageFactory.java | 2 +- .../deserialization/factories/PacketInMessageFactory.java | 2 +- .../deserialization/factories/PortStatusMessageFactory.java | 2 +- .../factories/QueueGetConfigReplyMessageFactory.java | 2 +- .../deserialization/factories/RoleReplyMessageFactory.java | 2 +- .../instruction/AbstractActionInstructionDeserializer.java | 2 +- .../instruction/AbstractInstructionDeserializer.java | 2 +- .../instruction/ClearActionsInstructionDeserializer.java | 2 +- .../instruction/GoToTableInstructionDeserializer.java | 2 +- .../instruction/MeterInstructionDeserializer.java | 2 +- .../instruction/WriteMetadataInstructionDeserializer.java | 2 +- .../match/AbstractOxmIpv4AddressDeserializer.java | 2 +- .../match/AbstractOxmIpv6AddressDeserializer.java | 2 +- .../match/AbstractOxmMacAddressDeserializer.java | 2 +- .../match/AbstractOxmMatchEntryDeserializer.java | 2 +- .../match/AbstractOxmMetadataDeserializer.java | 2 +- .../impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java | 2 +- .../impl/deserialization/match/OxmIpv6FlabelDeserializer.java | 2 +- .../impl/deserialization/match/OxmPbbIsidDeserializer.java | 2 +- .../impl/deserialization/match/OxmVlanVidDeserializer.java | 2 +- .../protocol/impl/serialization/ActionsInitializer.java | 2 +- .../impl/serialization/DefaultExperimenterInitializer.java | 2 +- .../protocol/impl/serialization/MatchEntriesInitializer.java | 2 +- .../impl/serialization/MessageFactoryInitializer.java | 2 +- .../protocol/impl/serialization/SerializerRegistryImpl.java | 2 +- .../serialization/action/OF13SetFieldActionSerializer.java | 2 +- .../experimenters/OF10VendorActionSerializer.java | 2 +- .../experimenters/OF10VendorInputMessageFactory.java | 2 +- .../experimenters/OF13ExperimenterActionSerializer.java | 2 +- .../experimenters/OF13ExperimenterInputMessageFactory.java | 2 +- .../experimenters/OF13ExperimenterInstructionSerializer.java | 2 +- .../experimenters/OF13MeterBandExperimenterSerializer.java | 2 +- .../experimenters/OF13TableFeatExpSerializer.java | 2 +- .../serialization/factories/BarrierInputMessageFactory.java | 2 +- .../impl/serialization/factories/EchoInputMessageFactory.java | 2 +- .../serialization/factories/EchoReplyInputMessageFactory.java | 2 +- .../serialization/factories/FlowModInputMessageFactory.java | 2 +- .../factories/GetAsyncRequestMessageFactory.java | 2 +- .../serialization/factories/GetConfigInputMessageFactory.java | 2 +- .../factories/GetFeaturesInputMessageFactory.java | 2 +- .../factories/GetQueueConfigInputMessageFactory.java | 2 +- .../serialization/factories/GroupModInputMessageFactory.java | 2 +- .../serialization/factories/HelloInputMessageFactory.java | 2 +- .../serialization/factories/MeterModInputMessageFactory.java | 2 +- .../serialization/factories/MultipartRequestInputFactory.java | 2 +- .../factories/OF10BarrierInputMessageFactory.java | 2 +- .../factories/OF10FlowModInputMessageFactory.java | 2 +- .../serialization/factories/OF10HelloInputMessageFactory.java | 2 +- .../factories/OF10PacketOutInputMessageFactory.java | 2 +- .../factories/OF10PortModInputMessageFactory.java | 2 +- .../factories/OF10QueueGetConfigInputMessageFactory.java | 2 +- .../serialization/factories/OF10StatsRequestInputFactory.java | 2 +- .../serialization/factories/PacketOutInputMessageFactory.java | 2 +- .../serialization/factories/PortModInputMessageFactory.java | 2 +- .../factories/RoleRequestInputMessageFactory.java | 2 +- .../serialization/factories/SetAsyncInputMessageFactory.java | 2 +- .../impl/serialization/factories/SetConfigMessageFactory.java | 2 +- .../serialization/factories/TableModInputMessageFactory.java | 2 +- .../instruction/AbstractActionInstructionSerializer.java | 2 +- .../serialization/match/AbstractOxmIpv6AddressSerializer.java | 2 +- .../impl/serialization/match/NxmTcpFlagSerializer.java | 4 ++-- .../impl/serialization/match/NxmTunnelIpv4DstSerializer.java | 4 ++-- .../impl/serialization/match/NxmTunnelIpv4SrcSerializer.java | 4 ++-- .../protocol/impl/serialization/match/OxmArpOpSerializer.java | 4 ++-- .../impl/serialization/match/OxmArpShaSerializer.java | 4 ++-- .../impl/serialization/match/OxmArpSpaSerializer.java | 4 ++-- .../impl/serialization/match/OxmArpThaSerializer.java | 4 ++-- .../impl/serialization/match/OxmArpTpaSerializer.java | 4 ++-- .../impl/serialization/match/OxmEthDstSerializer.java | 4 ++-- .../impl/serialization/match/OxmEthSrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmEthTypeSerializer.java | 4 ++-- .../impl/serialization/match/OxmIcmpv4CodeSerializer.java | 4 ++-- .../impl/serialization/match/OxmIcmpv4TypeSerializer.java | 4 ++-- .../impl/serialization/match/OxmIcmpv6CodeSerializer.java | 4 ++-- .../impl/serialization/match/OxmIcmpv6TypeSerializer.java | 4 ++-- .../impl/serialization/match/OxmInPhyPortSerializer.java | 4 ++-- .../impl/serialization/match/OxmInPortSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpDscpSerializer.java | 4 ++-- .../protocol/impl/serialization/match/OxmIpEcnSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpProtoSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv4DstSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv4SrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6DstSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6ExtHdrSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6FlabelSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6NdSllSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6NdTargetSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6NdTllSerializer.java | 4 ++-- .../impl/serialization/match/OxmIpv6SrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmMetadataSerializer.java | 4 ++-- .../impl/serialization/match/OxmMplsBosSerializer.java | 4 ++-- .../impl/serialization/match/OxmMplsLabelSerializer.java | 4 ++-- .../impl/serialization/match/OxmMplsTcSerializer.java | 4 ++-- .../impl/serialization/match/OxmPbbIsidSerializer.java | 4 ++-- .../impl/serialization/match/OxmSctpDstSerializer.java | 4 ++-- .../impl/serialization/match/OxmSctpSrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmTcpDstSerializer.java | 4 ++-- .../impl/serialization/match/OxmTcpSrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmTunnelIdSerializer.java | 4 ++-- .../impl/serialization/match/OxmUdpDstSerializer.java | 4 ++-- .../impl/serialization/match/OxmUdpSrcSerializer.java | 4 ++-- .../impl/serialization/match/OxmVlanPcpSerializer.java | 4 ++-- .../impl/serialization/match/OxmVlanVidSerializer.java | 4 ++-- .../openflowjava/protocol/impl/util/ByteBufUtils.java | 1 + .../openflowjava/protocol/impl/util/CodeKeyMakerFactory.java | 1 + .../protocol/impl/util/InstructionsInitializer.java | 1 + .../openflowjava/protocol/impl/util/MatchDeserializer.java | 1 + .../protocol/impl/util/OF10MatchDeserializer.java | 1 + .../openflowjava/protocol/impl/util/OF13MatchSerializer.java | 1 + .../factories/BarrierReplyMessageFactoryTest.java | 2 +- .../factories/EchoReplyMessageFactoryTest.java | 2 +- .../factories/EchoRequestMessageFactoryTest.java | 2 +- .../deserialization/factories/ErrorMessageFactoryTest.java | 2 +- .../factories/FeaturesReplyMessageFactoryTest.java | 2 +- .../factories/FlowRemovedMessageFactoryTest.java | 2 +- .../factories/GetAsyncReplyMessageFactoryTest.java | 2 +- .../factories/GetConfigReplyMessageFactoryTest.java | 2 +- .../deserialization/factories/HelloMessageFactoryTest.java | 2 +- .../factories/MultipartReplyMessageFactoryTest.java | 2 +- .../factories/OF10BarrierReplyMessageFactoryTest.java | 3 +-- .../factories/OF10EchoReplyMessageFactoryTest.java | 3 +-- .../factories/OF10EchoRequestMessageFactoryTest.java | 2 +- .../factories/OF10ErrorMessageFactoryTest.java | 2 +- .../factories/OF10FeaturesReplyMessageFactoryTest.java | 2 +- .../factories/OF10FlowRemovedMessageFactoryTest.java | 2 +- .../factories/OF10GetConfigReplyMessageFactoryTest.java | 3 +-- .../factories/OF10HelloMessageFactoryTest.java | 2 +- .../factories/OF10PacketInMessageFactoryTest.java | 2 +- .../factories/OF10PortStatusMessageFactoryTest.java | 2 +- .../factories/OF10QueueGetConfigReplyMessageFactoryTest.java | 2 +- .../factories/OF10StatsReplyMessageFactoryTest.java | 2 +- .../deserialization/factories/PacketInMessageFactoryTest.java | 2 +- .../factories/PortStatusMessageFactoryTest.java | 2 +- .../factories/QueueGetConfigReplyMessageFactoryMultiTest.java | 2 +- .../factories/QueueGetConfigReplyMessageFactoryTest.java | 2 +- .../factories/RoleReplyMessageFactoryTest.java | 2 +- .../factories/BarrierInputMessageFactoryTest.java | 2 +- .../serialization/factories/EchoInputMessageFactoryTest.java | 2 +- .../factories/EchoReplyInputMessageFactoryTest.java | 2 +- .../factories/FlowModInputMessageFactoryTest.java | 2 +- .../factories/GetConfigInputMessageFactoryTest.java | 2 +- .../factories/GetFeaturesInputMessageFactoryTest.java | 2 +- .../factories/GetQueueConfigInputMessageFactoryTest.java | 2 +- .../factories/GetaAsyncRequestMessageFactoryTest.java | 2 +- .../factories/GroupModInputMessageFactoryTest.java | 2 +- .../serialization/factories/HelloInputMessageFactoryTest.java | 2 +- .../factories/MeterModInputMessageFactoryTest.java | 2 +- .../factories/MultipartRequestInputFactoryTest.java | 2 +- .../factories/OF10BarrierInputMessageFactoryTest.java | 2 +- .../factories/OF10FlowModInputMessageFactoryTest.java | 2 +- .../factories/OF10HelloInputMessageFactoryTest.java | 2 +- .../factories/OF10PacketOutInputMessageFactoryTest.java | 2 +- .../factories/OF10PortModInputMessageFactoryTest.java | 2 +- .../factories/OF10QueueGetConfigInputMessageFactoryTest.java | 2 +- .../factories/OF10StatsRequestInputFactoryTest.java | 2 +- .../factories/OF10VendorInputMessageFactoryTest.java | 2 +- .../factories/OF13ExperimenterInputMessageFactoryTest.java | 2 +- .../factories/PacketOutInputMessageFactoryTest.java | 2 +- .../factories/PortModInputMessageFactoryTest.java | 2 +- .../factories/RoleRequestInputMessageFactoryTest.java | 2 +- .../factories/SetAsyncInputMessageFactoryTest.java | 2 +- .../serialization/factories/SetConfigMessageFactoryTest.java | 2 +- .../factories/TableModInputMessageFactoryTest.java | 2 +- .../serialization/factories/multipart/TableFeaturesTest.java | 2 +- .../protocol/impl/util/ActionsDeserializerTest.java | 1 + .../openflowjava/protocol/impl/util/BufferHelper.java | 1 + .../protocol/impl/util/InstructionsDeserializerTest.java | 1 + .../protocol/impl/util/MatchDeserializerTest.java | 1 + .../protocol/impl/util/OF10ActionsDeserializerTest.java | 1 + .../protocol/impl/util/OF10ActionsSerializerTest.java | 1 + .../protocol/impl/util/OF10MatchDeserializerTest.java | 1 + .../protocol/impl/util/OF10MatchSerializerTest.java | 1 + .../protocol/impl/util/OF13ActionsSerializerTest.java | 1 + .../protocol/impl/util/OF13InstructionsSerializerTest.java | 1 + .../protocol/impl/util/OF13MatchSerializerTest.java | 1 + .../protocol/impl/util/OF13MatchSerializerTest2.java | 1 + 227 files changed, 271 insertions(+), 256 deletions(-) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl => openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api}/util/EncodeConstants.java (97%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl => openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api}/util/OxmMatchConstants.java (95%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java similarity index 97% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EncodeConstants.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index 711152f9..b3f6dff5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.protocol.api.util; /** * Stores common constants diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java similarity index 95% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OxmMatchConstants.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 94fbc2b3..499e95c5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.protocol.api.util; /** * Stores oxm_match constants diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 2160a85e..78734fc4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -14,7 +14,7 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index a1ed6198..7c1d110b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -37,7 +37,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java index 7e3a156c..44115fad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index afc01f62..f459c97f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 8808569f..34d2534c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java index e6009150..9a83ec49 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index e29504f3..fe15b917 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -51,9 +51,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java index 29ef0f56..25e896e4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java @@ -34,7 +34,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 6e193e24..017e2454 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -9,7 +9,7 @@ import java.util.Map; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java index a5b17631..4ff7c307 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java index db859179..0fae6a61 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java index a04453ee..b295ec3c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java index 6190e912..39d3b55d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java index e2a7095a..3013c880 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java index 9819f860..c284fc5e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index b9286e10..41c989eb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index 25e1b2bb..cfbcbe27 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index bdb9510d..70589117 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index f46779d9..cb888a4c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index b422d881..4fb33a73 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index aa8803fe..ab186fa8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index 90cf6690..e47980f4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index aba3e785..91e55721 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index b70d8309..15877640 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index f3f119ef..a9a08aa6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index 0ac46715..0e68c0b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java index 9a851a1b..316d970f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java index 8cc06920..ab14cf66 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java index 7ac99c4f..4c109ca6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java index 5aca519f..8c8ba389 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java index 6d2b767e..6e1e5597 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index c3fdf8ba..5a049c51 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java index ad08dc12..d7991eb9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java @@ -13,7 +13,7 @@ import java.math.BigInteger; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java index bfe552b9..86a2d085 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java index c6156a0b..d565fa63 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java index 5d193161..dc6e11a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java index f721ad12..b596cd92 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 1ff7ee5d..1e8ffcec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java index 68ddd120..59122817 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java index a6b0bd1d..ec45475e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java index cd83b039..a63c255d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java index d5b8a7fe..dda0fd36 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCodeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadRequestCodeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorTypeV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index dc61607b..851bc421 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java index 32e09c4f..e048092d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java index 5e54892c..4c247c6a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactory.java index a71dddbc..51a18867 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java index 8302fa37..3de0288b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java index 3d0489a8..a674387b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java index 1dcad3fd..51f058d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 4cf0b1d6..d0b3f500 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java index 4d8a44af..808a1da9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index 80c6d27c..2ffc23c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java index ecdbfa37..26110ec4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java index eaee8f38..f42bd84d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactory.java @@ -13,7 +13,7 @@ import java.math.BigInteger; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 224b3a68..3f4126ba 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java index ff6da009..f15409f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index 7cb26fdf..cc2ef5e8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -13,7 +13,7 @@ import java.util.ArrayList; import java.util.List; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index d3ed8651..21af10fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java index 074fff47..ebd626d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index 2dce4110..e92260e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java index 63085cb3..aab30e20 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java @@ -11,7 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java index 2afce0b8..a1850ee3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java @@ -11,7 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java index 58b431bf..e9154e24 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java @@ -11,7 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index 99c0f8cd..62c7a507 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java index abf757f8..d38b82ed 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index eb8b6d73..c14e69c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index 3b96a6fe..50e51b42 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java index 1dfdd711..2cc2ed45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index e5156fe9..6e7de9b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index 789f0b6b..753c745a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -36,7 +36,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java index 32850a27..5aaa458e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13MultipartExperimenterSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13TableFeatExpSerializer; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 348487e0..2c7f814f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -51,7 +51,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 68fd0977..452a8c16 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -34,7 +34,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 3e36addc..4336015b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionsInitializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 070424c2..93539a83 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java index 4fac1b29..db950929 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java index 35fe2f48..afb0cc97 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java index dd2d4c3d..a2f320f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java index 34530357..5403da50 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInstructionSerializer.java index d1e0df87..ec0d5662 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInstructionSerializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MeterBandExperimenterSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MeterBandExperimenterSerializer.java index bede2a00..3845686b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MeterBandExperimenterSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MeterBandExperimenterSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; public class OF13MeterBandExperimenterSerializer diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java index 78307263..8a619d6e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java index e10249a2..e7b18569 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java index 06ba0620..e85a684a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java index 5273a7b9..8d155ba7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index e4b448a9..97b9808c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java index 3dfd5dcc..3f382877 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java index 3867e33c..e045dc0d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java index b04997d2..d56df56a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java index f154125d..b0586145 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java index 925e78da..99f578c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java index b2918dcd..747279d1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java index 4ef9c44f..dfe441ad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index b8061a6b..c7424405 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java index 3a3e7eae..403f10ca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index 14f2f490..b8d71256 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java index 47f84b54..a2fa2a6c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java index 68b54dd9..e663aca8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java index 7f452bb2..28b2a116 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java index 34e6b85b..03bb1e99 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 397e48c5..881bc1a6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java index daea2ac5..73b6376b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index ba271d6a..c3042ddb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java index 8f8c82e7..24bb5de6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java index b903e83b..78ce560c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java index a1407a01..e4e12cfa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java index d7cb6a56..9efaa1e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 5e4489f5..cd74c988 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index 61cea69d..27464650 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java index aec49f0e..d59e16f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.slf4j.Logger; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java index a2f4e227..05b98809 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author brent.salisbury diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java index 7cebc5a3..19bd4a60 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author brent.salisbury diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java index 84aefe11..4520d9c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java index 4198f96f..8836d0ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java index d51adb70..bad5995f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java index 83e67c9f..637ca043 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java index b0af9891..25e6417f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java index 12b2bcf4..8ac6b9d6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java index b4995d61..74d75304 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java index da60d720..70bf999a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java index 901be666..82722fc5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java index b391ef1d..a5f367fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java index 4e267cbb..303b116e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java index 09a943d1..feafa962 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java index 541ba0f6..2aba7e8c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java index f8096219..2c955077 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java index eacaf491..dc1ba5ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java index 193e3f71..65bea297 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java index 7a99f7b6..7193f504 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java index b8a53b9b..df717c18 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java index 494a6fa4..2c92d022 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java index 5111b832..4d6299ef 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java index 9d04d581..d7d26172 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java @@ -10,8 +10,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java index 4805b264..1e049929 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java index 66cb9f4e..fed6402f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java index a9cd13e4..9037ee6f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java index 3e4d0579..c0864da9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java index 0b70ffc6..7057fe30 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java index 3a009f2f..6b0e27de 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java index 8685c464..12f2ec63 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java index 3c5de383..c27936a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java index 4e3af758..7a80f40e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java index 0d5db302..ca740dd5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java index 6fd507ab..9327b566 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java index 82703f69..1d50c383 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java index 0933cdb6..22b5093a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java index 8a808618..e7bcfd6e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java index ac9a5de9..033f7f79 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java index 73979972..5f110390 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java index 96022e67..2e091b44 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java index 4f4fca28..ba181fa0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java index 6afa1592..775b91a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java index 59439662..e7420e35 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Map.Entry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 941140a0..26abb180 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -12,6 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java index 43bc4639..11ac7f56 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ApplyActionsInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java index e33a1c48..09cc3119 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java @@ -15,6 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index 4e510df9..0f449395 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -11,6 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index 7c3d61c0..73826923 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java index 8bc381a8..863ac336 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java index ae184295..abd1d1d5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java index 7b6a6305..04fa4ddb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java index 5df6b771..5e114778 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java index c12a4ec6..233c7e38 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java index cc5709d1..22b7df56 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java index 8cc9f8cd..6dd6558d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java index 13bbb2a8..e30fb02c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index d8bd93ee..0be6bb94 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index bfa70044..d246bdc8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java index 2d7ee042..368f8f03 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java @@ -16,9 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java index cdfd644f..92197425 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java @@ -17,9 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java index efcd8aff..96fd0335 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java index 68a49b2c..98be668f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index 25ce7690..4330e32d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java index fc99ebb3..891c9e05 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java index 727ea082..c0d795a6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java @@ -17,9 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java index 0015f3fd..2438f17c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java index aac06253..502d4ffa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java index 42458413..759b0b66 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java index 0e9b7f53..e204b3ca 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 267430b7..4b06bab1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java index 21889a08..7fbf5130 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index 647fd9e2..b538e856 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java index c87f0143..1125ca2d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java index 6e9099d3..ab4ef3a6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java index 70795848..e41e53b6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java index c7d21f6a..9584bf62 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java index 158557b7..25bc0ff7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java index 8107fb68..40aa9a0d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index 844dcddc..3c5ba034 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java index 31d5247f..bf5a3c36 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java index 644dc352..62ab4bf1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java index 924702e1..0c7b2911 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java index 594246e1..5cc956ac 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java index ba129d3f..dcb543fc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index 3a299a63..db9fb3d1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index f7f72518..11068f3f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java index 955ba4e9..4227330b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java index f1a70c8e..4ddb02cc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 7a3effc8..3a3f3276 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java index 4de13d31..c4807192 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 31388928..7af7384d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index 9a71288b..56004dad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java index 29f9c7b0..cc2a7576 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index a576c20e..86ba6024 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java index 45c0e00e..022b3349 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF10VendorInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java index 84f55591..362f95ac 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 89f4e31a..e7a438df 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index 332a5c4f..adecf3cb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java index a07715c6..981a8901 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index 9a50f326..02ac426c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java index d6c2725b..bd41db6e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java index 8fde1ce8..823ed686 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java index 084c3d6c..77ecc214 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java @@ -25,7 +25,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index 440a57d7..06fbe466 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -15,6 +15,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index 8a40cf2a..5ce9196a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -16,6 +16,7 @@ import org.junit.Assert; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 1d7231d0..e6de7eae 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -15,6 +15,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index d4cdc802..5e79c5d1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -18,6 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 9da47629..5e304dc9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -15,6 +15,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index b1cd11bb..bb793091 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -17,6 +17,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 55e129e6..262be94b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index a225db30..cb686194 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index 0e14df0b..b450ccdc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -17,6 +17,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 329559de..eb7c78dc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -17,6 +17,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 746bb625..f4970001 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -20,6 +20,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java index 35ec8e5b..e7f1e8d3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java @@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; From 37cf2e565f6ec0f86f65b35898091fcf279753a5 Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Wed, 2 Jul 2014 16:04:11 +0200 Subject: [PATCH 012/285] Bug 1277 - Move ByteBuffUtils to separate bundle - ByteBufUtils moved to bundle utils Signed-off-by: Martin Bobak --- .../openflowjava/protocol/impl/core/OFDecoder.java | 2 +- .../openflowjava/protocol/impl/core/OFFrameDecoder.java | 2 +- .../action/OF10AbstractIpAddressActionDeserializer.java | 2 +- .../action/OF10AbstractMacAddressActionDeserializer.java | 2 +- .../factories/MultipartReplyMessageFactory.java | 2 +- .../factories/OF10FeaturesReplyMessageFactory.java | 2 +- .../factories/OF10PortStatusMessageFactory.java | 2 +- .../factories/OF10StatsReplyMessageFactory.java | 2 +- .../deserialization/factories/PortStatusMessageFactory.java | 2 +- .../match/AbstractOxmIpv4AddressDeserializer.java | 2 +- .../match/AbstractOxmIpv6AddressDeserializer.java | 2 +- .../match/AbstractOxmMacAddressDeserializer.java | 2 +- .../action/AbstractEthertypeActionSerializer.java | 2 +- .../serialization/action/AbstractHeaderActionSerializer.java | 2 +- .../action/OF10AbstractIpAddressActionSerializer.java | 2 +- .../action/OF10AbstractMacAddressActionSerializer.java | 2 +- .../action/OF10AbstractPortActionSerializer.java | 2 +- .../serialization/action/OF10EnqueueActionSerializer.java | 2 +- .../serialization/action/OF10SetNwTosActionSerializer.java | 2 +- .../serialization/action/OF10SetVlanPcpActionSerializer.java | 2 +- .../serialization/action/OF10SetVlanVidActionSerializer.java | 2 +- .../serialization/action/OF13OutputActionSerializer.java | 2 +- .../serialization/action/OF13SetFieldActionSerializer.java | 2 +- .../serialization/action/OF13SetMplsTtlActionSerializer.java | 2 +- .../serialization/action/OF13SetNwTtlActionSerializer.java | 2 +- .../experimenters/OF10VendorInputMessageFactory.java | 2 +- .../experimenters/OF13ExperimenterInputMessageFactory.java | 2 +- .../experimenters/OF13TableFeatExpSerializer.java | 2 +- .../serialization/factories/BarrierInputMessageFactory.java | 2 +- .../serialization/factories/EchoInputMessageFactory.java | 2 +- .../factories/EchoReplyInputMessageFactory.java | 2 +- .../serialization/factories/FlowModInputMessageFactory.java | 2 +- .../factories/GetAsyncRequestMessageFactory.java | 2 +- .../factories/GetConfigInputMessageFactory.java | 2 +- .../factories/GetFeaturesInputMessageFactory.java | 2 +- .../factories/GetQueueConfigInputMessageFactory.java | 2 +- .../serialization/factories/GroupModInputMessageFactory.java | 2 +- .../serialization/factories/HelloInputMessageFactory.java | 2 +- .../serialization/factories/MeterModInputMessageFactory.java | 2 +- .../factories/MultipartRequestInputFactory.java | 2 +- .../factories/OF10BarrierInputMessageFactory.java | 2 +- .../factories/OF10FlowModInputMessageFactory.java | 2 +- .../factories/OF10HelloInputMessageFactory.java | 2 +- .../factories/OF10PacketOutInputMessageFactory.java | 2 +- .../factories/OF10PortModInputMessageFactory.java | 2 +- .../factories/OF10QueueGetConfigInputMessageFactory.java | 2 +- .../factories/OF10StatsRequestInputFactory.java | 2 +- .../factories/PacketOutInputMessageFactory.java | 2 +- .../serialization/factories/PortModInputMessageFactory.java | 2 +- .../factories/RoleRequestInputMessageFactory.java | 2 +- .../serialization/factories/SetAsyncInputMessageFactory.java | 2 +- .../serialization/factories/SetConfigMessageFactory.java | 2 +- .../serialization/factories/TableModInputMessageFactory.java | 2 +- .../instruction/AbstractActionInstructionSerializer.java | 2 +- .../instruction/GoToTableInstructionSerializer.java | 2 +- .../instruction/WriteMetadataInstructionSerializer.java | 2 +- .../match/AbstractOxmIpv4AddressSerializer.java | 2 +- .../match/AbstractOxmIpv6AddressSerializer.java | 2 +- .../serialization/match/AbstractOxmMacAddressSerializer.java | 2 +- .../impl/serialization/match/OxmIpv6ExtHdrSerializer.java | 2 +- .../protocol/impl/util/OF10MatchDeserializer.java | 1 + .../openflowjava/protocol/impl/util/OF10MatchSerializer.java | 1 + .../openflowjava/protocol/impl/util/OF13MatchSerializer.java | 1 + .../openflowjava/protocol/impl/core/OFDecoderTest.java | 2 +- .../openflowjava/protocol/impl/core/OFFrameDecoderTest.java | 2 +- .../protocol/impl/core/OFVersionDetectorTest.java | 2 +- .../factories/MultipartReplyMessageFactoryTest.java | 2 +- .../factories/OF10PacketInMessageFactoryTest.java | 2 +- .../factories/OF10StatsReplyMessageFactoryTest.java | 2 +- .../factories/PacketInMessageFactoryTest.java | 2 +- .../factories/HelloInputMessageFactoryTest.java | 2 +- .../factories/OF10FlowModInputMessageFactoryTest.java | 2 +- .../factories/OF10PacketOutInputMessageFactoryTest.java | 2 +- .../factories/OF10PortModInputMessageFactoryTest.java | 2 +- .../factories/OF10StatsRequestInputFactoryTest.java | 2 +- .../factories/PacketOutInputMessageFactoryTest.java | 2 +- .../factories/PortModInputMessageFactoryTest.java | 2 +- .../factories/SetAsyncInputMessageFactoryTest.java | 2 +- .../serialization/factories/multipart/TableFeaturesTest.java | 2 +- .../openflowjava/protocol/impl/util/BufferHelper.java | 1 + .../protocol/impl/util/InstructionsDeserializerTest.java | 1 + .../protocol/impl/util/MatchDeserializerTest.java | 1 + .../protocol/impl/util/OF10ActionsDeserializerTest.java | 3 ++- .../protocol/impl/util/OF10ActionsSerializerTest.java | 1 + .../protocol/impl/util/OF10MatchSerializerTest.java | 1 + .../protocol/impl/util/OF13InstructionsSerializerTest.java | 1 + .../protocol/impl/util/OF13MatchSerializerTest.java | 3 ++- .../protocol/it/integration/IntegrationTest.java | 2 +- .../openflowjava/protocol/impl/clients/ScenarioFactory.java | 2 +- .../openflowjava/protocol/impl/clients/SendEvent.java | 2 +- .../protocol/impl/clients/SimpleClientHandler.java | 2 +- .../protocol/impl/clients/WaitForMessageEvent.java | 2 +- util/pom.xml | 5 +++++ .../org/opendaylight/openflowjava}/util/ByteBufUtils.java | 2 +- .../opendaylight/openflowjava}/util/ByteBufUtilsTest.java | 5 +++-- 95 files changed, 103 insertions(+), 86 deletions(-) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl => util/src/main/java/org/opendaylight/openflowjava}/util/ByteBufUtils.java (99%) rename {openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl => util/src/test/java/org/opendaylight/openflowjava}/util/ByteBufUtilsTest.java (97%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index ee578046..b4f739b5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -14,7 +14,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index d074e93e..cff68f8f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -16,7 +16,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java index 39d3b55d..058d0870 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java index 3013c880..14a1c843 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 1e8ffcec..cf3e2d74 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index 851bc421..2d3cc782 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -15,7 +15,7 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java index a674387b..e7036ed8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index d0b3f500..94885a50 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index 2ffc23c2..e204d762 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java index aab30e20..9d7329fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java index a1850ee3..d6c4d2b1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java index e9154e24..32383b2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java index fe89f769..7af91fd6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java index 98431396..b9614676 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java index 5006a269..d7bf73aa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java index f1261f35..e3cb27e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java index bf857e95..fee943a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index b7f7f867..8c55a732 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index 65a5b77e..cedae208 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 3d73de9d..59cddfa3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index ca1f8dcd..11df22f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index c9d39d44..19acf948 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 93539a83..a2814310 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index ea53482e..495c6bc1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index d86f407f..02c01157 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java index afb0cc97..2a9cfb66 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java index 5403da50..58b2b68e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java index 8a619d6e..2c4f49f1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java index e7b18569..157dcc9a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java index e85a684a..23c0c031 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java index 8d155ba7..8b9bf8ae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 97b9808c..3bfe885e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java index 3f382877..dd6c922f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncRequestMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java index e045dc0d..2686abc8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java index d56df56a..515bb8a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java index b0586145..f107ccd9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java index 99f578c4..300e0200 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java index 747279d1..26af4530 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java index dfe441ad..50f59677 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index c7424405..7aaeb74d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java index 403f10ca..cb1fce88 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index b8d71256..ba8498ef 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java index a2fa2a6c..73a7b81c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java index e663aca8..f217e100 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java index 28b2a116..d21838cc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java index 03bb1e99..bbdd122c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 881bc1a6..a64268da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java index 73b6376b..e4c56a0d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index c3042ddb..72b0d8bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -14,7 +14,7 @@ import java.util.Map; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java index 24bb5de6..43ec60cd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java index 78ce560c..44a089d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java @@ -15,7 +15,7 @@ import java.util.Map; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java index e4e12cfa..84c69ab8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java index 9efaa1e5..dac909e6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactory.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index cd74c988..b2667611 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 57ae954f..2ab3a517 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 3725e040..79e0725d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index 9972c154..1d1907af 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -9,7 +9,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index 27464650..63b6f42e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -13,7 +13,7 @@ import java.util.Arrays; import java.util.List; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index 94df9f08..847a0409 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -9,7 +9,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java index d7d26172..4852a4fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java @@ -9,7 +9,7 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index 0f449395..93ff402d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -12,6 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index 5c12399a..813b6084 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -11,6 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index 73826923..e2196daf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java index 8337b792..27a1bff4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java @@ -24,7 +24,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java index 786a0d88..658b487d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java @@ -23,7 +23,7 @@ import org.mockito.MockitoAnnotations; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; /** * Testing class of {@link OFFrameDecoder} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java index 0f1d87d0..1a3a3244 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java @@ -21,7 +21,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; /** * diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index d246bdc8..94d2a956 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java index 502d4ffa..a632ba45 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 4b06bab1..54cdd2ca 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java index 7fbf5130..a154ad4b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index db9fb3d1..f971c026 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 3a3f3276..24449825 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 7af7384d..99d06a75 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index 56004dad..d03f7983 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 86ba6024..737acecc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index e7a438df..394e70c2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index adecf3cb..8b5f8bfa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index 02ac426c..0b890765 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java index 77ecc214..12cb7244 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java @@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index 5ce9196a..6a857639 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -17,6 +17,7 @@ import org.junit.Assert; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index e6de7eae..112437b5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 5e79c5d1..422113fa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -20,6 +20,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 5e304dc9..100f38c0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; @@ -91,7 +92,7 @@ public void test() { Action action5 = actions.get(4); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); - Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), + Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); Action action6 = actions.get(5); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index bb793091..eba0d98b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index cb686194..c6f566cb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index eb7c78dc..8fbe8b36 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index f4970001..17bc3267 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; @@ -257,7 +258,7 @@ public void testIpv6Flabel() { byte[] label = new byte[4]; out.readBytes(label); - LOG.debug("label: "+ByteBufUtils.bytesToHexString(label)); + LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label); } diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 8a391dfa..16ee112a 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -28,7 +28,7 @@ import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.slf4j.Logger; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 71d03968..318d7226 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -10,7 +10,7 @@ import java.util.Stack; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; /** * Class for providing prepared handshake scenario diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index bd664b80..5df57844 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java index 6e3540dd..1c888067 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java @@ -13,7 +13,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index b4b80cfb..42ef75ab 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -10,7 +10,7 @@ import java.util.Arrays; -import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/util/pom.xml b/util/pom.xml index cca28557..98c4038f 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -16,5 +16,10 @@ junit test + + org.opendaylight.openflowjava + openflow-protocol-api + ${project.version} + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java similarity index 99% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java rename to util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index e7420e35..f03f1963 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.util; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtilsTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java similarity index 97% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtilsTest.java rename to util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 990f072f..e9c2d0c1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ByteBufUtilsTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.util; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; @@ -18,6 +18,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.util.ByteBufUtils; /** * @author michal.polkorab @@ -28,7 +29,7 @@ public class ByteBufUtilsTest { private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff}; /** - * Test of {@link ByteBufUtils#hexStringToBytes(String)} + * Test of {@link org.opendaylight.openflowjava.util.ByteBufUtils#hexStringToBytes(String)} */ @Test public void testHexStringToBytes() { From 3129a6f302a62f549ff2dd21b987e28bab686d5e Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 1 Jul 2014 10:38:24 +0200 Subject: [PATCH 013/285] TLS support - configurable passwords - this change allows usage of arbitrary passwords (for keystore, certificate, truststore) instead of hardcoded "opendaylight" password Signed-off-by: Michal Polkorab --- .../api/connection/TlsConfiguration.java | 19 ++++++++++-- .../api/connection/TlsConfigurationImpl.java | 17 ++++++++++- .../protocol/impl/core/SslContextFactory.java | 30 ++++++------------- .../protocol/impl/core/SslKeyStore.java | 14 --------- .../SwitchConnectionProviderModule.java | 12 ++++++++ ...nflow-switch-connection-provider-impl.yang | 16 ++++++++-- .../protocol/impl/core/SslKeyStoreTest.java | 23 +------------- 7 files changed, 69 insertions(+), 62 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index 54298294..00e1a410 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -39,12 +39,27 @@ public interface TlsConfiguration { public KeystoreType getTlsTruststoreType(); /** - * @return keystore path type (classpath or path) + * @return keystore path type (CLASSPATH or PATH) */ public PathType getTlsKeystorePathType(); /** - * @return truststore path type (classpath or path) + * @return truststore path type (CLASSPATH or PATH) */ public PathType getTlsTruststorePathType(); + + /** + * @return password protecting specified keystore + */ + public String getKeystorePassword(); + + /** + * @return password protecting certificate + */ + public String getCertificatePassword(); + + /** + * @return password protecting specified truststore + */ + public String getTruststorePassword(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java index d0bafdd4..4d6fa87d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java @@ -12,8 +12,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; /** + * Class is used only for testing purposes - passwords are hardcoded * @author michal.polkorab - * */ public class TlsConfigurationImpl implements TlsConfiguration { @@ -73,4 +73,19 @@ public PathType getTlsKeystorePathType() { public PathType getTlsTruststorePathType() { return truststorePathType; } + + @Override + public String getKeystorePassword() { + return "opendaylight"; + } + + @Override + public String getCertificatePassword() { + return "opendaylight"; + } + + @Override + public String getTruststorePassword() { + return "opendaylight"; + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java index 8deb4aa0..965cab3d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java @@ -19,8 +19,6 @@ import javax.net.ssl.TrustManagerFactory; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,12 +32,7 @@ public 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 String keystore; - private KeystoreType keystoreType; - private String truststore; - private KeystoreType truststoreType; - private PathType keystorePathType; - private PathType truststorePathType; + private TlsConfiguration tlsConfig; private static final Logger LOGGER = LoggerFactory .getLogger(SslContextFactory.class); @@ -50,12 +43,7 @@ public class SslContextFactory { * keystore types */ public SslContextFactory(TlsConfiguration tlsConfig) { - keystore = tlsConfig.getTlsKeystore(); - keystoreType = tlsConfig.getTlsKeystoreType(); - keystorePathType = tlsConfig.getTlsKeystorePathType(); - truststore = tlsConfig.getTlsTruststore(); - truststoreType = tlsConfig.getTlsTruststoreType(); - truststorePathType = tlsConfig.getTlsTruststorePathType(); + this.tlsConfig = tlsConfig; } /** @@ -69,15 +57,15 @@ public SSLContext getServerContext() { } SSLContext serverContext = null; try { - KeyStore ks = KeyStore.getInstance(keystoreType.name()); - ks.load(SslKeyStore.asInputStream(keystore, keystorePathType), - SslKeyStore.getKeyStorePassword()); + KeyStore ks = KeyStore.getInstance(tlsConfig.getTlsKeystoreType().name()); + ks.load(SslKeyStore.asInputStream(tlsConfig.getTlsKeystore(), tlsConfig.getTlsKeystorePathType()), + tlsConfig.getKeystorePassword().toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); - kmf.init(ks, SslKeyStore.getCertificatePassword()); + kmf.init(ks, tlsConfig.getCertificatePassword().toCharArray()); - KeyStore ts = KeyStore.getInstance(truststoreType.name()); - ts.load(SslKeyStore.asInputStream(truststore, truststorePathType), - SslKeyStore.getKeyStorePassword()); + KeyStore ts = KeyStore.getInstance(tlsConfig.getTlsTruststoreType().name()); + ts.load(SslKeyStore.asInputStream(tlsConfig.getTlsTruststore(), tlsConfig.getTlsTruststorePathType()), + tlsConfig.getTruststorePassword().toCharArray()); TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); tmf.init(ts); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java index b5fdab1a..25c2e0b2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java @@ -59,18 +59,4 @@ public static InputStream asInputStream(String filename, PathType pathType) { } return in; } - - /** - * @return certificate password as char[] - */ - public static char[] getCertificatePassword() { - return "opendaylight".toCharArray(); - } - - /** - * @return KeyStore password as char[] - */ - public static char[] getKeyStorePassword() { - return "opendaylight".toCharArray(); - } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index bf8c600f..04d16aab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -122,6 +122,18 @@ public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.P public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() { return Objects.firstNonNull(tlsConfig.getTruststorePathType(), null); } + @Override + public String getKeystorePassword() { + return Objects.firstNonNull(tlsConfig.getKeystorePassword(), null); + } + @Override + public String getCertificatePassword() { + return Objects.firstNonNull(tlsConfig.getCertificatePassword(), null); + } + @Override + public String getTruststorePassword() { + return Objects.firstNonNull(tlsConfig.getTruststorePassword(), null); + } }; } @Override diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index 0abc830a..fe19560c 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -51,9 +51,17 @@ module openflow-switch-connection-provider-impl { type of-config:keystore-type; } leaf keystore-path-type { - description "keystore path type (classpath or path)"; + description "keystore path type (CLASSPATH or PATH)"; type of-config:path-type; } + leaf keystore-password { + description "password protecting keystore"; + type string; + } + leaf certificate-password { + description "password protecting certificate"; + type string; + } leaf truststore { description "truststore location"; type string; @@ -63,9 +71,13 @@ module openflow-switch-connection-provider-impl { type of-config:keystore-type; } leaf truststore-path-type { - description "truststore path type (classpath or path)"; + description "truststore path type (CLASSPATH or PATH)"; type of-config:path-type; } + leaf truststore-password { + description "password protecting truststore"; + type string; + } } } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java index c75fdee9..ca6826f0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.core; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.io.InputStream; @@ -53,24 +52,4 @@ public void testAsInputStream2() throws Exception { assertNotNull( inputStream ); inputStream.close(); } - - /** - * Test certificate password retrieval - */ - @Test - public void testGetCertificatePassword() { - char[] password = SslKeyStore.getCertificatePassword(); - assertNotNull(password); - assertTrue (password.length>0) ; - } - - /** - * Test keystore password retrieval - */ - @Test - public void testGetKeyStorePassword() { - char[] password = SslKeyStore.getKeyStorePassword() ; - assertNotNull(password); - assertTrue (password.length>0) ; - } -} \ No newline at end of file +} From 17ca65275a2c47e19f900045904c50e78213a9de Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 3 Jul 2014 09:04:37 +0200 Subject: [PATCH 014/285] Unified extensibility method names - removed ambiguity - now both registration methods use the same name pattern - registerSerializer() now correctly allows usage of HeaderSerializer Signed-off-by: Michal Polkorab --- .../impl/connection/SwitchConnectionProviderImpl.java | 7 +++---- .../spi/connection/SwitchConnectionProvider.java | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 92d42626..b2025986 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializerFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; @@ -24,7 +24,6 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -130,8 +129,8 @@ public ServerFacade getServerFacade() { } @Override - public void registerCustomSerializer(MessageTypeKey key, - OFSerializer serializer) { + public void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index abcaabac..c31cb443 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -11,11 +11,10 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import com.google.common.util.concurrent.ListenableFuture; @@ -54,9 +53,9 @@ public interface SwitchConnectionProvider extends AutoCloseable { * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerCustomSerializer(MessageTypeKey key, - OFSerializer serializer); - + public void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer); + /** * Registers custom deserializer * @param key used for deserializer lookup From 00544d12bd8cf8d8d285e3022da4d519596f08cd Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 3 Jul 2014 10:02:51 +0200 Subject: [PATCH 015/285] Extensibility support - added possibility to unregister registered (de)serializers Signed-off-by: Michal Polkorab --- .../api/extensibility/DeserializerRegistry.java | 10 ++++++++++ .../api/extensibility/SerializerRegistry.java | 9 +++++++++ .../SwitchConnectionProviderImpl.java | 10 ++++++++++ .../DeserializerRegistryImpl.java | 12 ++++++++++++ .../serialization/SerializerRegistryImpl.java | 12 ++++++++++++ .../connection/SwitchConnectionProvider.java | 17 +++++++++++++++++ 6 files changed, 70 insertions(+) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 665fa574..4266ab54 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -27,8 +27,18 @@ public interface DeserializerRegistry { SERIALIZER_TYPE getDeserializer(MessageCodeKey key); /** + * Registers deserializer under key * @param key used to registry lookup * @param deserializer deserializer instance */ public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer); + + /** + * Unregisters deserializer under key + * @param key used to registry lookup + * @param deserializer deserializer instance + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + public boolean unregisterDeserializer(MessageCodeKey key); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index b5eec47f..83b4ae8d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -34,4 +34,13 @@ public interface SerializerRegistry { */ public void registerSerializer(MessageTypeKey msgTypeKey, OFGeneralSerializer serializer); + + /** + * Unregisters serializer under key + * @param msgTypeKey lookup key + * @param serializer serializer implementation + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + public boolean unregisterSerializer(MessageTypeKey msgTypeKey); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index b2025986..0bab56a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -144,4 +144,14 @@ public void registerDeserializer(MessageCodeKey key, public void close() throws Exception { shutdown(); } + + @Override + public boolean unregisterSerializer(MessageTypeKey key) { + return serializerRegistry.unregisterSerializer(key); + } + + @Override + public boolean unregisterDeserializer(MessageCodeKey key) { + return deserializerRegistry.unregisterDeserializer(key); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 34d2534c..ff618542 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -78,4 +78,16 @@ public void registerDeserializer(MessageCodeKey key, registry.put(key, deserializer); } + @Override + public boolean unregisterDeserializer(MessageCodeKey key) { + if (key == null) { + throw new NullPointerException("MessageCodeKey is null"); + } + OFGeneralDeserializer deserializer = registry.remove(key); + if (deserializer == null) { + return false; + } + return true; + } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 4336015b..4f36b054 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -81,4 +81,16 @@ public void registerSerializer( } registry.put(msgTypeKey, serializer); } + + @Override + public boolean unregisterSerializer(MessageTypeKey msgTypeKey) { + if (msgTypeKey == null) { + throw new NullPointerException("MessageTypeKey is null"); + } + OFGeneralSerializer serializer = registry.remove(msgTypeKey); + if (serializer == null) { + return false; + } + return true; + } } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index c31cb443..8bae5c06 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -63,4 +63,21 @@ public void registerSerializer(MessageTypeKey key, */ public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer); + /** + * Unregisters custom serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + public boolean unregisterSerializer(MessageTypeKey key); + + /** + * Unregisters custom deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + public boolean unregisterDeserializer(MessageCodeKey key); } From a36c93be5820165c81258c23af1f3ad26d44ffa1 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 3 Jul 2014 13:17:03 +0200 Subject: [PATCH 016/285] Changed output directory for generated classes - generated classes were not cleaned when located in src -> moved to target - also modified .gitignore - removed unnecessary lines Signed-off-by: Michal Polkorab --- .gitignore | 2 -- pom.xml | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6eda0829..1e44f73b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ target/ .settings/ .externalToolBuilders/ maven-eclipse.xml -yang-gen-config -yang-gen-sal .checkstyle diff --git a/pom.xml b/pom.xml index d79caac1..05862144 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,8 @@ 3.0.0 1.5.0 1.26.2 - src/main/yang-gen-config - src/main/yang-gen-sal + ${project.build.directory}/yang-gen-config + ${project.build.directory}/yang-gen-sal ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 1.0.9 @@ -287,8 +287,6 @@ src/main/yang - ${jmxGeneratorPath} - ${salGeneratorPath} @@ -506,4 +504,4 @@ - \ No newline at end of file + From 774bedf030142fd05a31e02b21c4079745cf83f0 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 30 Apr 2014 17:56:11 +0200 Subject: [PATCH 017/285] Default experimenters moved to separate bundle + unit tests (ConfigSubsystem migration will be added later) Change-Id: Ia6477919fa56347d1e28fd329949b2fb4b852b55 Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-augments.yang | 3 + openflow-protocol-ext/pom.xml | 47 ++++++ ...ltExperimenterDeserializerInitializer.java | 18 +-- .../OF10StatsReplyVendorDeserializer.java | 35 +++++ .../OF10VendorActionDeserializer.java | 14 +- .../OF10VendorMessageDeserializer.java | 38 +++++ .../OF13ExperimenterActionDeserializer.java | 60 +++++++ ...3ExperimenterErrorMessageDeserializer.java | 36 +++++ ...13ExperimenterInstructionDeserializer.java | 13 +- .../OF13ExperimenterMessageDeserializer.java | 39 +++++ ...ultipartReplyExperimenterDeserializer.java | 36 +++++ ...etConfigReplyExperimenterDeserializer.java | 53 +++++++ ...TableFeaturesExperimenterDeserializer.java | 49 ++++++ .../DefaultExperimenterInitializer.java | 68 ++++++++ .../OF10StatsRequestVendorSerializer.java | 16 +- .../OF10VendorActionSerializer.java | 12 +- .../OF10VendorInputMessageFactory.java | 20 +-- .../OF13ExperimenterActionSerializer.java | 16 +- .../OF13ExperimenterInputMessageFactory.java | 22 +-- ...OF13ExperimenterInstructionSerializer.java | 12 +- .../OF13MeterBandExperimenterSerializer.java | 25 +-- .../OF13MultipartExperimenterSerializer.java | 21 +-- .../OF13TableFeatExpSerializer.java | 38 +++-- .../protocol/ext/util/ExtBufferUtils.java | 53 +++++++ .../protocol/ext/util/ExtConstants.java | 43 +++++ .../src/main/resources/log4j.xml | 20 +++ .../OF10StatsReplyVendorDeserializerTest.java | 59 +++++++ .../OF10VendorActionDeserializerTest.java | 114 ++++++++++++++ .../OF10VendorMessageDeserializerTest.java | 65 ++++++++ ...F13ExperimenterActionDeserializerTest.java | 114 ++++++++++++++ ...erimenterErrorMessageDeserializerTest.java | 63 ++++++++ ...perimenterInstructionDeserializerTest.java | 114 ++++++++++++++ ...13ExperimenterMessageDeserializerTest.java | 69 ++++++++ ...partReplyExperimenterDeserializerTest.java | 63 ++++++++ ...nfigReplyExperimenterDeserializerTest.java | 75 +++++++++ ...eFeaturesExperimenterDeserializerTest.java | 125 +++++++++++++++ .../OF10StatsRequestVendorSerializerTest.java | 65 ++++++++ .../OF10VendorActionSerializerTest.java | 79 ++++++++++ .../OF10VendorInputMessageFactoryTest.java | 77 +++++++++ .../OF13ExperimenterActionSerializerTest.java | 126 +++++++++++++++ ...13ExperimenterInputMessageFactoryTest.java | 77 +++++++++ ...ExperimenterInstructionSerializerTest.java | 126 +++++++++++++++ ...13MeterBandExperimenterSerializerTest.java | 51 ++++++ ...13MultipartExperimenterSerializerTest.java | 69 ++++++++ .../OF13TableFeatExpSerializerTest.java | 147 ++++++++++++++++++ .../DeserializerRegistryImpl.java | 2 - .../factories/ErrorMessageFactory.java | 35 +++-- .../MultipartReplyMessageFactory.java | 17 +- .../QueueGetConfigReplyMessageFactory.java | 36 +++-- .../DefaultExperimenterInitializer.java | 66 -------- .../serialization/SerializerRegistryImpl.java | 2 - .../MeterModInputMessageFactoryTest.java | 21 +-- .../MultipartRequestInputFactoryTest.java | 67 -------- .../OF10StatsRequestInputFactoryTest.java | 61 -------- .../OF10VendorInputMessageFactoryTest.java | 71 --------- ...13ExperimenterInputMessageFactoryTest.java | 72 --------- .../multipart/TableFeaturesTest.java | 43 +---- .../impl/util/OF10ActionsSerializerTest.java | 26 ---- .../impl/util/OF13ActionsSerializerTest.java | 26 ---- pom.xml | 1 + 60 files changed, 2442 insertions(+), 589 deletions(-) create mode 100644 openflow-protocol-ext/pom.xml rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext}/deserialization/DefaultExperimenterDeserializerInitializer.java (55%) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java (80%) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization}/OF13ExperimenterInstructionDeserializer.java (81%) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF10StatsRequestVendorSerializer.java (57%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF10VendorActionSerializer.java (79%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF10VendorInputMessageFactory.java (65%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13ExperimenterActionSerializer.java (77%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13ExperimenterInputMessageFactory.java (63%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13ExperimenterInstructionSerializer.java (78%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13MeterBandExperimenterSerializer.java (57%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13MultipartExperimenterSerializer.java (56%) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters => openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization}/OF13TableFeatExpSerializer.java (63%) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java create mode 100644 openflow-protocol-ext/src/main/resources/log4j.xml create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java create mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 4f274d4c..ed6d01d1 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -379,6 +379,9 @@ leaf experimenter { type uint32; } + leaf data { + type binary; + } } } \ No newline at end of file diff --git a/openflow-protocol-ext/pom.xml b/openflow-protocol-ext/pom.xml new file mode 100644 index 00000000..171aa3f6 --- /dev/null +++ b/openflow-protocol-ext/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.5-SNAPSHOT + + org.opendaylight.openflowjava + openflow-protocol-ext + 0.5-SNAPSHOT + bundle + Openflow Protocol Library - EXT + http://maven.apache.org + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + + ${project.groupId} + openflow-protocol-api + ${project.version} + + + ${project.groupId} + openflow-protocol-spi + ${project.version} + + + io.netty + netty-buffer + + + junit + junit + test + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java similarity index 55% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java index 44115fad..9dde85e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DefaultExperimenterDeserializerInitializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java @@ -6,13 +6,11 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; +package org.opendaylight.openflowjava.protocol.ext.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -29,14 +27,14 @@ public class DefaultExperimenterDeserializerInitializer { public static void registerDeserializers(DeserializerRegistry registry) { // register OF v1.0 default experimenter deserializers // - default action deserializer - registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, - EncodeConstants.EXPERIMENTER_VALUE, Action.class), new ExperimenterActionDeserializer()); + registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF10_VERSION_ID, + ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); // register OF v1.3 default experimenter deserializers // - default action deserializer - registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EXPERIMENTER_VALUE, Action.class), new ExperimenterActionDeserializer()); + registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, + ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); // - default instruction deserializer - registry.registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EXPERIMENTER_VALUE, Instruction.class), new OF13ExperimenterInstructionDeserializer()); + registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, + ExtConstants.EXPERIMENTER_VALUE, Instruction.class), new OF13ExperimenterInstructionDeserializer()); } } diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java new file mode 100644 index 00000000..f2447447 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsReplyVendorDeserializer implements OFDeserializer { + + @Override + public MultipartReplyExperimenter deserialize(ByteBuf message) { + MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); + builder.setExperimenter(message.readUnsignedInt()); + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + builder.setData(data); + } + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java similarity index 80% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java index 316d970f..f52d8310 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/ExperimenterActionDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java @@ -6,13 +6,13 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.deserialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; @@ -23,15 +23,15 @@ * @author michal.polkorab * */ -public class ExperimenterActionDeserializer implements OFDeserializer, +public class OF10VendorActionDeserializer implements OFDeserializer, HeaderDeserializer { @Override public Action deserializeHeader(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); @@ -41,11 +41,11 @@ public Action deserializeHeader(ByteBuf input) { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); int length = input.readUnsignedShort(); // subtract experimenter header length - length -= EncodeConstants.EXPERIMENTER_IDS_LENGTH; + length -= ExtConstants.EXPERIMENTER_IDS_LENGTH; ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); if (length > 0) { diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java new file mode 100644 index 00000000..493b35af --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10VendorMessageDeserializer implements OFDeserializer { + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder(); + builder.setVersion((short) ExtConstants.OF10_VERSION_ID); + builder.setXid(message.readUnsignedInt()); + builder.setExperimenter(message.readUnsignedInt()); + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + builder.setData(data); + } + return builder.build(); + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java new file mode 100644 index 00000000..0da1c33f --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterActionDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Action deserializeHeader(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(Experimenter.class); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(input.readUnsignedInt()); + builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + return builder.build(); + } + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(Experimenter.class); + int length = input.readUnsignedShort(); + // subtract experimenter header length + length -= ExtConstants.EXPERIMENTER_IDS_LENGTH; + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(input.readUnsignedInt()); + if (length > 0) { + byte[] data = new byte[length]; + input.readBytes(data); + expBuilder.setData(data); + } + builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + return builder.build(); + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java new file mode 100644 index 00000000..2239d119 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterErrorMessageDeserializer implements OFDeserializer { + + @Override + public ExperimenterError deserialize(ByteBuf message) { + ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder(); + expBuilder.setExpType(message.readUnsignedShort()); + expBuilder.setExperimenter(message.readUnsignedInt()); + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + expBuilder.setData(data); + } + return expBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java similarity index 81% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java index ab14cf66..c6a3b389 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenters/OF13ExperimenterInstructionDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java @@ -6,13 +6,13 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.deserialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; @@ -29,20 +29,21 @@ public class OF13ExperimenterInstructionDeserializer implements OFDeserializer 0) { diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java new file mode 100644 index 00000000..43b0356f --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterMessageDeserializer implements OFDeserializer { + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder(); + builder.setVersion((short) ExtConstants.OF13_VERSION_ID); + builder.setXid(message.readUnsignedInt()); + builder.setExperimenter(message.readUnsignedInt()); + builder.setExpType(message.readUnsignedInt()); + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + builder.setData(data); + } + return builder.build(); + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java new file mode 100644 index 00000000..138bb702 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13MultipartReplyExperimenterDeserializer implements OFDeserializer { + + @Override + public MultipartReplyExperimenter deserialize(ByteBuf message) { + MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); + builder.setExperimenter(message.readUnsignedInt()); + builder.setExpType(message.readUnsignedInt()); + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + builder.setData(data); + } + return builder.build(); + } + +} \ No newline at end of file diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java new file mode 100644 index 00000000..87bcff00 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13QueueGetConfigReplyExperimenterDeserializer + implements OFDeserializer { + + private static final int PADDING_IN_QUEUE_PROPERTY_HEADER = 4; + private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4; + + @Override + public QueueProperty deserialize(ByteBuf input) { + QueuePropertyBuilder builder = new QueuePropertyBuilder(); + QueueProperties property = QueueProperties.forValue(input.readUnsignedShort()); + builder.setProperty(property); + int length = input.readUnsignedShort(); + input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER); + ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder(); + expBuilder.setExperimenter(input.readUnsignedInt()); + input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY); + // extract experimenter_data length + length = length - 2 * ExtConstants.SIZE_OF_SHORT_IN_BYTES - PADDING_IN_QUEUE_PROPERTY_HEADER + - ExtConstants.SIZE_OF_INT_IN_BYTES - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY; + if (length > 0) { + byte[] data = new byte[length]; + input.readBytes(data); + expBuilder.setData(data); + } + builder.addAugmentation(ExperimenterQueueProperty.class, expBuilder.build()); + return builder.build(); + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java new file mode 100644 index 00000000..ef9a811e --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13TableFeaturesExperimenterDeserializer + implements OFDeserializer{ + + @Override + public TableFeatureProperties deserialize(ByteBuf input) { + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort()); + builder.setType(type); + int length = input.readUnsignedShort(); + ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = + new ExperimenterRelatedTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(input.readUnsignedInt()); + expBuilder.setExpType(input.readUnsignedInt()); + // extract experimenter_data length + length = length - 2 * ExtConstants.SIZE_OF_SHORT_IN_BYTES - 2 * ExtConstants.SIZE_OF_INT_IN_BYTES; + if (length > 0) { + byte[] data = new byte[length]; + input.readBytes(data); + expBuilder.setData(data); + } + builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build()); + return builder.build(); + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java new file mode 100644 index 00000000..a3509fab --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class DefaultExperimenterInitializer { + + /** + * Registers message serializers into provided registry + * @param registry registry to be initialized with message serializers + */ + public static void registerDefaultExperimenterSerializers(SerializerRegistry registry) { + // register OF v1.0 default experimenter serializers + short version = ExtConstants.OF10_VERSION_ID; + // - default vendor (experimenter) message serializer + registry.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), + new OF10VendorInputMessageFactory()); + // - default vendor (experimenter) action serializer + registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, + Experimenter.class), new OF10VendorActionSerializer()); + // - default vendor stats (experimenter multipart) serializer + registry.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), + new OF10StatsRequestVendorSerializer()); + + // register OF v1.3 default experimenter serializers + version = ExtConstants.OF13_VERSION_ID; + // - default experimenter message serializer + registry.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), + new OF13ExperimenterInputMessageFactory()); + // - default experimenter action serializer + registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, + Experimenter.class), new OF13ExperimenterActionSerializer()); + // - default vendor stats (experimenter multipart) serializer + registry.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), + new OF13MultipartExperimenterSerializer()); + // - default experimenter instruction serializer + registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Instruction.class, + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common + .instruction.rev130731.Experimenter.class), new OF13ExperimenterInstructionSerializer()); + // - default experimenter message serializer + registry.registerSerializer(new MessageTypeKey<>(version, TableFeatureProperties.class), + new OF13TableFeatExpSerializer()); + // - default experimenter message serializer + registry.registerSerializer(new MessageTypeKey<>(version, MeterBandExperimenter.class), + new OF13MeterBandExperimenterSerializer()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10StatsRequestVendorSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java similarity index 57% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10StatsRequestVendorSerializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java index 37d9212d..a2f94f3e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10StatsRequestVendorSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java @@ -1,18 +1,22 @@ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; +/** + * @author michal.polkorab + * + */ public class OF10StatsRequestVendorSerializer implements OFSerializer{ - @Override - public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getExperimenter().intValue()); + @Override + public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { + outBuffer.writeInt(input.getExperimenter().intValue()); if (input.getData() != null) { - outBuffer.writeBytes(input.getData()); + outBuffer.writeBytes(input.getData()); } - } + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java similarity index 79% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java index db950929..83d20ad7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorActionSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java @@ -6,23 +6,27 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +/** + * @author michal.polkorab + * + */ public class OF10VendorActionSerializer implements OFSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); outBuffer.writeInt(experimenter.getExperimenter().intValue()); byte[] data = experimenter.getData(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java similarity index 65% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java index 2a9cfb66..ef1f7633 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF10VendorInputMessageFactory.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java @@ -6,13 +6,13 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; /** @@ -22,16 +22,16 @@ public class OF10VendorInputMessageFactory implements OFSerializer { private static final byte MESSAGE_TYPE = 4; - - @Override - public void serialize(ExperimenterInput input, ByteBuf outBuffer) { - ByteBufUtils.writeOFHeader(MESSAGE_TYPE, input, outBuffer, EncodeConstants.EMPTY_LENGTH); + + @Override + public void serialize(ExperimenterInput input, ByteBuf outBuffer) { + ExtBufferUtils.writeOFHeader(MESSAGE_TYPE, input, outBuffer, ExtConstants.EMPTY_LENGTH); outBuffer.writeInt(input.getExperimenter().intValue()); byte[] data = input.getData(); if (data != null) { outBuffer.writeBytes(data); } - ByteBufUtils.updateOFHeaderLength(outBuffer); - } - + ExtBufferUtils.updateOFHeaderLength(outBuffer); + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java similarity index 77% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java index a2f320f0..c0fbb480 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterActionSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java @@ -6,25 +6,29 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +/** + * @author michal.polkorab + * + */ public class OF13ExperimenterActionSerializer implements OFSerializer, HeaderSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { int actionStartIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); int actionLengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); ExperimenterAction expAction = action.getAugmentation(ExperimenterAction.class); outBuffer.writeInt(expAction.getExperimenter().intValue()); if (expAction.getData() != null) { @@ -35,8 +39,8 @@ public void serialize(Action action, ByteBuf outBuffer) { @Override public void serializeHeader(Action action, ByteBuf outBuffer) { - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_IDS_LENGTH); + outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + outBuffer.writeShort(ExtConstants.EXPERIMENTER_IDS_LENGTH); ExperimenterAction expAction = action.getAugmentation(ExperimenterAction.class); outBuffer.writeInt(expAction.getExperimenter().intValue()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java similarity index 63% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java index 58b2b68e..0b5752c8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13ExperimenterInputMessageFactory.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java @@ -6,13 +6,13 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; /** @@ -24,17 +24,17 @@ public class OF13ExperimenterInputMessageFactory implements OFSerializer { +/** + * @author michal.polkorab + * + */ +public class OF13MeterBandExperimenterSerializer implements OFSerializer { - @Override - public void serialize(MeterBandExperimenter meterBand, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(meterBand.getType().getIntValue()); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + @Override + public void serialize(MeterBandExperimenter meterBand, ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(meterBand.getType().getIntValue()); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); outBuffer.writeInt(meterBand.getRate().intValue()); outBuffer.writeInt(meterBand.getBurstSize().intValue()); outBuffer.writeInt(meterBand.getExperimenter().intValue()); if (meterBand.getData() != null) { - outBuffer.writeBytes(meterBand.getData()); + outBuffer.writeBytes(meterBand.getData()); } outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MultipartExperimenterSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java similarity index 56% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MultipartExperimenterSerializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java index 42002a4a..d018bf75 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13MultipartExperimenterSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java @@ -6,23 +6,26 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; -public class OF13MultipartExperimenterSerializer - implements OFSerializer { +/** + * @author michal.polkorab + * + */ +public class OF13MultipartExperimenterSerializer implements OFSerializer { - @Override - public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getExperimenter().intValue()); - outBuffer.writeInt(input.getExpType().intValue()); + @Override + public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { + outBuffer.writeInt(input.getExperimenter().intValue()); + outBuffer.writeInt(input.getExpType().intValue()); if (input.getData() != null) { - outBuffer.writeBytes(input.getData()); + outBuffer.writeBytes(input.getData()); } - } + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java similarity index 63% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java index 2c4f49f1..5eba6bf1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenters/OF13TableFeatExpSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java @@ -6,32 +6,36 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenters; +package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +/** + * @author michal.polkorab + * + */ public class OF13TableFeatExpSerializer implements OFSerializer { private static final int EXPERIMENTER_CODE = 65534; // 0xFFFE private static final int EXPERIMENTER_MISS_CODE = 65535; // 0xFFFF - @Override - public void serialize(TableFeatureProperties property, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - if (property.getType().equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)) { - outBuffer.writeShort(EXPERIMENTER_CODE); - } else { - outBuffer.writeShort(EXPERIMENTER_MISS_CODE); - } - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + @Override + public void serialize(TableFeatureProperties property, ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + if (property.getType().equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)) { + outBuffer.writeShort(EXPERIMENTER_CODE); + } else { + outBuffer.writeShort(EXPERIMENTER_MISS_CODE); + } + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); ExperimenterRelatedTableFeatureProperty exp = property. getAugmentation(ExperimenterRelatedTableFeatureProperty.class); outBuffer.writeInt(exp.getExperimenter().intValue()); @@ -40,12 +44,12 @@ public void serialize(TableFeatureProperties property, ByteBuf outBuffer) { if (data != null) { outBuffer.writeBytes(data); } - int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; + int paddingRemainder = (outBuffer.writerIndex() - startIndex) % ExtConstants.PADDING; if (paddingRemainder != 0) { - int padding = EncodeConstants.PADDING - paddingRemainder; - ByteBufUtils.padBuffer(padding, outBuffer); + int padding = ExtConstants.PADDING - paddingRemainder; + ExtBufferUtils.padBuffer(padding, outBuffer); } outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } + } } diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java new file mode 100644 index 00000000..1bae5d9b --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.util; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +/** + * @author michal.polkorab + * + */ +public class ExtBufferUtils { + + /** + * Create OF header + * @param msgType message code + * @param message POJO + * @param out writing buffer + * @param length ofheader length + */ + public static void writeOFHeader(byte msgType, E message, ByteBuf out, int length) { + out.writeByte(message.getVersion()); + out.writeByte(msgType); + out.writeShort(length); + out.writeInt(message.getXid().intValue()); + } + + /** + * Write length standard OF header + * @param out writing buffer + */ + public static void updateOFHeaderLength(ByteBuf out) { + out.setShort(ExtConstants.OFHEADER_LENGTH_INDEX, out.readableBytes()); + } + + /** + * Fills specified ByteBuf with 0 (zeros) of desired length, used for padding + * @param length + * @param out ByteBuf to be padded + */ + public static void padBuffer(int length, ByteBuf out) { + for (int i = 0; i < length; i++) { + out.writeByte(0); + } + } +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java new file mode 100644 index 00000000..80c384f3 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.util; + +/** + * @author michal.polkorab + * + */ +public class ExtConstants { + + /** Default OF padding (in bytes) */ + public static final byte PADDING = 8; + /** OpenFlow v1.0 wire protocol number */ + public static final byte OF10_VERSION_ID = 0x01; + /** OpenFlow v1.0 wire protocol number */ + public static final byte OF13_VERSION_ID = 0x04; + /** Index of length in Openflow header */ + public static final int OFHEADER_LENGTH_INDEX = 2; + /** Zero length - used when the length is updated later */ + public static final int EMPTY_LENGTH = 0; + + /** Length of long in bytes */ + public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE; + /** Length of int in bytes */ + public static final byte SIZE_OF_INT_IN_BYTES = Integer.SIZE / Byte.SIZE; + /** Length of short in bytes */ + public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE; + /** Length of byte in bytes */ + public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE; + /** Length of 3 bytes */ + public static final byte SIZE_OF_3_BYTES = 3; + + /** Common experimenter value */ + public static final int EXPERIMENTER_VALUE = 0xFFFF; + /** OF v1.3 lenght of experimenter_ids - see Multipart TableFeatures (properties) message */ + public static final byte EXPERIMENTER_IDS_LENGTH = 8; +} diff --git a/openflow-protocol-ext/src/main/resources/log4j.xml b/openflow-protocol-ext/src/main/resources/log4j.xml new file mode 100644 index 00000000..a51c5b5b --- /dev/null +++ b/openflow-protocol-ext/src/main/resources/log4j.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java new file mode 100644 index 00000000..8979b7dd --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsReplyVendorDeserializerTest { + + /** + * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 3, 2, 1, 0}; + buffer.writeBytes(data); + + OF10StatsReplyVendorDeserializer deserializer = + new OF10StatsReplyVendorDeserializer(); + MultipartReplyExperimenter message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, message.getData()); + } + + /** + * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(42); + + OF10StatsReplyVendorDeserializer deserializer = + new OF10StatsReplyVendorDeserializer(); + MultipartReplyExperimenter message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue()); + Assert.assertNull("Unexpected data", message.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java new file mode 100644 index 00000000..46f4a410 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10VendorActionDeserializerTest { + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(16); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF10VendorActionDeserializer deserializer = + new OF10VendorActionDeserializer(); + Action action = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF10VendorActionDeserializer deserializer = + new OF10VendorActionDeserializer(); + Action action = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeader() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF10VendorActionDeserializer deserializer = + new OF10VendorActionDeserializer(); + Action action = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeaderWithData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF10VendorActionDeserializer deserializer = + new OF10VendorActionDeserializer(); + Action action = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java new file mode 100644 index 00000000..76514bd8 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class OF10VendorMessageDeserializerTest { + + /** + * Testing of {@link OF10VendorMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(12345); + buffer.writeInt(98765); + byte[] data = new byte[]{5, 6, 7, 8}; + buffer.writeBytes(data); + + OF10VendorMessageDeserializer deserializer = + new OF10VendorMessageDeserializer(); + ExperimenterMessage message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong version", 1, message.getVersion().shortValue()); + Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); + Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, message.getData()); + } + + /** + * Testing of {@link OF10VendorMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(12345); + buffer.writeInt(98765); + + OF10VendorMessageDeserializer deserializer = + new OF10VendorMessageDeserializer(); + ExperimenterMessage message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong version", 1, message.getVersion().shortValue()); + Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); + Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); + Assert.assertNull("Unexpected data", message.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java new file mode 100644 index 00000000..4ea3bf3c --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterActionDeserializerTest { + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(16); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF13ExperimenterActionDeserializer deserializer = + new OF13ExperimenterActionDeserializer(); + Action action = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF13ExperimenterActionDeserializer deserializer = + new OF13ExperimenterActionDeserializer(); + Action action = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeader() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF13ExperimenterActionDeserializer deserializer = + new OF13ExperimenterActionDeserializer(); + Action action = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeaderWithData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF13ExperimenterActionDeserializer deserializer = + new OF13ExperimenterActionDeserializer(); + Action action = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); + ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java new file mode 100644 index 00000000..e37f62e4 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterErrorMessageDeserializerTest { + + /** + * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(35000); + buffer.writeInt(70000); + byte[] data = new byte[]{5, 5, 5, 6, 7, 8, 9, 10}; + buffer.writeBytes(data); + + OF13ExperimenterErrorMessageDeserializer deserializer = + new OF13ExperimenterErrorMessageDeserializer(); + ExperimenterError message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); + Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, message.getData()); + } + + /** + * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(35000); + buffer.writeInt(70000); + + OF13ExperimenterErrorMessageDeserializer deserializer = + new OF13ExperimenterErrorMessageDeserializer(); + ExperimenterError message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); + Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); + Assert.assertNull("Unexpected data", message.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java new file mode 100644 index 00000000..bd9f8db0 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterInstructionDeserializerTest { + + /** + * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF13ExperimenterInstructionDeserializer deserializer = + new OF13ExperimenterInstructionDeserializer(); + Instruction instruction = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); + ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF13ExperimenterInstructionDeserializer deserializer = + new OF13ExperimenterInstructionDeserializer(); + Instruction instruction = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); + ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeader() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + + OF13ExperimenterInstructionDeserializer deserializer = + new OF13ExperimenterInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); + ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } + + /** + * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testHeaderWithData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(8); + buffer.writeInt(42); + byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; + buffer.writeBytes(data); + + OF13ExperimenterInstructionDeserializer deserializer = + new OF13ExperimenterInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + + Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); + ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); + Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); + Assert.assertNull("Data not null", experimenter.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java new file mode 100644 index 00000000..f5cc9619 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterMessageDeserializerTest { + + /** + * Testing of {@link OF13ExperimenterMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(12345); + buffer.writeInt(98765); + buffer.writeInt(89123); + byte[] data = new byte[]{5, 6, 7, 8}; + buffer.writeBytes(data); + + OF13ExperimenterMessageDeserializer deserializer = + new OF13ExperimenterMessageDeserializer(); + ExperimenterMessage message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong version", 4, message.getVersion().shortValue()); + Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); + Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 89123, message.getExpType().intValue()); + Assert.assertArrayEquals("Wrong data", data, message.getData()); + } + + /** + * Testing of {@link OF13ExperimenterMessageDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(12345); + buffer.writeInt(98765); + buffer.writeInt(89123); + + OF13ExperimenterMessageDeserializer deserializer = + new OF13ExperimenterMessageDeserializer(); + ExperimenterMessage message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong version", 4, message.getVersion().shortValue()); + Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); + Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 89123, message.getExpType().intValue()); + Assert.assertNull("Unexpected data", message.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java new file mode 100644 index 00000000..ad36b542 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; + +/** + * @author michal.polkorab + * + */ +public class OF13MultipartReplyExperimenterDeserializerTest { + + /** + * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(456654); + buffer.writeInt(888222); + byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3}; + buffer.writeBytes(data); + + OF13MultipartReplyExperimenterDeserializer deserializer = + new OF13MultipartReplyExperimenterDeserializer(); + MultipartReplyExperimenter message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue()); + Assert.assertArrayEquals("Wrong data", data, message.getData()); + } + + /** + * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(456654); + buffer.writeInt(888222); + + OF13MultipartReplyExperimenterDeserializer deserializer = + new OF13MultipartReplyExperimenterDeserializer(); + MultipartReplyExperimenter message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue()); + Assert.assertNull("Unexpected data", message.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java new file mode 100644 index 00000000..b11d466d --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; +import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; + +/** + * @author michal.polkorab + * + */ +public class OF13QueueGetConfigReplyExperimenterDeserializerTest { + + /** + * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(24); + ExtBufferUtils.padBuffer(4, buffer); + buffer.writeInt(128); + ExtBufferUtils.padBuffer(4, buffer); + byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3}; + buffer.writeBytes(data); + + OF13QueueGetConfigReplyExperimenterDeserializer deserializer = + new OF13QueueGetConfigReplyExperimenterDeserializer(); + QueueProperty message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty()); + ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class); + Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue()); + Assert.assertArrayEquals("Wrong data", data, exp.getData()); + } + + /** + * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); + buffer.writeShort(16); + ExtBufferUtils.padBuffer(4, buffer); + buffer.writeInt(128); + ExtBufferUtils.padBuffer(4, buffer); + + OF13QueueGetConfigReplyExperimenterDeserializer deserializer = + new OF13QueueGetConfigReplyExperimenterDeserializer(); + QueueProperty message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty()); + ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class); + Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue()); + Assert.assertNull("Unexpected data", exp.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java new file mode 100644 index 00000000..600a36fd --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class OF13TableFeaturesExperimenterDeserializerTest { + + /** + * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testExperimenter() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(65534); + buffer.writeShort(16); + buffer.writeInt(256); + buffer.writeInt(546); + byte[] data = new byte[]{1, 2, 3, 4}; + buffer.writeBytes(data); + + OF13TableFeaturesExperimenterDeserializer deserializer = + new OF13TableFeaturesExperimenterDeserializer(); + TableFeatureProperties message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTER, message.getType()); + ExperimenterRelatedTableFeatureProperty property = + message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); + Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); + Assert.assertArrayEquals("Wrong data", data, property.getData()); + } + + /** + * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testExperimenterWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(65534); + buffer.writeShort(12); + buffer.writeInt(256); + buffer.writeInt(546); + + OF13TableFeaturesExperimenterDeserializer deserializer = + new OF13TableFeaturesExperimenterDeserializer(); + TableFeatureProperties message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTER, message.getType()); + ExperimenterRelatedTableFeatureProperty property = + message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); + Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); + Assert.assertNull("Unexpected data", property.getData()); + } + + /** + * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testExperimenterMiss() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(65535); + buffer.writeShort(16); + buffer.writeInt(256); + buffer.writeInt(546); + byte[] data = new byte[]{1, 2, 3, 4}; + buffer.writeBytes(data); + + OF13TableFeaturesExperimenterDeserializer deserializer = + new OF13TableFeaturesExperimenterDeserializer(); + TableFeatureProperties message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, message.getType()); + ExperimenterRelatedTableFeatureProperty property = + message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); + Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); + Assert.assertArrayEquals("Wrong data", data, property.getData()); + } + + /** + * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO + * @throws Exception + */ + @Test + public void testExperimenterMissWithoutData() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(65535); + buffer.writeShort(12); + buffer.writeInt(256); + buffer.writeInt(546); + + OF13TableFeaturesExperimenterDeserializer deserializer = + new OF13TableFeaturesExperimenterDeserializer(); + TableFeatureProperties message = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, message.getType()); + ExperimenterRelatedTableFeatureProperty property = + message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); + Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); + Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); + Assert.assertNull("Unexpected data", property.getData()); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java new file mode 100644 index 00000000..e5fd1f6b --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestVendorSerializerTest { + + /** + * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() { + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + expBuilder.setExperimenter(42L); + byte[] data = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; + expBuilder.setData(data); + MultipartRequestExperimenter message = expBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10StatsRequestVendorSerializer serializer = new OF10StatsRequestVendorSerializer(); + serializer.serialize(message, buffer); + + Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); + byte[] expData = new byte[8]; + buffer.readBytes(expData); + Assert.assertArrayEquals("Wrong experimenter data", data, expData); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + expBuilder.setExperimenter(42L); + MultipartRequestExperimenter message = expBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10StatsRequestVendorSerializer serializer = new OF10StatsRequestVendorSerializer(); + serializer.serialize(message, buffer); + + Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java new file mode 100644 index 00000000..bdb06aaa --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10VendorActionSerializerTest { + + /** + * Testing of {@link OF10VendorActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testVendorActionWithData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(82L); + byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; + expBuilder.setData(expData); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorActionSerializer serializer = new OF10VendorActionSerializer(); + serializer.serialize(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong data", expData, tmp); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF10VendorActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testVendorActionWithoutData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(102L); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorActionSerializer serializer = new OF10VendorActionSerializer(); + serializer.serialize(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java new file mode 100644 index 00000000..2d9e82f9 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10VendorInputMessageFactoryTest { + + /** + * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() throws Exception { + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) 1); + builder.setXid(1024L); + builder.setExperimenter(0x0001020304L); + byte[] data = new byte[]{5, 6, 7, 8}; + builder.setData(data); + ExperimenterInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); + vendorFactory.serialize(message, out); + + Assert.assertEquals("Wrong version", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong xid", 1024, out.readUnsignedInt()); + Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); + byte[] expData = new byte[4]; + out.readBytes(expData); + Assert.assertArrayEquals("Wrong data", data, expData); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } + + /** + * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testWithoutData() throws Exception { + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) 1); + builder.setXid(1024L); + builder.setExperimenter(0x0001020304L); + ExperimenterInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); + vendorFactory.serialize(message, out); + + Assert.assertEquals("Wrong version", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong xid", 1024, out.readUnsignedInt()); + Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java new file mode 100644 index 00000000..2eaf92bc --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterActionSerializerTest { + + /** + * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testVendorActionWithData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(82L); + byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; + expBuilder.setData(expData); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); + serializer.serialize(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong data", expData, tmp); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testVendorActionWithoutData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(102L); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); + serializer.serialize(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testHeaderWithData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(82L); + byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; + expBuilder.setData(expData); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); + serializer.serializeHeader(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testHeaderWithoutData() { + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); + expBuilder.setExperimenter(102L); + actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); + Action action = actionBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); + serializer.serializeHeader(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java new file mode 100644 index 00000000..1a14b9d6 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterInputMessageFactoryTest { + + /** + * Testing of {@link OF13ExperimenterInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() throws Exception { + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) 4); + builder.setXid(888L); + builder.setExperimenter(0x0001020304L); + byte[] data = new byte[]{5, 6, 7, 8}; + builder.setData(data); + ExperimenterInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); + vendorFactory.serialize(message, out); + + Assert.assertEquals("Wrong version", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong xid", 888, out.readUnsignedInt()); + Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); + byte[] expData = new byte[4]; + out.readBytes(expData); + Assert.assertArrayEquals("Wrong data", data, expData); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testWithoutData() throws Exception { + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) 4); + builder.setXid(888L); + builder.setExperimenter(0x0001020304L); + ExperimenterInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); + vendorFactory.serialize(message, out); + + Assert.assertEquals("Wrong version", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong xid", 888, out.readUnsignedInt()); + Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java new file mode 100644 index 00000000..177ef631 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ExperimenterInstructionSerializerTest { + + /** + * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() { + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(Experimenter.class); + ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); + expBuilder.setExperimenter(142L); + byte[] data = new byte[]{1, 2, 3, 4, 5, 6, 7, 8}; + expBuilder.setData(data); + builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); + Instruction instruction = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); + serializer.serialize(instruction, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); + byte[] expData = new byte[8]; + buffer.readBytes(expData); + Assert.assertArrayEquals("Wrong experimenter data", data, expData); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(Experimenter.class); + ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); + expBuilder.setExperimenter(142L); + builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); + Instruction instruction = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); + serializer.serialize(instruction, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testHeader() { + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(Experimenter.class); + ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); + expBuilder.setExperimenter(142L); + byte[] data = new byte[]{1, 2, 3, 4, 5, 6, 7, 8}; + expBuilder.setData(data); + builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); + Instruction instruction = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); + serializer.serializeHeader(instruction, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testHeaderWithoutData() { + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(Experimenter.class); + ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); + expBuilder.setExperimenter(142L); + builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); + Instruction instruction = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); + serializer.serializeHeader(instruction, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java new file mode 100644 index 00000000..624a6536 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13MeterBandExperimenterSerializerTest { + + /** + * Testing of {@link OF13MeterBandExperimenterSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() { + MeterBandExperimenterBuilder builder = new MeterBandExperimenterBuilder(); + builder.setType(MeterBandType.OFPMBTEXPERIMENTER); + builder.setRate(128L); + builder.setBurstSize(256L); + builder.setExperimenter(512L); + MeterBandExperimenter band = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13MeterBandExperimenterSerializer serializer = new OF13MeterBandExperimenterSerializer(); + serializer.serialize(band, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong type", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong type", 128, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong type", 256, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong type", 512, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java new file mode 100644 index 00000000..216e5c72 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13MultipartExperimenterSerializerTest { + + /** + * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void test() { + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + expBuilder.setExperimenter(42L); + expBuilder.setExpType(84L); + byte[] data = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; + expBuilder.setData(data); + MultipartRequestExperimenter message = expBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13MultipartExperimenterSerializer serializer = new OF13MultipartExperimenterSerializer(); + serializer.serialize(message, buffer); + + Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 84, buffer.readUnsignedInt()); + byte[] expData = new byte[8]; + buffer.readBytes(expData); + Assert.assertArrayEquals("Wrong experimenter data", data, expData); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testWithoutData() { + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + expBuilder.setExperimenter(42L); + expBuilder.setExpType(84L); + MultipartRequestExperimenter message = expBuilder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13MultipartExperimenterSerializer serializer = new OF13MultipartExperimenterSerializer(); + serializer.serialize(message, buffer); + + Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 84, buffer.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } +} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java new file mode 100644 index 00000000..b6f89c54 --- /dev/null +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13TableFeatExpSerializerTest { + + /** + * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testExperimenter() { + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); + ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = + new ExperimenterRelatedTableFeaturePropertyBuilder(); + propBuilder.setExperimenter(891L); + propBuilder.setExpType(6546L); + byte[] data = new byte[]{0, 1, 2, 3}; + propBuilder.setData(data); + builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, + propBuilder.build()); + TableFeatureProperties property = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); + serializer.serialize(property, buffer); + + Assert.assertEquals("Wrong type", 65534, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 891, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 6546, buffer.readUnsignedInt()); + byte[] expData = new byte[4]; + buffer.readBytes(expData); + Assert.assertArrayEquals("Wrong experimenter data", data, expData); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testExperimenterWithoutData() { + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); + ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = + new ExperimenterRelatedTableFeaturePropertyBuilder(); + propBuilder.setExperimenter(891L); + propBuilder.setExpType(6546L); + builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, + propBuilder.build()); + TableFeatureProperties property = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); + serializer.serialize(property, buffer); + + Assert.assertEquals("Wrong type", 65534, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 891, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 6546, buffer.readUnsignedInt()); + buffer.skipBytes(4); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testExperimenterMiss() { + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); + ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = + new ExperimenterRelatedTableFeaturePropertyBuilder(); + propBuilder.setExperimenter(8L); + propBuilder.setExpType(6L); + byte[] data = new byte[]{4, 5, 6, 7}; + propBuilder.setData(data); + builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, + propBuilder.build()); + TableFeatureProperties property = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); + serializer.serialize(property, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 8, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 6, buffer.readUnsignedInt()); + byte[] expData = new byte[4]; + buffer.readBytes(expData); + Assert.assertArrayEquals("Wrong experimenter data", data, expData); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO + * @throws Exception + */ + @Test + public void testExperimenterMissWithoutData() { + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); + ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = + new ExperimenterRelatedTableFeaturePropertyBuilder(); + propBuilder.setExperimenter(8L); + propBuilder.setExpType(6L); + builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, + propBuilder.build()); + TableFeatureProperties property = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); + serializer.serialize(property, buffer); + + Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong experimenter", 8, buffer.readUnsignedInt()); + Assert.assertEquals("Wrong exp-type", 6, buffer.readUnsignedInt()); + buffer.skipBytes(4); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index ff618542..f7f8b6fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -50,8 +50,6 @@ public void init() { ActionDeserializerInitializer.registerDeserializers(this); // register instruction deserializers InstructionDeserializerInitializer.registerDeserializers(this); - // register default experimenter deserializers - DefaultExperimenterDeserializerInitializer.registerDeserializers(this); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index 5a049c51..45b25aba 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -10,10 +10,12 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode; @@ -37,10 +39,12 @@ * @author michal.polkorab * @author timotej.kubas */ -public class ErrorMessageFactory implements OFDeserializer { +public class ErrorMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { private static final String UNKNOWN_CODE = "UNKNOWN_CODE"; private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE"; + private DeserializerRegistry registry; @Override public ErrorMessage deserialize(ByteBuf rawMessage) { @@ -49,10 +53,18 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); ErrorType errorType = ErrorType.forValue(type); - decodeType(builder, errorType, type); - decodeCode(rawMessage, builder, errorType); - if (rawMessage.readableBytes() > 0) { - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + if (ErrorType.EXPERIMENTER.equals(errorType)) { + builder.setType(errorType.getIntValue()); + OFDeserializer deserializer = registry.getDeserializer(new MessageCodeKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, ErrorMessage.class)); + ExperimenterError error = deserializer.deserialize(rawMessage); + builder.addAugmentation(ExperimenterError.class, error); + } else { + decodeType(builder, errorType, type); + decodeCode(rawMessage, builder, errorType); + if (rawMessage.readableBytes() > 0) { + builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + } } return builder.build(); } @@ -212,12 +224,6 @@ private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder, } break; } - case EXPERIMENTER: - ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder(); - expBuilder.setExpType(code); - expBuilder.setExperimenter(rawMessage.readUnsignedInt()); - builder.addAugmentation(ExperimenterError.class, expBuilder.build()); - break; default: setUnknownCode(builder, code); break; @@ -237,4 +243,9 @@ private static void setCode(ErrorMessageBuilder builder, int code, String codeSt builder.setCodeString(codeString); } + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index cf3e2d74..98192092 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -26,8 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; @@ -432,14 +430,15 @@ private List createTableFeaturesProperties(ByteBuf input builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) { - ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - expBuilder.setExpType(input.readUnsignedInt()); - OFDeserializer propDeserializer = registry.getDeserializer( + // return index to property start, so that the experimenter properties are deserialized + // correctly - as whole ofp_table_feature_prop_experimenter property + input.readerIndex(input.readerIndex() - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + OFDeserializer propDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - type.getIntValue(), ExperimenterRelatedTableFeatureProperty.class)); - ExperimenterRelatedTableFeatureProperty expProp = propDeserializer.deserialize(input); - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expProp); + type.getIntValue(), TableFeatureProperties.class)); + TableFeatureProperties expProp = propDeserializer.deserialize(input); + properties.add(expProp); + continue; } if (paddingRemainder != 0) { input.skipBytes(EncodeConstants.PADDING - paddingRemainder); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java index 26110ec4..ab05b53c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java @@ -13,9 +13,11 @@ import java.util.ArrayList; import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; @@ -33,14 +35,16 @@ * @author timotej.kubas * @author michal.polkorab */ -public class QueueGetConfigReplyMessageFactory implements OFDeserializer { +public class QueueGetConfigReplyMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { private static final byte PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER = 4; private static final byte PADDING_IN_PACKET_QUEUE_HEADER = 6; private static final byte PADDING_IN_QUEUE_PROPERTY_HEADER = 4; private static final int PADDING_IN_RATE_QUEUE_PROPERTY = 6; - private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4; private static final byte PACKET_QUEUE_LENGTH = 16; + private static final byte QUEUE_PROP_HEADER_SIZE = 8; + private DeserializerRegistry registry; @Override public GetQueueConfigOutput deserialize(ByteBuf rawMessage) { @@ -53,7 +57,7 @@ public GetQueueConfigOutput deserialize(ByteBuf rawMessage) { return builder.build(); } - private static List createQueuesList(ByteBuf input){ + private List createQueuesList(ByteBuf input){ List queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { QueuesBuilder queueBuilder = new QueuesBuilder(); @@ -67,7 +71,7 @@ private static List createQueuesList(ByteBuf input){ return queuesList; } - private static List createPropertiesList(ByteBuf input, int length){ + private List createPropertiesList(ByteBuf input, int length){ int propertiesLength = length; List propertiesList = new ArrayList<>(); while (propertiesLength > 0) { @@ -83,16 +87,26 @@ private static List createPropertiesList(ByteBuf input, int lengt propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build()); input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY); } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) { - ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY); - expBuilder.setData(input.readBytes(currentPropertyLength - - EncodeConstants.SIZE_OF_INT_IN_BYTES - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY).array()); - propertiesBuilder.addAugmentation(RateQueueProperty.class, expBuilder.build()); + // return index to property start, so that the experimenter properties are deserialized + // correctly - as whole ofp_queue_prop_experimenter property + input.readerIndex(input.readerIndex() - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES + - PADDING_IN_QUEUE_PROPERTY_HEADER); + OFDeserializer deserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, + EncodeConstants.EXPERIMENTER_VALUE, QueueProperty.class)); + QueueProperty expProp = deserializer.deserialize(input.slice(input.readerIndex(), + currentPropertyLength - QUEUE_PROP_HEADER_SIZE)); + propertiesList.add(expProp); + continue; } propertiesList.add(propertiesBuilder.build()); } return propertiesList; } + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java deleted file mode 100644 index 5aaa458e..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/DefaultExperimenterInitializer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF10StatsRequestVendorSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF10VendorInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13ExperimenterActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13ExperimenterInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13ExperimenterInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13MeterBandExperimenterSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13MultipartExperimenterSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF13TableFeatExpSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class DefaultExperimenterInitializer { - - /** - * Registers message serializers into provided registry - * @param serializerRegistry registry to be initialized with message serializers - */ - public static void registerDefaultExperimenterSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.0 default experimenter serializers - short version = EncodeConstants.OF10_VERSION_ID; - CommonMessageRegistryHelper helper = new CommonMessageRegistryHelper(version, serializerRegistry); - helper.registerSerializer(ExperimenterInput.class, new OF10VendorInputMessageFactory()); - EnhancedKeyRegistryHelper actionHelper = new EnhancedKeyRegistryHelper<>( - EncodeConstants.OF10_VERSION_ID, Action.class, serializerRegistry); - actionHelper.registerSerializer(Experimenter.class, new OF13ExperimenterActionSerializer()); - helper.registerSerializer(MultipartRequestExperimenter.class, new OF10StatsRequestVendorSerializer()); - // register OF v1.3 default experimenter serializers - version = EncodeConstants.OF13_VERSION_ID; - helper = new CommonMessageRegistryHelper(version, serializerRegistry); - helper.registerSerializer(ExperimenterInput.class, new OF13ExperimenterInputMessageFactory()); - helper.registerSerializer(MultipartRequestExperimenter.class, new OF13MultipartExperimenterSerializer()); - helper.registerSerializer(TableFeatureProperties.class, new OF13TableFeatExpSerializer()); - helper.registerSerializer(MeterBandExperimenter.class, new OF13MeterBandExperimenterSerializer()); - actionHelper = new EnhancedKeyRegistryHelper<>( - EncodeConstants.OF13_VERSION_ID, Action.class, serializerRegistry); - actionHelper.registerSerializer(Experimenter.class, new OF13ExperimenterActionSerializer()); - EnhancedKeyRegistryHelper insHelper = new EnhancedKeyRegistryHelper<>( - EncodeConstants.OF13_VERSION_ID, Instruction.class, serializerRegistry); - insHelper.registerSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight - .openflow.common.instruction.rev130731.Experimenter.class, - new OF13ExperimenterInstructionSerializer()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 4f36b054..3d8e3a62 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -50,8 +50,6 @@ public void init() { ActionsInitializer.registerActionSerializers(this); // instruction serializers InstructionsInitializer.registerInstructionSerializers(this); - // default vendor / experimenter serializers - DefaultExperimenterInitializer.registerDefaultExperimenterSerializers(this); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index 11068f3f..718f134b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -32,10 +32,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder; @@ -76,7 +74,7 @@ public void testMeterModInputMessage() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); meterModFactory.serialize(message, out); - BufferHelper.checkHeaderV13(out, (byte) 29, 64); + BufferHelper.checkHeaderV13(out, (byte) 29, 48); Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt()); @@ -109,14 +107,6 @@ private static List createBandsList(){ dscpRemarkBand.setPrecLevel((short) 3); dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); - MeterBandExperimenterCaseBuilder expCaseBuilder = new MeterBandExperimenterCaseBuilder(); - MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder(); - experimenterBand.setType(MeterBandType.OFPMBTEXPERIMENTER); - experimenterBand.setRate(1L); - experimenterBand.setBurstSize(2L); - experimenterBand.setExperimenter(4L); - expCaseBuilder.setMeterBandExperimenter(experimenterBand.build()); - bandsList.add(bandsBuilder.setMeterBand(expCaseBuilder.build()).build()); return bandsList; } @@ -142,15 +132,6 @@ private static List decodeBandsList(ByteBuf input){ input.skipBytes(3); dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); - MeterBandExperimenterCaseBuilder expCaseBuilder = new MeterBandExperimenterCaseBuilder(); - MeterBandExperimenterBuilder experimenterBand = new MeterBandExperimenterBuilder(); - experimenterBand.setType(MeterBandType.forValue(input.readUnsignedShort())); - input.skipBytes(Short.SIZE/Byte.SIZE); - experimenterBand.setRate(input.readUnsignedInt()); - experimenterBand.setBurstSize(input.readUnsignedInt()); - experimenterBand.setExperimenter(input.readUnsignedInt()); - expCaseBuilder.setMeterBandExperimenter(experimenterBand.build()); - bandsList.add(bandsBuilder.setMeterBand(expCaseBuilder.build()).build()); return bandsList; } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java index 4227330b..1c34f365 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java @@ -32,7 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase; @@ -47,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder; @@ -453,69 +451,4 @@ private static MultipartRequestBody createRequestDesc() { return caseBuilder.build(); } - /** - * Testing OF10StatsRequestInputFactory (Vendor) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(56L); - expBuilder.setExpType(148L); - byte[] expData = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - expBuilder.setData(expData); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 18, 32); - Assert.assertEquals("Wrong type", 0xFFFF, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES); - Assert.assertEquals("Wrong experimenter", 56, out.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 148, out.readUnsignedInt()); - byte[] temp = new byte[8]; - out.readBytes(temp); - Assert.assertArrayEquals("Wrong data", expData, temp); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Vendor) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenterWithoutData() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(56L); - expBuilder.setExpType(152L); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 18, 24); - Assert.assertEquals("Wrong type", 0xFFFF, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES); - Assert.assertEquals("Wrong experimenter", 56, out.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 152, out.readUnsignedInt()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 737acecc..5909067e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -29,13 +29,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; @@ -302,63 +300,4 @@ public void testQueue() throws Exception { Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - - /** - * Testing OF10StatsRequestInputFactory (Vendor) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(56L); - byte[] expData = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - expBuilder.setData(expData); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 24); - Assert.assertEquals("Wrong type", 0xFFFF, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 56, out.readUnsignedInt()); - byte[] temp = new byte[8]; - out.readBytes(temp); - Assert.assertArrayEquals("Wrong data", expData, temp); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Vendor) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenterWithoutData() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(56L); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 16); - Assert.assertEquals("Wrong type", 0xFFFF, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 56, out.readUnsignedInt()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java deleted file mode 100644 index 022b3349..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10VendorInputMessageFactoryTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenters.OF10VendorInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorInputMessageFactoryTest { - - private SerializerRegistry registry; - private OFSerializer vendorFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - vendorFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, ExperimenterInput.class)); - } - - - /** - * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setExperimenter(0x0001020304L); - builder.setData(new byte[] {0x01, 0x02, 0x03, 0x04}); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - vendorFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 4, 16); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - byte[] data = new byte[4]; - out.readBytes(data); - Assert.assertArrayEquals("Wrong data", message.getData(), data); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java deleted file mode 100644 index 362f95ac..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF13ExperimenterInputMessageFactoryTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF13ExperimenterInputMessageFactoryTest { - - private static final byte EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE = 4; - private SerializerRegistry registry; - private OFSerializer expFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - expFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterInput.class)); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setExperimenter(0x0001020304L); - builder.setExpType(0x0001020304L); - byte[] expData = new byte[] {0, 1, 2, 3, 4, 5, 6, 7}; - builder.setData(expData); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, EXPERIMENTER_REQUEST_MESSAGE_CODE_TYPE, 24); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - Assert.assertEquals("Wrong expType", 0x0001020304L, out.readUnsignedInt()); - byte[] tmp = new byte[8]; - out.readBytes(tmp); - Assert.assertArrayEquals("Wrong data", expData, tmp); - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java index 12cb7244..347ca633 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java @@ -26,8 +26,6 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; @@ -204,27 +202,6 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { oxmBuilder.setMatchEntries(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); - ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(1024L); - expBuilder.setExpType(2048L); - byte[] expData = new byte[]{0, 1, 2}; - expBuilder.setData(expData); - propBuilder.addAugmentation( - ExperimenterRelatedTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); - expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(4098L); - expBuilder.setExpType(8152L); - byte[] expData2 = new byte[]{3, 4, 6, 7, 8, 9}; - expBuilder.setData(expData2); - propBuilder.addAugmentation( - ExperimenterRelatedTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); tableFeaturesBuilder.setTableFeatureProperties(properties); tableFeaturesList.add(tableFeaturesBuilder.build()); featuresBuilder.setTableFeatures(tableFeaturesList); @@ -235,7 +212,7 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - BufferHelper.checkHeaderV13(out, (byte) 18, 272); + BufferHelper.checkHeaderV13(out, (byte) 18, 232); Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); @@ -282,7 +259,7 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong length", 136, out.readUnsignedShort()); + Assert.assertEquals("Wrong length", 96, out.readUnsignedShort()); Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); out.skipBytes(5); Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", @@ -315,22 +292,6 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); out.skipBytes(4); - Assert.assertEquals("Wrong property type", 0xFFFE, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 1024, out.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 2048, out.readUnsignedInt()); - byte[] tmp = new byte[3]; - out.readBytes(tmp); - Assert.assertArrayEquals("Wrong experimenter data", expData, tmp); - out.skipBytes(1); - Assert.assertEquals("Wrong property type", 0xFFFF, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 4098, out.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 8152, out.readUnsignedInt()); - byte[] tmp2 = new byte[6]; - out.readBytes(tmp2); - Assert.assertArrayEquals("Wrong experimenter data", expData2, tmp2); - out.skipBytes(6); Assert.assertTrue("Unread data", out.readableBytes() == 0); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index eba0d98b..533bfa40 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -24,8 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; @@ -41,7 +39,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; @@ -155,20 +152,6 @@ public void test() { queueBuilder.setQueueId(400L); actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(82L); - byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; - expBuilder.setData(expData); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(102L); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory @@ -230,15 +213,6 @@ public void test() { Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort()); out.skipBytes(6); Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 82, out.readUnsignedInt()); - byte[] tmp = new byte[8]; - out.readBytes(tmp); - Assert.assertArrayEquals("Wrong data", expData, tmp); - Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 102, out.readUnsignedInt()); Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index b450ccdc..76784c92 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -21,8 +21,6 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; @@ -43,7 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; @@ -178,20 +175,6 @@ public void test() { actionBuilder = new ActionBuilder(); actionBuilder.setType(PopPbb.class); actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(82L); - byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; - expBuilder.setData(expData); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(102L); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory @@ -257,15 +240,6 @@ public void test() { Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); - Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 82, out.readUnsignedInt()); - byte[] tmp = new byte[8]; - out.readBytes(tmp); - Assert.assertArrayEquals("Wrong data", expData, tmp); - Assert.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 102, out.readUnsignedInt()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } diff --git a/pom.xml b/pom.xml index 05862144..b691ee2e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ openflow-protocol-it feature simple-client + openflow-protocol-ext scm:git:ssh://git.opendaylight.org:29418/openflowjava.git From 5c2b2f88da58e2e629eb5a06fdcb281ff8010656 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 9 May 2014 15:21:05 +0200 Subject: [PATCH 018/285] Default experimenter bundle migrated to ConfigSubsystem - updated copyright for ext bundle Change-Id: I031afe7f1674d4fc44e91be64b5a1cb51bef44ac Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-augments.yang | 4 +- openflow-protocol-ext/pom.xml | 66 +++++++++++++++++++ .../protocol/ext/ExtensionRegistrator.java | 49 ++++++++++++++ ...ltExperimenterDeserializerInitializer.java | 14 ++-- .../OF10StatsReplyVendorDeserializer.java | 2 +- .../OF10VendorActionDeserializer.java | 2 +- .../OF10VendorMessageDeserializer.java | 2 +- .../OF13ExperimenterActionDeserializer.java | 2 +- ...3ExperimenterErrorMessageDeserializer.java | 4 +- ...13ExperimenterInstructionDeserializer.java | 2 +- .../OF13ExperimenterMessageDeserializer.java | 2 +- ...ultipartReplyExperimenterDeserializer.java | 2 +- ...etConfigReplyExperimenterDeserializer.java | 2 +- ...TableFeaturesExperimenterDeserializer.java | 2 +- ...ultExperimenterSerializerInitializer.java} | 28 ++++---- .../OF10StatsRequestVendorSerializer.java | 8 +++ .../OF10VendorActionSerializer.java | 2 +- .../OF10VendorInputMessageFactory.java | 2 +- .../OF13ExperimenterActionSerializer.java | 2 +- .../OF13ExperimenterInputMessageFactory.java | 2 +- ...OF13ExperimenterInstructionSerializer.java | 2 +- .../OF13MeterBandExperimenterSerializer.java | 2 +- .../OF13MultipartExperimenterSerializer.java | 2 +- .../OF13TableFeatExpSerializer.java | 2 +- .../protocol/ext/util/ExtBufferUtils.java | 2 +- .../protocol/ext/util/ExtConstants.java | 2 +- .../rev140509/ExtensionRegistratorModule.java | 34 ++++++++++ .../ExtensionRegistratorModuleFactory.java | 20 ++++++ .../src/main/yang/openflow-ext.yang | 45 +++++++++++++ .../OF10StatsReplyVendorDeserializerTest.java | 2 +- .../OF10VendorActionDeserializerTest.java | 2 +- .../OF10VendorMessageDeserializerTest.java | 2 +- ...F13ExperimenterActionDeserializerTest.java | 2 +- ...erimenterErrorMessageDeserializerTest.java | 6 +- ...perimenterInstructionDeserializerTest.java | 2 +- ...13ExperimenterMessageDeserializerTest.java | 2 +- ...partReplyExperimenterDeserializerTest.java | 2 +- ...nfigReplyExperimenterDeserializerTest.java | 2 +- ...eFeaturesExperimenterDeserializerTest.java | 2 +- .../OF10StatsRequestVendorSerializerTest.java | 2 +- .../OF10VendorActionSerializerTest.java | 2 +- .../OF10VendorInputMessageFactoryTest.java | 2 +- .../OF13ExperimenterActionSerializerTest.java | 2 +- ...13ExperimenterInputMessageFactoryTest.java | 2 +- ...ExperimenterInstructionSerializerTest.java | 2 +- ...13MeterBandExperimenterSerializerTest.java | 2 +- ...13MultipartExperimenterSerializerTest.java | 2 +- .../OF13TableFeatExpSerializerTest.java | 2 +- .../DeserializerRegistryImpl.java | 2 +- 49 files changed, 288 insertions(+), 66 deletions(-) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java rename openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/{DefaultExperimenterInitializer.java => DefaultExperimenterSerializerInitializer.java} (76%) create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java create mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java create mode 100644 openflow-protocol-ext/src/main/yang/openflow-ext.yang diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index ed6d01d1..2ac2d248 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -379,8 +379,8 @@ leaf experimenter { type uint32; } - leaf data { - type binary; + leaf exp-data { + type binary; } } diff --git a/openflow-protocol-ext/pom.xml b/openflow-protocol-ext/pom.xml index 171aa3f6..935449c4 100644 --- a/openflow-protocol-ext/pom.xml +++ b/openflow-protocol-ext/pom.xml @@ -18,6 +18,62 @@ HEAD + + + + org.opendaylight.yangtools + yang-maven-plugin + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${jmxGeneratorPath} + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + ${salGeneratorPath} + + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + ${project.build.directory}/site/models + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${config.version} + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.generator.version} + jar + + + + + + + ${project.groupId} @@ -29,6 +85,11 @@ openflow-protocol-spi ${project.version} + + org.opendaylight.openflowjava + openflow-protocol-impl + ${project.version} + io.netty netty-buffer @@ -43,5 +104,10 @@ slf4j-log4j12 ${slf4j.version} + + org.opendaylight.controller + config-api + ${config.version} + diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java new file mode 100644 index 00000000..19ee4f45 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.ext; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.ext.deserialization.DefaultExperimenterDeserializerInitializer; +import org.opendaylight.openflowjava.protocol.ext.serialization.DefaultExperimenterSerializerInitializer; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; + +/** + * @author michal.polkorab + * + */ +public class ExtensionRegistrator implements AutoCloseable { + + /** + * @param providers providesr that shall be filled with serializers + */ + public void registerDefaultExperimenterSerializers(List providers) { + if (providers != null) { + for (SwitchConnectionProvider provider : providers) { + DefaultExperimenterSerializerInitializer.registerSerializers(provider); + } + } + } + + /** + * @param providers providers that shall be filled with deserializers + */ + public void registerDefaultExperimenterDeserializers(List providers) { + if (providers != null) { + for (SwitchConnectionProvider provider : providers) { + DefaultExperimenterDeserializerInitializer.registerDeserializers(provider); + } + } + } + + @Override + public void close() throws Exception { + // no need to close - registrator only registers (de)serializers and quits + } +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java index 9dde85e3..c57e67e8 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.ext.deserialization; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -22,19 +22,19 @@ public class DefaultExperimenterDeserializerInitializer { /** * Registers default experimenter deserializers - * @param registry registry to be filled with deserializers + * @param provider provider to be filled with deserializers */ - public static void registerDeserializers(DeserializerRegistry registry) { + public static void registerDeserializers(SwitchConnectionProvider provider) { // register OF v1.0 default experimenter deserializers // - default action deserializer - registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF10_VERSION_ID, + provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF10_VERSION_ID, ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); // register OF v1.3 default experimenter deserializers // - default action deserializer - registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, + provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); // - default instruction deserializer - registry.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, + provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, ExtConstants.EXPERIMENTER_VALUE, Instruction.class), new OF13ExperimenterInstructionDeserializer()); } } diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java index f2447447..e981c1b8 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java index f52d8310..2ce0be6c 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java index 493b35af..d421e593 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java index 0da1c33f..86acddce 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java index 2239d119..a95769ca 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -28,7 +28,7 @@ public ExperimenterError deserialize(ByteBuf message) { if (message.readableBytes() > 0) { byte[] data = new byte[message.readableBytes()]; message.readBytes(data); - expBuilder.setData(data); + expBuilder.setExpData(data); } return expBuilder.build(); } diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java index c6a3b389..2474a7dd 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java index 43b0356f..fafdd449 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java index 138bb702..54027e90 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java index 87bcff00..fdbd051c 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java index ef9a811e..aa9993d5 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java similarity index 76% rename from openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java rename to openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java index a3509fab..7f80a67d 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterInitializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -10,8 +10,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -24,45 +24,45 @@ * @author michal.polkorab * */ -public class DefaultExperimenterInitializer { +public class DefaultExperimenterSerializerInitializer { /** * Registers message serializers into provided registry - * @param registry registry to be initialized with message serializers + * @param provider provider to be initialized with message serializers */ - public static void registerDefaultExperimenterSerializers(SerializerRegistry registry) { + public static void registerSerializers(SwitchConnectionProvider provider) { // register OF v1.0 default experimenter serializers short version = ExtConstants.OF10_VERSION_ID; // - default vendor (experimenter) message serializer - registry.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), + provider.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), new OF10VendorInputMessageFactory()); // - default vendor (experimenter) action serializer - registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, + provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, Experimenter.class), new OF10VendorActionSerializer()); // - default vendor stats (experimenter multipart) serializer - registry.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), + provider.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), new OF10StatsRequestVendorSerializer()); // register OF v1.3 default experimenter serializers version = ExtConstants.OF13_VERSION_ID; // - default experimenter message serializer - registry.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), + provider.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), new OF13ExperimenterInputMessageFactory()); // - default experimenter action serializer - registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, + provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, Experimenter.class), new OF13ExperimenterActionSerializer()); // - default vendor stats (experimenter multipart) serializer - registry.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), + provider.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), new OF13MultipartExperimenterSerializer()); // - default experimenter instruction serializer - registry.registerSerializer(new EnhancedMessageTypeKey<>(version, Instruction.class, + provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Instruction.class, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common .instruction.rev130731.Experimenter.class), new OF13ExperimenterInstructionSerializer()); // - default experimenter message serializer - registry.registerSerializer(new MessageTypeKey<>(version, TableFeatureProperties.class), + provider.registerSerializer(new MessageTypeKey<>(version, TableFeatureProperties.class), new OF13TableFeatExpSerializer()); // - default experimenter message serializer - registry.registerSerializer(new MessageTypeKey<>(version, MeterBandExperimenter.class), + provider.registerSerializer(new MessageTypeKey<>(version, MeterBandExperimenter.class), new OF13MeterBandExperimenterSerializer()); } } diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java index a2f94f3e..2958d363 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.openflowjava.protocol.ext.serialization; import io.netty.buffer.ByteBuf; diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java index 83d20ad7..2f2deab1 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java index ef1f7633..b20cef69 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java index c0fbb480..83acd146 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java index 0b5752c8..1dcb8bbb 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java index 6cd2cf72..88e28cb4 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java index f65f5fbc..fad246bb 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java index d018bf75..be8e4a70 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java index 5eba6bf1..8eab0c3c 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java index 1bae5d9b..4c878f38 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java index 80c384f3..06f51eb6 100644 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java new file mode 100644 index 00000000..86ef8556 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509; + +import org.opendaylight.openflowjava.protocol.ext.ExtensionRegistrator; + +public class ExtensionRegistratorModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.AbstractExtensionRegistratorModule { + public ExtensionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public ExtensionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.ExtensionRegistratorModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + ExtensionRegistrator registrator = new ExtensionRegistrator(); + registrator.registerDefaultExperimenterSerializers(getOpenflowSwitchConnectionProviderDependency()); + registrator.registerDefaultExperimenterDeserializers(getOpenflowSwitchConnectionProviderDependency()); + return registrator; + } + +} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java new file mode 100644 index 00000000..139c4921 --- /dev/null +++ b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. +* +* This program and the accompanying materials are made available under the +* terms of the Eclipse Public License v1.0 which accompanies this distribution, +* and is available at http://www.eclipse.org/legal/epl-v10.html +*/ +/* +* Generated file +* +* Generated from: yang module name: openflow-ext yang module local name: openflow-ext +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri May 09 15:50:56 CEST 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509; +public class ExtensionRegistratorModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.AbstractExtensionRegistratorModuleFactory { + +} diff --git a/openflow-protocol-ext/src/main/yang/openflow-ext.yang b/openflow-protocol-ext/src/main/yang/openflow-ext.yang new file mode 100644 index 00000000..aa78e3e6 --- /dev/null +++ b/openflow-protocol-ext/src/main/yang/openflow-ext.yang @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +module openflow-ext { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:openflow:ext"; + prefix "openflow-ext"; + + import config {prefix config; revision-date 2013-04-05;} + import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} + + + description + "openflow library default extension package"; + + revision "2014-05-09" { + description + "Initial revision"; + } + + identity openflow-ext { + base config:module-type; + config:java-name-prefix ExtensionRegistrator; + } + + augment "/config:modules/config:module/config:configuration" { + case openflow-ext { + when "/config:modules/config:module/config:type = 'openflow-ext'"; + + list openflow-switch-connection-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; + } + } + } + } + } +} \ No newline at end of file diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java index 8979b7dd..0a20e935 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java index 46f4a410..4894fae1 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java index 76514bd8..02eb4b0f 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java index 4ea3bf3c..3088c2e5 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java index e37f62e4..5f3aa96d 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -39,7 +39,7 @@ public void test() { Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getData()); + Assert.assertArrayEquals("Wrong data", data, message.getExpData()); } /** @@ -58,6 +58,6 @@ public void testWithoutData() { Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); - Assert.assertNull("Unexpected data", message.getData()); + Assert.assertNull("Unexpected data", message.getExpData()); } } diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java index bd9f8db0..aed3fac4 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java index f5cc9619..c1b0da7a 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java index ad36b542..dc789a98 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java index b11d466d..27133e66 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java index 600a36fd..e7cb027f 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java index e5fd1f6b..7a55990b 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java index bdb06aaa..130fcc0e 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java index 2d9e82f9..8c7f1c70 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java index 2eaf92bc..e7cb7e76 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java index 1a14b9d6..ba0bbf4a 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java index 177ef631..cf01dffc 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java index 624a6536..7cc5b493 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java index 216e5c72..aa332ab4 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java index b6f89c54..cee23f6a 100644 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java +++ b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index f7f8b6fb..f78dbb85 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -26,7 +26,7 @@ * @author michal.polkorab */ public class DeserializerRegistryImpl implements DeserializerRegistry { - + private Map registry; /** From a29dd3933cb2c7e214f686b3a6bef56c06167061 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 8 Jul 2014 11:18:55 +0200 Subject: [PATCH 019/285] Bug 1323 - Treated expensive logging in OFDecoder and OFFrameDecoder Signed-off-by: Michal Polkorab --- .../openflowjava/protocol/impl/core/OFDecoder.java | 6 ++++-- .../openflowjava/protocol/impl/core/OFFrameDecoder.java | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index b4f739b5..8edebe92 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -38,8 +38,10 @@ public OFDecoder() { @Override protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List out) throws Exception { - LOGGER.debug("VersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("VersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + } DataObject dataObject = null; try { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 86eb28a0..88b11a6a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -61,8 +61,10 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) } int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); - LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); + LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + } return; } @@ -70,9 +72,11 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) LOGGER.debug("length of actual message: {}", length); if (readableBytes < length) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("skipping bytebuf - too few bytes for msg: " + readableBytes + " < " + length); LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); + } return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); From 4c994650215392efabd1eedf50129ad1652a905c Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 8 Jul 2014 11:28:48 +0200 Subject: [PATCH 020/285] Bug 1324 - Buffer released correctly (even if translated dataObject is null) - updated OFDecoderTest - buffer is now released even on deserialization exception Change-Id: I1a3a6f17309f795b7db08bf3ed68ea49ab888cf0 Signed-off-by: Michal Polkorab --- .../protocol/impl/core/OFDecoder.java | 16 +++++++++------- .../protocol/impl/core/OFDecoderTest.java | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index 8edebe92..450eb4bb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -47,17 +47,19 @@ protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, try { dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), msg.getVersion()); + if (dataObject == null) { + LOGGER.warn("Translated POJO is null"); + } else { + out.add(dataObject); + } } catch(Exception e) { LOGGER.error("Message deserialization failed"); LOGGER.error(e.getMessage(), e); - return; + // TODO: delegate exception to allow easier deserialization + // debugging / deserialization problem awareness + } finally { + msg.getMessageBuffer().release(); } - if (dataObject == null) { - LOGGER.warn("Translated POJO is null"); - return; - } - msg.getMessageBuffer().release(); - out.add(dataObject); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java index 27a1bff4..4c2789f1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java @@ -90,7 +90,7 @@ public void testDecodeDeserializeException() { // Verify that the message buf was released... assertEquals( 0, outList.size() ) ; - assertEquals( 1, writeObj.refCnt() ) ; + assertEquals( 0, writeObj.refCnt() ) ; } /** @@ -109,6 +109,6 @@ public void testDecodeDeserializeNull() { // Verify that the message buf was released... assertEquals( 0, outList.size() ) ; - assertEquals( 1, writeObj.refCnt() ) ; + assertEquals( 0, writeObj.refCnt() ) ; } } From 60ad94454217d7d1f6f9e65f39f72ae111ecc845 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 14 Jul 2014 16:45:04 +0200 Subject: [PATCH 021/285] Updated extension registration keys - keys now properly use experimenter ID to distinguish between experimenter messages - also updated initialization and registry helper classes Change-Id: I6177c72397aa7b534cffdf0a9b729fbec2effa50 Signed-off-by: Michal Polkorab --- .../api/extensibility/MessageCodeKey.java | 6 +- .../api/extensibility/MessageTypeKey.java | 9 +- .../keys/ActionDeserializerKey.java | 53 ++++++++++++ .../keys/ActionSerializerKey.java | 63 ++++++++++++++ .../keys/InstructionDeserializerKey.java | 53 ++++++++++++ .../keys/InstructionSerializerKey.java | 66 ++++++++++++++ .../keys/MatchEntryDeserializerKey.java | 64 ++++++++++++++ .../keys/MatchEntrySerializerKey.java | 81 +++++++++++++++++ .../src/main/yang/openflow-augments.yang | 6 ++ .../ActionDeserializerInitializer.java | 69 ++++++++------- .../InstructionDeserializerInitializer.java | 23 +++-- .../MessageDerializerInitializer.java | 52 +++++------ .../OF13SetFieldActionDeserializer.java | 17 ++-- .../serialization/ActionsInitializer.java | 16 ++-- .../InstructionsInitializer.java | 10 +-- .../MatchEntriesInitializer.java | 86 ++++++++++--------- .../serialization/SerializerRegistryImpl.java | 1 - .../action/OF13SetFieldActionSerializer.java | 16 +++- .../factories/FlowModInputMessageFactory.java | 8 +- .../GroupModInputMessageFactory.java | 4 +- .../MultipartRequestInputFactory.java | 25 ++++-- .../OF10FlowModInputMessageFactory.java | 8 +- .../OF10PacketOutInputMessageFactory.java | 4 +- .../PacketOutInputMessageFactory.java | 4 +- .../AbstractActionInstructionSerializer.java | 8 +- ...eyMaker.java => AbstractTypeKeyMaker.java} | 4 +- .../ActionDeserializerRegistryHelper.java | 42 +++++++++ .../util/ActionSerializerRegistryHelper.java | 43 ++++++++++ .../impl/util/CodeKeyMakerFactory.java | 34 ++++++-- .../util/EnhancedTypeKeyMakerFactory.java | 64 -------------- ...InstructionDeserializerRegistryHelper.java | 42 +++++++++ .../InstructionSerializerRegistryHelper.java | 42 +++++++++ .../protocol/impl/util/ListSerializer.java | 4 +- .../MatchEntryDeserializerRegistryHelper.java | 10 +-- .../MatchEntrySerializerRegistryHelper.java | 49 +++++++++++ .../impl/util/OF13MatchSerializer.java | 18 ++-- .../SimpleDeserializerRegistryHelper.java | 3 +- ...cedTypeKeyMaker.java => TypeKeyMaker.java} | 6 +- .../impl/util/TypeKeyMakerFactory.java | 86 +++++++++++++++++++ .../MultipartReplyMessageFactoryTest.java | 2 +- .../impl/util/MatchDeserializerTest.java | 14 +-- .../impl/util/OF10ActionsSerializerTest.java | 2 +- .../impl/util/OF13ActionsSerializerTest.java | 2 +- .../util/OF13InstructionsSerializerTest.java | 2 +- 44 files changed, 946 insertions(+), 275 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{util => serialization}/InstructionsInitializer.java (84%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/{AbstractEnhancedTypeKeyMaker.java => AbstractTypeKeyMaker.java} (79%) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMakerFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/{EnhancedTypeKeyMaker.java => TypeKeyMaker.java} (80%) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index 5ebcde21..b850eae9 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -19,7 +19,7 @@ public class MessageCodeKey { /** * Constructor * @param version wire protocol version - * @param value used as distinguisher + * @param value used as distinguisher (read from binary data / buffer) * @param clazz class of object that is going to be deserialized */ public MessageCodeKey(short version, int value, Class clazz) { @@ -60,6 +60,6 @@ public boolean equals(Object obj) { @Override public String toString() { - return "msgVersion: " + msgVersion + " class: " + clazz.getName() + " msgType: " + msgType; + return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; } -} +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java index 7885b7e1..0ece4c61 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java @@ -17,22 +17,21 @@ */ public class MessageTypeKey { - private final Class msgType; + private final Class msgType; private final short msgVersion; /** * @param msgVersion protocol version - * @param msgType type of message + * @param msgType type of message - class of serialized object */ - public MessageTypeKey(short msgVersion, Class msgType) { - super(); + public MessageTypeKey(short msgVersion, Class msgType) { this.msgType = msgType; this.msgVersion = msgVersion; } @Override public String toString() { - return "msgVersion: " + msgVersion + " msgType: " + msgType.getName(); + return "msgVersion: " + msgVersion + " objectType: " + msgType.getName(); } @Override diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java new file mode 100644 index 00000000..f345c3bf --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type action type + * @param experimenterId experimenter / vendor ID + */ + public ActionDeserializerKey(short version, + int type, Long experimenterId) { + super(version, type, Action.class); + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ActionDeserializerKey other = (ActionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java new file mode 100644 index 00000000..3956108e --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class ActionSerializerKey extends MessageTypeKey { + + private Class actionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param actionType type of action + * @param experimenterId experimenter / vendor ID + */ + public ActionSerializerKey(short msgVersion, Class actionType, + Long experimenterId) { + super(msgVersion, Action.class); + this.actionType = actionType; + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("rawtypes") + ActionSerializerKey other = (ActionSerializerKey) obj; + if (actionType == null) { + if (other.actionType != null) + return false; + } else if (!actionType.equals(other.actionType)) + return false; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java new file mode 100644 index 00000000..ec4cc0bb --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type instruction type + * @param experimenterId + */ + public InstructionDeserializerKey(short version, int type, + Long experimenterId) { + super(version, type, Instruction.class); + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InstructionDeserializerKey other = (InstructionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java new file mode 100644 index 00000000..dee43ee8 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class InstructionSerializerKey + extends MessageTypeKey{ + + private Class instructionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object (Instruction.class) + * @param instructionType type of instruction + * @param experimenterId experimenter / vendor ID + */ + public InstructionSerializerKey(short msgVersion, Class instructionType, + Long experimenterId) { + super(msgVersion, Instruction.class); + this.instructionType = instructionType; + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("rawtypes") + InstructionSerializerKey other = (InstructionSerializerKey) obj; + if (instructionType == null) { + if (other.instructionType != null) + return false; + } else if (!instructionType.equals(other.instructionType)) + return false; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " instructionType type: " + instructionType.getName() + + " vendorID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java new file mode 100644 index 00000000..6403a4d9 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerKey extends MessageCodeKey { + + private int oxmField; + private Long experimenterId; + + /** + * @param version protocol wire version + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntryDeserializerKey(short version, + int oxmClass, int oxmField) { + super(version, oxmClass, MatchEntries.class); + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + if (oxmField != other.oxmField) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java new file mode 100644 index 00000000..e71ddb49 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * @param oxm_class (see specification) + * @param oxm_field (see specification) + */ +public class MatchEntrySerializerKey extends MessageTypeKey{ + + private Class oxmClass; + private Class oxmField; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntrySerializerKey(short msgVersion, Class oxmClass, + Class oxmField) { + super(msgVersion, MatchEntries.class); + this.oxmClass = oxmClass; + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + @SuppressWarnings("rawtypes") + MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + if (oxmClass == null) { + if (other.oxmClass != null) + return false; + } else if (!oxmClass.equals(other.oxmClass)) + return false; + if (oxmField == null) { + if (other.oxmField != null) + return false; + } else if (!oxmField.equals(other.oxmField)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: " + + oxmField.getName() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 2ac2d248..44986927 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -175,6 +175,12 @@ type oft:ipv6-exthdr-flags; } } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "experimenter-match-entry"; + leaf experimenter { + type uint32; + } + } augment "/oxm:oxm-container/oxm:match-entries" { ext:augment-identifier "tcp-flag-match-entry"; leaf tcp-flag { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index 7c1d110b..e641ee93 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer; @@ -37,9 +38,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper; /** * @author michal.polkorab @@ -53,37 +52,37 @@ public class ActionDeserializerInitializer { */ public static void registerDeserializers(DeserializerRegistry registry) { // register OF v1.0 action deserializers - SimpleDeserializerRegistryHelper helper = - new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, Action.class, new OF10OutputActionDeserializer()); - helper.registerDeserializer(1, Action.class, new OF10SetVlanVidActionDeserializer()); - helper.registerDeserializer(2, Action.class, new OF10SetVlanPcpActionDeserializer()); - helper.registerDeserializer(3, Action.class, new OF10StripVlanActionDeserializer()); - helper.registerDeserializer(4, Action.class, new OF10SetDlSrcActionDeserializer()); - helper.registerDeserializer(5, Action.class, new OF10SetDlDstActionDeserializer()); - helper.registerDeserializer(6, Action.class, new OF10SetNwSrcActionDeserializer()); - helper.registerDeserializer(7, Action.class, new OF10SetNwDstActionDeserializer()); - helper.registerDeserializer(8, Action.class, new OF10SetNwTosActionDeserializer()); - helper.registerDeserializer(9, Action.class, new OF10SetTpSrcActionDeserializer()); - helper.registerDeserializer(10, Action.class, new OF10SetTpDstActionDeserializer()); - helper.registerDeserializer(11, Action.class, new OF10EnqueueActionDeserializer()); + ActionDeserializerRegistryHelper helper = + new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(0, new OF10OutputActionDeserializer()); + helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); + helper.registerDeserializer(2, new OF10SetVlanPcpActionDeserializer()); + helper.registerDeserializer(3, new OF10StripVlanActionDeserializer()); + helper.registerDeserializer(4, new OF10SetDlSrcActionDeserializer()); + helper.registerDeserializer(5, new OF10SetDlDstActionDeserializer()); + helper.registerDeserializer(6, new OF10SetNwSrcActionDeserializer()); + helper.registerDeserializer(7, new OF10SetNwDstActionDeserializer()); + helper.registerDeserializer(8, new OF10SetNwTosActionDeserializer()); + helper.registerDeserializer(9, new OF10SetTpSrcActionDeserializer()); + helper.registerDeserializer(10, new OF10SetTpDstActionDeserializer()); + helper.registerDeserializer(11, new OF10EnqueueActionDeserializer()); // register OF v1.3 action deserializers - helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, Action.class, new OF13OutputActionDeserializer()); - helper.registerDeserializer(11, Action.class, new OF13CopyTtlOutActionDeserializer()); - helper.registerDeserializer(12, Action.class, new OF13CopyTtlInActionDeserializer()); - helper.registerDeserializer(15, Action.class, new OF13SetMplsTtlActionDeserializer()); - helper.registerDeserializer(16, Action.class, new OF13DecMplsTtlActionDeserializer()); - helper.registerDeserializer(17, Action.class, new OF13PushVlanActionDeserializer()); - helper.registerDeserializer(18, Action.class, new OF13PopVlanActionDeserializer()); - helper.registerDeserializer(19, Action.class, new OF13PushMplsActionDeserializer()); - helper.registerDeserializer(20, Action.class, new OF13PopMplsActionDeserializer()); - helper.registerDeserializer(21, Action.class, new OF13SetQueueActionDeserializer()); - helper.registerDeserializer(22, Action.class, new OF13GroupActionDeserializer()); - helper.registerDeserializer(23, Action.class, new OF13SetNwTtlActionDeserializer()); - helper.registerDeserializer(24, Action.class, new OF13DecNwTtlActionDeserializer()); - helper.registerDeserializer(25, Action.class, new OF13SetFieldActionDeserializer()); - helper.registerDeserializer(26, Action.class, new OF13PushPbbActionDeserializer()); - helper.registerDeserializer(27, Action.class, new OF13PopPbbActionDeserializer()); + helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(0, new OF13OutputActionDeserializer()); + helper.registerDeserializer(11, new OF13CopyTtlOutActionDeserializer()); + helper.registerDeserializer(12, new OF13CopyTtlInActionDeserializer()); + helper.registerDeserializer(15, new OF13SetMplsTtlActionDeserializer()); + helper.registerDeserializer(16, new OF13DecMplsTtlActionDeserializer()); + helper.registerDeserializer(17, new OF13PushVlanActionDeserializer()); + helper.registerDeserializer(18, new OF13PopVlanActionDeserializer()); + helper.registerDeserializer(19, new OF13PushMplsActionDeserializer()); + helper.registerDeserializer(20, new OF13PopMplsActionDeserializer()); + helper.registerDeserializer(21, new OF13SetQueueActionDeserializer()); + helper.registerDeserializer(22, new OF13GroupActionDeserializer()); + helper.registerDeserializer(23, new OF13SetNwTtlActionDeserializer()); + helper.registerDeserializer(24, new OF13DecNwTtlActionDeserializer()); + helper.registerDeserializer(25, new OF13SetFieldActionDeserializer()); + helper.registerDeserializer(26, new OF13PushPbbActionDeserializer()); + helper.registerDeserializer(27, new OF13PopPbbActionDeserializer()); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java index 9a83ec49..a09f5147 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java @@ -9,15 +9,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper; /** * @author michal.polkorab @@ -31,13 +30,13 @@ public class InstructionDeserializerInitializer { */ public static void registerDeserializers(DeserializerRegistry registry) { // register OF v1.3 instruction deserializers - SimpleDeserializerRegistryHelper helper = - new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(1, Instruction.class, new GoToTableInstructionDeserializer()); - helper.registerDeserializer(2, Instruction.class, new WriteMetadataInstructionDeserializer()); - helper.registerDeserializer(3, Instruction.class, new WriteActionsInstructionDeserializer()); - helper.registerDeserializer(4, Instruction.class, new ApplyActionsInstructionDeserializer()); - helper.registerDeserializer(5, Instruction.class, new ClearActionsInstructionDeserializer()); - helper.registerDeserializer(6, Instruction.class, new MeterInstructionDeserializer()); + InstructionDeserializerRegistryHelper helper = + new InstructionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(1, new GoToTableInstructionDeserializer()); + helper.registerDeserializer(2, new WriteMetadataInstructionDeserializer()); + helper.registerDeserializer(3, new WriteActionsInstructionDeserializer()); + helper.registerDeserializer(4, new ApplyActionsInstructionDeserializer()); + helper.registerDeserializer(5, new ClearActionsInstructionDeserializer()); + helper.registerDeserializer(6, new MeterInstructionDeserializer()); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java index 25e896e4..e45da36f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java @@ -65,33 +65,33 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { // register OF v1.0 message deserializers SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, HelloMessage.class, new OF10HelloMessageFactory()); - helper.registerDeserializer(1, ErrorMessage.class, new OF10ErrorMessageFactory()); - helper.registerDeserializer(2, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); - helper.registerDeserializer(3, EchoOutput.class, new OF10EchoReplyMessageFactory()); - helper.registerDeserializer(6, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, PacketInMessage.class, new OF10PacketInMessageFactory()); - helper.registerDeserializer(11, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); - helper.registerDeserializer(12, PortStatusMessage.class, new OF10PortStatusMessageFactory()); - helper.registerDeserializer(17, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); - helper.registerDeserializer(19, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); - helper.registerDeserializer(21, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); + helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); + helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); + helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); // register Of v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(1, ErrorMessage.class, new ErrorMessageFactory()); - helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(6, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, PacketInMessage.class, new PacketInMessageFactory()); - helper.registerDeserializer(11, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); - helper.registerDeserializer(12, PortStatusMessage.class, new PortStatusMessageFactory()); - helper.registerDeserializer(19, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); - helper.registerDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory()); - helper.registerDeserializer(23, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); - helper.registerDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory()); - helper.registerDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); + helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); + helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); + helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 91e55721..e50baa4c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -8,15 +8,15 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; +import io.netty.buffer.ByteBuf; + import java.util.ArrayList; import java.util.List; -import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; @@ -46,9 +46,14 @@ public Action deserialize(ByteBuf input) { // get oxm_field & hasMask byte and extract the field value int oxmField = input.getUnsignedByte(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - OFDeserializer matchDeserializer = registry.getDeserializer( - new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, oxmClass, - oxmField, MatchEntries.class)); + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + } + OFDeserializer matchDeserializer = registry.getDeserializer(key); List entry = new ArrayList<>(); entry.add(matchDeserializer.deserialize(input)); matchEntries.setMatchEntries(entry); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index 753c745a..818a842b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10EnqueueActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10OutputActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlDstActionSerializer; @@ -36,8 +37,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; +import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; @@ -65,7 +65,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** * Initializes serializer registry with action serializers @@ -78,10 +77,9 @@ public class ActionsInitializer { * @param serializerRegistry registry to be initialized with action serializers */ public static void registerActionSerializers(SerializerRegistry serializerRegistry) { - Class actionClass = Action.class; // register OF v1.0 action serializers - EnhancedKeyRegistryHelper helper = - new EnhancedKeyRegistryHelper<>(EncodeConstants.OF10_VERSION_ID, actionClass, serializerRegistry); + ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF10_VERSION_ID, serializerRegistry); helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); @@ -95,8 +93,8 @@ public static void registerActionSerializers(SerializerRegistry serializerRegist helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); // register OF v1.0 action serializers - helper = new EnhancedKeyRegistryHelper<>( - EncodeConstants.OF13_VERSION_ID, actionClass, serializerRegistry); + helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); @@ -114,4 +112,4 @@ public static void registerActionSerializers(SerializerRegistry serializerRegist helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java similarity index 84% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java index 11ac7f56..09bfe0ce 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.protocol.impl.serialization; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -16,13 +16,13 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.MeterInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab @@ -35,11 +35,9 @@ public class InstructionsInitializer { * @param serializerRegistry registry to be initialized with instruction serializers */ public static void registerInstructionSerializers(SerializerRegistry serializerRegistry) { - Class instructionClass = Instruction.class; // register OF v1.3 instruction serializers - EnhancedKeyRegistryHelper helper = - new EnhancedKeyRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - instructionClass, serializerRegistry); + InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 2c7f814f..49a70d3a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -53,6 +53,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; +import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; @@ -112,48 +113,49 @@ public class MatchEntriesInitializer { public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { // register OF v1.3 OpenflowBasicClass match entry serializers Class oxmClass = OpenflowBasicClass.class; - EnhancedKeyRegistryHelper registryHelper = - new EnhancedKeyRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, oxmClass, serializerRegistry); - registryHelper.registerSerializer(InPort.class, new OxmInPortSerializer()); - registryHelper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); - registryHelper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); - registryHelper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); - registryHelper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); - registryHelper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); - registryHelper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); - registryHelper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); - registryHelper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); - registryHelper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); - registryHelper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); - registryHelper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); - registryHelper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); - registryHelper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); - registryHelper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); - registryHelper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); - registryHelper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); - registryHelper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); - registryHelper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); - registryHelper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); - registryHelper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); - registryHelper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); - registryHelper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); - registryHelper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); - registryHelper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); - registryHelper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); - registryHelper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); - registryHelper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); - registryHelper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); - registryHelper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); - registryHelper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); - registryHelper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); - registryHelper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); - registryHelper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); - registryHelper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); - registryHelper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); - registryHelper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); - registryHelper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); - registryHelper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); - registryHelper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); + MatchEntrySerializerRegistryHelper helper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + oxmClass, serializerRegistry); + helper.registerSerializer(InPort.class, new OxmInPortSerializer()); + helper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); + helper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); + helper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); + helper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); + helper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); + helper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); + helper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); + helper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); + helper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); + helper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); + helper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); + helper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); + helper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); + helper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); + helper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); + helper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); + helper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); + helper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); + helper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); + helper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); + helper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); + helper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); + helper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); + helper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); + helper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); + helper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); + helper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); + helper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); + helper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); + helper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); + helper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); + helper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); + helper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); + helper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); + helper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); + helper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); + helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); + helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); + helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); // Register OpenFlow NXM1Class match entry serializer Class nxm1Class = Nxm1Class.class; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 3d8e3a62..47b2d4a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -16,7 +16,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionsInitializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index a2814310..86fb3212 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -10,16 +10,18 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** @@ -39,8 +41,14 @@ public void serialize(Action action, ByteBuf outBuffer) { outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); MatchEntries entry = oxmField.getMatchEntries().get(0); - OFSerializer serializer = registry.getSerializer(new EnhancedMessageTypeKey<>( - EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField())); + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + } else { + key.setExperimenterId(null); + } + OFSerializer serializer = registry.getSerializer(key); serializer.serialize(entry, outBuffer); int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 3bfe885e..421bfc4a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; @@ -32,8 +32,8 @@ public class FlowModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private static final byte MESSAGE_TYPE = 14; private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2; - private static final EnhancedTypeKeyMaker INSTRUCTION_KEY_MAKER = - EnhancedTypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + private static final TypeKeyMaker INSTRUCTION_KEY_MAKER = + TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); private SerializerRegistry registry; @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java index 300e0200..18155039 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; @@ -53,7 +53,7 @@ private void serializerBuckets(List buckets, ByteBuf outBuffer) { outBuffer.writeInt(currentBucket.getWatchPort().getValue().intValue()); outBuffer.writeInt(currentBucket.getWatchGroup().intValue()); ByteBufUtils.padBuffer(PADDING_IN_BUCKET, outBuffer); - ListSerializer.serializeList(currentBucket.getAction(), EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(currentBucket.getAction(), TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer); outBuffer.setShort(bucketLengthIndex, outBuffer.writerIndex() - bucketLengthIndex); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 7aaeb74d..29cc5898 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -12,18 +12,19 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; @@ -34,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; @@ -355,7 +357,7 @@ private void writeInstructionRelatedTableProperty(final ByteBuf output, } padding = paddingNeeded(length); output.writeShort(length); - EnhancedTypeKeyMaker keyMaker = EnhancedTypeKeyMakerFactory + TypeKeyMaker keyMaker = TypeKeyMakerFactory .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output); } else { @@ -413,7 +415,7 @@ private void writeActionsRelatedTableProperty(final ByteBuf output, length += actions.size() * STRUCTURE_HEADER_LENGTH; padding += paddingNeeded(length); output.writeShort(length); - EnhancedTypeKeyMaker keyMaker = EnhancedTypeKeyMakerFactory + TypeKeyMaker keyMaker = TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); ListSerializer.serializeHeaderList(actions, keyMaker, registry, output); } else { @@ -437,9 +439,14 @@ private void writeOxmRelatedTableProperty(final ByteBuf output, output.writeShort(length); for (MatchEntries entry : entries) { - HeaderSerializer entrySerializer = registry.getSerializer( - new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, - entry.getOxmClass(), entry.getOxmMatchField())); + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + } else { + key.setExperimenterId(null); + } + HeaderSerializer entrySerializer = registry.getSerializer(key); entrySerializer.serializeHeader(entry, output); } } else { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index ba8498ef..7ba6e7eb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; @@ -31,8 +31,8 @@ public class OF10FlowModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private static final byte MESSAGE_TYPE = 14; - private static final EnhancedTypeKeyMaker ACTION_KEY_MAKER = - EnhancedTypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID); + private static final TypeKeyMaker ACTION_KEY_MAKER = + TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID); private SerializerRegistry registry; @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java index f217e100..a83c1a6d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; @@ -36,7 +36,7 @@ public void serialize(PacketOutInput message, ByteBuf outBuffer) { int actionsLengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); int actionsStartIndex = outBuffer.writerIndex(); - ListSerializer.serializeList(message.getAction(), EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(message.getAction(), TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, outBuffer); outBuffer.setShort(actionsLengthIndex, outBuffer.writerIndex() - actionsStartIndex); byte[] data = message.getData(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java index e4c56a0d..022ddb98 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; @@ -40,7 +40,7 @@ public void serialize(PacketOutInput message, ByteBuf outBuffer) { outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); ByteBufUtils.padBuffer(PADDING_IN_PACKET_OUT_MESSAGE, outBuffer); int actionsStartIndex = outBuffer.writerIndex(); - ListSerializer.serializeList(message.getAction(), EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(message.getAction(), TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer); outBuffer.setShort(actionsLengthIndex, outBuffer.writerIndex() - actionsStartIndex); byte[] data = message.getData(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index b2667611..8603f513 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedTypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; @@ -31,8 +31,8 @@ public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer implements SerializerRegistryInjector { - private static final EnhancedTypeKeyMaker ACTION_KEY_MAKER = - EnhancedTypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + private static final TypeKeyMaker ACTION_KEY_MAKER = + TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); private SerializerRegistry registry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractEnhancedTypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java similarity index 79% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractEnhancedTypeKeyMaker.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java index 787b7e0d..3a804afc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractEnhancedTypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java @@ -13,14 +13,14 @@ * @author michal.polkorab * @param type the key maker is based on */ -public abstract class AbstractEnhancedTypeKeyMaker implements EnhancedTypeKeyMaker { +public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { private short version; /** * @param version openflow wire version */ - public AbstractEnhancedTypeKeyMaker(short version) { + public AbstractTypeKeyMaker(short version) { this.version = version; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java new file mode 100644 index 00000000..13b9f915 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public ActionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new ActionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java new file mode 100644 index 00000000..48382ad1 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + */ +public class ActionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param objectType + * @param serializerRegistry + */ + public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param actionType + * @param serializer + */ + public void registerSerializer(Class actionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, + actionType, null), serializer); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 26abb180..d2eabddd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -10,12 +10,11 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** * @author michal.polkorab @@ -34,8 +33,16 @@ public MessageCodeKey make(ByteBuf input) { int oxmClass = input.getUnsignedShort(input.readerIndex()); int oxmField = input.getUnsignedByte(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - return new EnhancedMessageCodeKey(getVersion(), oxmClass, - oxmField, MatchEntries.class); + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + return key; + } + key.setExperimenterId(null); + return key; } }; } @@ -49,7 +56,13 @@ public static CodeKeyMaker createActionsKeyMaker(short version) { @Override public MessageCodeKey make(ByteBuf input) { int type = input.getUnsignedShort(input.readerIndex()); - return new MessageCodeKey(getVersion(), type, Action.class); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ActionDeserializerKey(getVersion(), type, expId); + } + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); + return actionDeserializerKey; } }; } @@ -63,7 +76,12 @@ public static CodeKeyMaker createInstructionsKeyMaker(short version) { @Override public MessageCodeKey make(ByteBuf input) { int type = input.getUnsignedShort(input.readerIndex()); - return new MessageCodeKey(getVersion(), type, Instruction.class); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new InstructionDeserializerKey(getVersion(), type, expId); + } + return new InstructionDeserializerKey(getVersion(), type, null); } }; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMakerFactory.java deleted file mode 100644 index 08a9b5ec..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMakerFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Creates KeyMakers - * @author michal.polkorab - */ -public abstract class EnhancedTypeKeyMakerFactory { - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static EnhancedTypeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractEnhancedTypeKeyMaker(version) { - @Override - public EnhancedMessageTypeKey make(MatchEntries entry) { - return new EnhancedMessageTypeKey<>( - getVersion(), entry.getOxmClass(), entry.getOxmMatchField()); - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static EnhancedTypeKeyMaker createActionKeyMaker(short version) { - return new AbstractEnhancedTypeKeyMaker(version) { - @Override - public EnhancedMessageTypeKey make(Action entry) { - return new EnhancedMessageTypeKey<>(getVersion(), Action.class, entry.getType()); - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static EnhancedTypeKeyMaker createInstructionKeyMaker(short version) { - return new AbstractEnhancedTypeKeyMaker(version) { - @Override - public EnhancedMessageTypeKey make(Instruction entry) { - return new EnhancedMessageTypeKey<>(getVersion(), Instruction.class, entry.getType()); - } - }; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java new file mode 100644 index 00000000..211bf158 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new InstructionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java new file mode 100644 index 00000000..5c111088 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + */ +public class InstructionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param serializerRegistry + */ + public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param instructionType + * @param serializer + */ + public void registerSerializer(Class instructionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, + instructionType, null), serializer); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index 9285708b..58a96352 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -32,7 +32,7 @@ public abstract class ListSerializer { * @param outBuffer output buffer */ public static void serializeList(List list, - EnhancedTypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { if (list != null) { for (E item : list) { OFSerializer serializer = registry.getSerializer(keyMaker.make(item)); @@ -49,7 +49,7 @@ public static void serializeList(List list, * @param outBuffer output buffer */ public static void serializeHeaderList(List list, - EnhancedTypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { if (list != null) { for (E item : list) { HeaderSerializer serializer = registry.getSerializer(keyMaker.make(item)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index 102d1f08..0acb4686 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -8,9 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; /** * @author michal.polkorab @@ -41,7 +40,8 @@ public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, * @param deserializer deserializer instance */ public void register(int oxmField, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new EnhancedMessageCodeKey(version, oxmClass, - oxmField, MatchEntries.class), deserializer); + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); + key.setExperimenterId(null); + registry.registerDeserializer(key, deserializer); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java new file mode 100644 index 00000000..d3be60a4 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; + +/** + * @author michal.polkorab + * @param OXM class + */ +public class MatchEntrySerializerRegistryHelper { + + private short version; + private Class generalClass; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param generalClass + * @param serializerRegistry + */ + public MatchEntrySerializerRegistryHelper(short version, Class generalClass, + SerializerRegistry serializerRegistry) { + this.version = version; + this.generalClass = generalClass; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param specificClass + * @param serializer + */ + public void registerSerializer( + Class specificClass, OFGeneralSerializer serializer) { + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); + key.setExperimenterId(null); + serializerRegistry.registerSerializer(key, serializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index e2196daf..d37c0a2b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -12,13 +12,15 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; @@ -75,9 +77,15 @@ public void serializeMatchEntries(List matchEntries, ByteBuf out) return; } for (MatchEntries entry : matchEntries) { - OFSerializer entrySerializer = registry.getSerializer( - new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), - entry.getOxmMatchField())); + + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + } else { + key.setExperimenterId(null); + } + OFSerializer entrySerializer = registry.getSerializer(key); entrySerializer.serialize(entry, out); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 430d836e..0fc66083 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -31,12 +31,13 @@ public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry dese /** * @param code code / value to distinguish between deserializers + * @param experimenterID TODO * @param deserializedObjectClass class of object that will be deserialized * by given deserializer * @param deserializer deserializer instance */ public void registerDeserializer(int code, - Class deserializedObjectClass, OFGeneralDeserializer deserializer) { + Long experimenterID, Class deserializedObjectClass, OFGeneralDeserializer deserializer) { registry.registerDeserializer(new MessageCodeKey(version, code, deserializedObjectClass), deserializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java similarity index 80% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMaker.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index 3add8156..4e17dfcd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedTypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -8,19 +8,19 @@ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; /** * @author michal.polkorab * @param */ -public interface EnhancedTypeKeyMaker { +public interface TypeKeyMaker { /** * @param entry * @return key that will be used for serializer lookup in * the serializer registry */ - public abstract EnhancedMessageTypeKey make(T entry); + public abstract MessageTypeKey make(T entry); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java new file mode 100644 index 00000000..13d68da9 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Creates KeyMakers + * @author michal.polkorab + */ +public abstract class TypeKeyMakerFactory { + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MatchEntrySerializerKey make(MatchEntries entry) { + MatchEntrySerializerKey key; + key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), + entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class) + .getExperimenter()); + return key; + } + key.setExperimenterId(null); + return key; + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createActionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public ActionSerializerKey make(Action entry) { + if (entry.getType().equals(Experimenter.class)) { + return new ActionSerializerKey<>(getVersion(), entry.getType(), entry.getAugmentation(ExperimenterAction.class).getExperimenter()); + } + return new ActionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createInstructionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public InstructionSerializerKey make(Instruction entry) { + if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common + .instruction.rev130731.Experimenter.class)) { + return new InstructionSerializerKey<>(getVersion(), entry.getType(), entry.getAugmentation(ExperimenterInstruction.class).getExperimenter()); + } + return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 94d2a956..5e6017a9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -18,10 +18,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 422113fa..b5ce1806 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -15,9 +15,9 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; @@ -122,8 +122,10 @@ public void startUp() { public void testIpv4Address() { ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); - OFDeserializer entryDeserializer = registry.getDeserializer( - new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12, MatchEntries.class)); + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); MatchEntries entry = entryDeserializer.deserialize(buffer); Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); @@ -136,8 +138,10 @@ public void testIpv4Address() { public void testIpv6Address() { ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); - OFDeserializer entryDeserializer = registry.getDeserializer( - new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26, MatchEntries.class)); + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 26); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); MatchEntries entry = entryDeserializer.deserialize(buffer); Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index 533bfa40..4a80e8c3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -154,7 +154,7 @@ public void test() { actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(actions, TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index 76784c92..bcc335c3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -177,7 +177,7 @@ public void test() { actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(actions, TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 8fbe8b36..902f8b58 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -144,7 +144,7 @@ public void test() { instructions.add(builder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(instructions, EnhancedTypeKeyMakerFactory + ListSerializer.serializeList(instructions, TypeKeyMakerFactory .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); From 645e623113cc537e5dfffa32bb5b56cd09dfb029 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 16 Jul 2014 11:20:27 +0200 Subject: [PATCH 022/285] Deleted openflow-protocol-ext bundle - there is another exemplary bundle - more simpler - removal needed by upcoming changes Signed-off-by: Michal Polkorab --- openflow-protocol-ext/pom.xml | 113 -------------- .../protocol/ext/ExtensionRegistrator.java | 49 ------ ...ltExperimenterDeserializerInitializer.java | 40 ----- .../OF10StatsReplyVendorDeserializer.java | 35 ----- .../OF10VendorActionDeserializer.java | 60 ------- .../OF10VendorMessageDeserializer.java | 38 ----- .../OF13ExperimenterActionDeserializer.java | 60 ------- ...3ExperimenterErrorMessageDeserializer.java | 36 ----- ...13ExperimenterInstructionDeserializer.java | 58 ------- .../OF13ExperimenterMessageDeserializer.java | 39 ----- ...ultipartReplyExperimenterDeserializer.java | 36 ----- ...etConfigReplyExperimenterDeserializer.java | 53 ------- ...TableFeaturesExperimenterDeserializer.java | 49 ------ ...aultExperimenterSerializerInitializer.java | 68 -------- .../OF10StatsRequestVendorSerializer.java | 30 ---- .../OF10VendorActionSerializer.java | 39 ----- .../OF10VendorInputMessageFactory.java | 37 ----- .../OF13ExperimenterActionSerializer.java | 48 ------ .../OF13ExperimenterInputMessageFactory.java | 40 ----- ...OF13ExperimenterInstructionSerializer.java | 49 ------ .../OF13MeterBandExperimenterSerializer.java | 38 ----- .../OF13MultipartExperimenterSerializer.java | 31 ---- .../OF13TableFeatExpSerializer.java | 55 ------- .../protocol/ext/util/ExtBufferUtils.java | 53 ------- .../protocol/ext/util/ExtConstants.java | 43 ----- .../rev140509/ExtensionRegistratorModule.java | 34 ---- .../ExtensionRegistratorModuleFactory.java | 20 --- .../src/main/resources/log4j.xml | 20 --- .../src/main/yang/openflow-ext.yang | 45 ------ .../OF10StatsReplyVendorDeserializerTest.java | 59 ------- .../OF10VendorActionDeserializerTest.java | 114 -------------- .../OF10VendorMessageDeserializerTest.java | 65 -------- ...F13ExperimenterActionDeserializerTest.java | 114 -------------- ...erimenterErrorMessageDeserializerTest.java | 63 -------- ...perimenterInstructionDeserializerTest.java | 114 -------------- ...13ExperimenterMessageDeserializerTest.java | 69 -------- ...partReplyExperimenterDeserializerTest.java | 63 -------- ...nfigReplyExperimenterDeserializerTest.java | 75 --------- ...eFeaturesExperimenterDeserializerTest.java | 125 --------------- .../OF10StatsRequestVendorSerializerTest.java | 65 -------- .../OF10VendorActionSerializerTest.java | 79 ---------- .../OF10VendorInputMessageFactoryTest.java | 77 --------- .../OF13ExperimenterActionSerializerTest.java | 126 --------------- ...13ExperimenterInputMessageFactoryTest.java | 77 --------- ...ExperimenterInstructionSerializerTest.java | 126 --------------- ...13MeterBandExperimenterSerializerTest.java | 51 ------ ...13MultipartExperimenterSerializerTest.java | 69 -------- .../OF13TableFeatExpSerializerTest.java | 147 ------------------ pom.xml | 1 - 49 files changed, 2995 deletions(-) delete mode 100644 openflow-protocol-ext/pom.xml delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java delete mode 100644 openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java delete mode 100644 openflow-protocol-ext/src/main/resources/log4j.xml delete mode 100644 openflow-protocol-ext/src/main/yang/openflow-ext.yang delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java delete mode 100644 openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java diff --git a/openflow-protocol-ext/pom.xml b/openflow-protocol-ext/pom.xml deleted file mode 100644 index 935449c4..00000000 --- a/openflow-protocol-ext/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - 4.0.0 - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.5-SNAPSHOT - - org.opendaylight.openflowjava - openflow-protocol-ext - 0.5-SNAPSHOT - bundle - Openflow Protocol Library - EXT - http://maven.apache.org - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - - - - org.opendaylight.yangtools - yang-maven-plugin - - - - generate-sources - - - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - - ${jmxGeneratorPath} - - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - - ${salGeneratorPath} - - - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl - ${project.build.directory}/site/models - - - true - - - - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${config.version} - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.generator.version} - jar - - - - - - - - - - ${project.groupId} - openflow-protocol-api - ${project.version} - - - ${project.groupId} - openflow-protocol-spi - ${project.version} - - - org.opendaylight.openflowjava - openflow-protocol-impl - ${project.version} - - - io.netty - netty-buffer - - - junit - junit - test - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - org.opendaylight.controller - config-api - ${config.version} - - - diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java deleted file mode 100644 index 19ee4f45..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/ExtensionRegistrator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.ext.deserialization.DefaultExperimenterDeserializerInitializer; -import org.opendaylight.openflowjava.protocol.ext.serialization.DefaultExperimenterSerializerInitializer; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; - -/** - * @author michal.polkorab - * - */ -public class ExtensionRegistrator implements AutoCloseable { - - /** - * @param providers providesr that shall be filled with serializers - */ - public void registerDefaultExperimenterSerializers(List providers) { - if (providers != null) { - for (SwitchConnectionProvider provider : providers) { - DefaultExperimenterSerializerInitializer.registerSerializers(provider); - } - } - } - - /** - * @param providers providers that shall be filled with deserializers - */ - public void registerDefaultExperimenterDeserializers(List providers) { - if (providers != null) { - for (SwitchConnectionProvider provider : providers) { - DefaultExperimenterDeserializerInitializer.registerDeserializers(provider); - } - } - } - - @Override - public void close() throws Exception { - // no need to close - registrator only registers (de)serializers and quits - } -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java deleted file mode 100644 index c57e67e8..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/DefaultExperimenterDeserializerInitializer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class DefaultExperimenterDeserializerInitializer { - - /** - * Registers default experimenter deserializers - * @param provider provider to be filled with deserializers - */ - public static void registerDeserializers(SwitchConnectionProvider provider) { - // register OF v1.0 default experimenter deserializers - // - default action deserializer - provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF10_VERSION_ID, - ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); - // register OF v1.3 default experimenter deserializers - // - default action deserializer - provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, - ExtConstants.EXPERIMENTER_VALUE, Action.class), new OF13ExperimenterActionDeserializer()); - // - default instruction deserializer - provider.registerDeserializer(new MessageCodeKey(ExtConstants.OF13_VERSION_ID, - ExtConstants.EXPERIMENTER_VALUE, Instruction.class), new OF13ExperimenterInstructionDeserializer()); - } -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java deleted file mode 100644 index e981c1b8..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsReplyVendorDeserializer implements OFDeserializer { - - @Override - public MultipartReplyExperimenter deserialize(ByteBuf message) { - MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); - builder.setExperimenter(message.readUnsignedInt()); - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - builder.setData(data); - } - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java deleted file mode 100644 index 2ce0be6c..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorActionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Action deserializeHeader(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - return builder.build(); - } - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - int length = input.readUnsignedShort(); - // subtract experimenter header length - length -= ExtConstants.EXPERIMENTER_IDS_LENGTH; - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - if (length > 0) { - byte[] data = new byte[length]; - input.readBytes(data); - expBuilder.setData(data); - } - builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java deleted file mode 100644 index d421e593..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorMessageDeserializer implements OFDeserializer { - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder(); - builder.setVersion((short) ExtConstants.OF10_VERSION_ID); - builder.setXid(message.readUnsignedInt()); - builder.setExperimenter(message.readUnsignedInt()); - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - builder.setData(data); - } - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java deleted file mode 100644 index 86acddce..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterActionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Action deserializeHeader(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - return builder.build(); - } - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - int length = input.readUnsignedShort(); - // subtract experimenter header length - length -= ExtConstants.EXPERIMENTER_IDS_LENGTH; - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - if (length > 0) { - byte[] data = new byte[length]; - input.readBytes(data); - expBuilder.setData(data); - } - builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java deleted file mode 100644 index a95769ca..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterErrorBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterErrorMessageDeserializer implements OFDeserializer { - - @Override - public ExperimenterError deserialize(ByteBuf message) { - ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder(); - expBuilder.setExpType(message.readUnsignedShort()); - expBuilder.setExperimenter(message.readUnsignedInt()); - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - expBuilder.setExpData(data); - } - return expBuilder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java deleted file mode 100644 index 2474a7dd..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializer.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterInstructionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Instruction deserializeHeader(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - return builder.build(); - } - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - input.skipBytes(ExtConstants.SIZE_OF_SHORT_IN_BYTES); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - if (input.readableBytes() > 0) { - byte[] data = new byte[input.readableBytes()]; - input.readBytes(data); - expBuilder.setData(data); - } - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java deleted file mode 100644 index fafdd449..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterMessageDeserializer implements OFDeserializer { - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - ExperimenterMessageBuilder builder = new ExperimenterMessageBuilder(); - builder.setVersion((short) ExtConstants.OF13_VERSION_ID); - builder.setXid(message.readUnsignedInt()); - builder.setExperimenter(message.readUnsignedInt()); - builder.setExpType(message.readUnsignedInt()); - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - builder.setData(data); - } - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java deleted file mode 100644 index 54027e90..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializer.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13MultipartReplyExperimenterDeserializer implements OFDeserializer { - - @Override - public MultipartReplyExperimenter deserialize(ByteBuf message) { - MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); - builder.setExperimenter(message.readUnsignedInt()); - builder.setExpType(message.readUnsignedInt()); - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - builder.setData(data); - } - return builder.build(); - } - -} \ No newline at end of file diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java deleted file mode 100644 index fdbd051c..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueuePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13QueueGetConfigReplyExperimenterDeserializer - implements OFDeserializer { - - private static final int PADDING_IN_QUEUE_PROPERTY_HEADER = 4; - private static final int PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY = 4; - - @Override - public QueueProperty deserialize(ByteBuf input) { - QueuePropertyBuilder builder = new QueuePropertyBuilder(); - QueueProperties property = QueueProperties.forValue(input.readUnsignedShort()); - builder.setProperty(property); - int length = input.readUnsignedShort(); - input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER); - ExperimenterQueuePropertyBuilder expBuilder = new ExperimenterQueuePropertyBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - input.skipBytes(PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY); - // extract experimenter_data length - length = length - 2 * ExtConstants.SIZE_OF_SHORT_IN_BYTES - PADDING_IN_QUEUE_PROPERTY_HEADER - - ExtConstants.SIZE_OF_INT_IN_BYTES - PADDING_IN_EXPERIMENTER_QUEUE_PROPERTY; - if (length > 0) { - byte[] data = new byte[length]; - input.readBytes(data); - expBuilder.setData(data); - } - builder.addAugmentation(ExperimenterQueueProperty.class, expBuilder.build()); - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java deleted file mode 100644 index aa9993d5..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13TableFeaturesExperimenterDeserializer - implements OFDeserializer{ - - @Override - public TableFeatureProperties deserialize(ByteBuf input) { - TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); - TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort()); - builder.setType(type); - int length = input.readUnsignedShort(); - ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(input.readUnsignedInt()); - expBuilder.setExpType(input.readUnsignedInt()); - // extract experimenter_data length - length = length - 2 * ExtConstants.SIZE_OF_SHORT_IN_BYTES - 2 * ExtConstants.SIZE_OF_INT_IN_BYTES; - if (length > 0) { - byte[] data = new byte[length]; - input.readBytes(data); - expBuilder.setData(data); - } - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build()); - return builder.build(); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java deleted file mode 100644 index 7f80a67d..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/DefaultExperimenterSerializerInitializer.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class DefaultExperimenterSerializerInitializer { - - /** - * Registers message serializers into provided registry - * @param provider provider to be initialized with message serializers - */ - public static void registerSerializers(SwitchConnectionProvider provider) { - // register OF v1.0 default experimenter serializers - short version = ExtConstants.OF10_VERSION_ID; - // - default vendor (experimenter) message serializer - provider.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), - new OF10VendorInputMessageFactory()); - // - default vendor (experimenter) action serializer - provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, - Experimenter.class), new OF10VendorActionSerializer()); - // - default vendor stats (experimenter multipart) serializer - provider.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), - new OF10StatsRequestVendorSerializer()); - - // register OF v1.3 default experimenter serializers - version = ExtConstants.OF13_VERSION_ID; - // - default experimenter message serializer - provider.registerSerializer(new MessageTypeKey<>(version, ExperimenterInput.class), - new OF13ExperimenterInputMessageFactory()); - // - default experimenter action serializer - provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Action.class, - Experimenter.class), new OF13ExperimenterActionSerializer()); - // - default vendor stats (experimenter multipart) serializer - provider.registerSerializer(new MessageTypeKey<>(version, MultipartRequestExperimenter.class), - new OF13MultipartExperimenterSerializer()); - // - default experimenter instruction serializer - provider.registerSerializer(new EnhancedMessageTypeKey<>(version, Instruction.class, - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common - .instruction.rev130731.Experimenter.class), new OF13ExperimenterInstructionSerializer()); - // - default experimenter message serializer - provider.registerSerializer(new MessageTypeKey<>(version, TableFeatureProperties.class), - new OF13TableFeatExpSerializer()); - // - default experimenter message serializer - provider.registerSerializer(new MessageTypeKey<>(version, MeterBandExperimenter.class), - new OF13MeterBandExperimenterSerializer()); - } -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java deleted file mode 100644 index 2958d363..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestVendorSerializer implements OFSerializer{ - - @Override - public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getExperimenter().intValue()); - if (input.getData() != null) { - outBuffer.writeBytes(input.getData()); - } - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java deleted file mode 100644 index 2f2deab1..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializer.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorActionSerializer implements OFSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - outBuffer.writeInt(experimenter.getExperimenter().intValue()); - byte[] data = experimenter.getData(); - if (data != null) { - outBuffer.writeBytes(data); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java deleted file mode 100644 index b20cef69..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; - -/** - * Translates Vendor messages - * @author michal.polkorab - */ -public class OF10VendorInputMessageFactory implements OFSerializer { - - private static final byte MESSAGE_TYPE = 4; - - @Override - public void serialize(ExperimenterInput input, ByteBuf outBuffer) { - ExtBufferUtils.writeOFHeader(MESSAGE_TYPE, input, outBuffer, ExtConstants.EMPTY_LENGTH); - outBuffer.writeInt(input.getExperimenter().intValue()); - byte[] data = input.getData(); - if (data != null) { - outBuffer.writeBytes(data); - } - ExtBufferUtils.updateOFHeaderLength(outBuffer); - } - -} \ No newline at end of file diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java deleted file mode 100644 index 83acd146..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializer.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterActionSerializer implements OFSerializer, - HeaderSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - int actionStartIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - int actionLengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); - ExperimenterAction expAction = action.getAugmentation(ExperimenterAction.class); - outBuffer.writeInt(expAction.getExperimenter().intValue()); - if (expAction.getData() != null) { - outBuffer.writeBytes(expAction.getData()); - } - outBuffer.setShort(actionLengthIndex, outBuffer.writerIndex() - actionStartIndex); - } - - @Override - public void serializeHeader(Action action, ByteBuf outBuffer) { - outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - outBuffer.writeShort(ExtConstants.EXPERIMENTER_IDS_LENGTH); - ExperimenterAction expAction = action.getAugmentation(ExperimenterAction.class); - outBuffer.writeInt(expAction.getExperimenter().intValue()); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java deleted file mode 100644 index 1dcb8bbb..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; - -/** - * Translates Experimenter messages - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF13ExperimenterInputMessageFactory implements OFSerializer{ - - /** Code type of Experimenter message */ - public static final byte MESSAGE_TYPE = 4; - - @Override - public void serialize(ExperimenterInput message, ByteBuf outBuffer) { - ExtBufferUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, ExtConstants.EMPTY_LENGTH); - outBuffer.writeInt(message.getExperimenter().intValue()); - outBuffer.writeInt(message.getExpType().intValue()); - byte[] data = message.getData(); - if (data != null) { - outBuffer.writeBytes(data); - } - ExtBufferUtils.updateOFHeaderLength(outBuffer); - } - -} \ No newline at end of file diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java deleted file mode 100644 index 88e28cb4..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * - * @author michal.polkorab - */ -public class OF13ExperimenterInstructionSerializer implements OFSerializer, - HeaderSerializer{ - - @Override - public void serializeHeader(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - outBuffer.writeShort(ExtConstants.EXPERIMENTER_IDS_LENGTH); - outBuffer.writeInt(instruction - .getAugmentation(ExperimenterInstruction.class).getExperimenter().intValue()); - } - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); - ExperimenterInstruction experimenter = - instruction.getAugmentation(ExperimenterInstruction.class); - outBuffer.writeInt(experimenter.getExperimenter().intValue()); - if (experimenter.getData() != null) { - outBuffer.writeBytes(experimenter.getData()); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java deleted file mode 100644 index fad246bb..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; - -/** - * @author michal.polkorab - * - */ -public class OF13MeterBandExperimenterSerializer implements OFSerializer { - - @Override - public void serialize(MeterBandExperimenter meterBand, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(meterBand.getType().getIntValue()); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); - outBuffer.writeInt(meterBand.getRate().intValue()); - outBuffer.writeInt(meterBand.getBurstSize().intValue()); - outBuffer.writeInt(meterBand.getExperimenter().intValue()); - if (meterBand.getData() != null) { - outBuffer.writeBytes(meterBand.getData()); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java deleted file mode 100644 index be8e4a70..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; - -/** - * @author michal.polkorab - * - */ -public class OF13MultipartExperimenterSerializer implements OFSerializer { - - @Override - public void serialize(MultipartRequestExperimenter input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getExperimenter().intValue()); - outBuffer.writeInt(input.getExpType().intValue()); - if (input.getData() != null) { - outBuffer.writeBytes(input.getData()); - } - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java deleted file mode 100644 index 8eab0c3c..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class OF13TableFeatExpSerializer implements OFSerializer { - - private static final int EXPERIMENTER_CODE = 65534; // 0xFFFE - private static final int EXPERIMENTER_MISS_CODE = 65535; // 0xFFFF - - @Override - public void serialize(TableFeatureProperties property, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - if (property.getType().equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER)) { - outBuffer.writeShort(EXPERIMENTER_CODE); - } else { - outBuffer.writeShort(EXPERIMENTER_MISS_CODE); - } - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ExtConstants.EMPTY_LENGTH); - ExperimenterRelatedTableFeatureProperty exp = property. - getAugmentation(ExperimenterRelatedTableFeatureProperty.class); - outBuffer.writeInt(exp.getExperimenter().intValue()); - outBuffer.writeInt(exp.getExpType().intValue()); - byte[] data = exp.getData(); - if (data != null) { - outBuffer.writeBytes(data); - } - int paddingRemainder = (outBuffer.writerIndex() - startIndex) % ExtConstants.PADDING; - if (paddingRemainder != 0) { - int padding = ExtConstants.PADDING - paddingRemainder; - ExtBufferUtils.padBuffer(padding, outBuffer); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java deleted file mode 100644 index 4c878f38..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtBufferUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.util; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; - -/** - * @author michal.polkorab - * - */ -public class ExtBufferUtils { - - /** - * Create OF header - * @param msgType message code - * @param message POJO - * @param out writing buffer - * @param length ofheader length - */ - public static void writeOFHeader(byte msgType, E message, ByteBuf out, int length) { - out.writeByte(message.getVersion()); - out.writeByte(msgType); - out.writeShort(length); - out.writeInt(message.getXid().intValue()); - } - - /** - * Write length standard OF header - * @param out writing buffer - */ - public static void updateOFHeaderLength(ByteBuf out) { - out.setShort(ExtConstants.OFHEADER_LENGTH_INDEX, out.readableBytes()); - } - - /** - * Fills specified ByteBuf with 0 (zeros) of desired length, used for padding - * @param length - * @param out ByteBuf to be padded - */ - public static void padBuffer(int length, ByteBuf out) { - for (int i = 0; i < length; i++) { - out.writeByte(0); - } - } -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java b/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java deleted file mode 100644 index 06f51eb6..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/openflowjava/protocol/ext/util/ExtConstants.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.util; - -/** - * @author michal.polkorab - * - */ -public class ExtConstants { - - /** Default OF padding (in bytes) */ - public static final byte PADDING = 8; - /** OpenFlow v1.0 wire protocol number */ - public static final byte OF10_VERSION_ID = 0x01; - /** OpenFlow v1.0 wire protocol number */ - public static final byte OF13_VERSION_ID = 0x04; - /** Index of length in Openflow header */ - public static final int OFHEADER_LENGTH_INDEX = 2; - /** Zero length - used when the length is updated later */ - public static final int EMPTY_LENGTH = 0; - - /** Length of long in bytes */ - public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE; - /** Length of int in bytes */ - public static final byte SIZE_OF_INT_IN_BYTES = Integer.SIZE / Byte.SIZE; - /** Length of short in bytes */ - public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE; - /** Length of byte in bytes */ - public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE; - /** Length of 3 bytes */ - public static final byte SIZE_OF_3_BYTES = 3; - - /** Common experimenter value */ - public static final int EXPERIMENTER_VALUE = 0xFFFF; - /** OF v1.3 lenght of experimenter_ids - see Multipart TableFeatures (properties) message */ - public static final byte EXPERIMENTER_IDS_LENGTH = 8; -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java deleted file mode 100644 index 86ef8556..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModule.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. -* -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0 which accompanies this distribution, -* and is available at http://www.eclipse.org/legal/epl-v10.html -*/ -package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509; - -import org.opendaylight.openflowjava.protocol.ext.ExtensionRegistrator; - -public class ExtensionRegistratorModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.AbstractExtensionRegistratorModule { - public ExtensionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public ExtensionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.ExtensionRegistratorModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - ExtensionRegistrator registrator = new ExtensionRegistrator(); - registrator.registerDefaultExperimenterSerializers(getOpenflowSwitchConnectionProviderDependency()); - registrator.registerDefaultExperimenterDeserializers(getOpenflowSwitchConnectionProviderDependency()); - return registrator; - } - -} diff --git a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java b/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java deleted file mode 100644 index 139c4921..00000000 --- a/openflow-protocol-ext/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/ext/rev140509/ExtensionRegistratorModuleFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/* -* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. -* -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0 which accompanies this distribution, -* and is available at http://www.eclipse.org/legal/epl-v10.html -*/ -/* -* Generated file -* -* Generated from: yang module name: openflow-ext yang module local name: openflow-ext -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Fri May 09 15:50:56 CEST 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509; -public class ExtensionRegistratorModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.ext.rev140509.AbstractExtensionRegistratorModuleFactory { - -} diff --git a/openflow-protocol-ext/src/main/resources/log4j.xml b/openflow-protocol-ext/src/main/resources/log4j.xml deleted file mode 100644 index a51c5b5b..00000000 --- a/openflow-protocol-ext/src/main/resources/log4j.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/openflow-protocol-ext/src/main/yang/openflow-ext.yang b/openflow-protocol-ext/src/main/yang/openflow-ext.yang deleted file mode 100644 index aa78e3e6..00000000 --- a/openflow-protocol-ext/src/main/yang/openflow-ext.yang +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -module openflow-ext { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:openflow:ext"; - prefix "openflow-ext"; - - import config {prefix config; revision-date 2013-04-05;} - import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} - - - description - "openflow library default extension package"; - - revision "2014-05-09" { - description - "Initial revision"; - } - - identity openflow-ext { - base config:module-type; - config:java-name-prefix ExtensionRegistrator; - } - - augment "/config:modules/config:module/config:configuration" { - case openflow-ext { - when "/config:modules/config:module/config:type = 'openflow-ext'"; - - list openflow-switch-connection-provider { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; - } - } - } - } - } -} \ No newline at end of file diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java deleted file mode 100644 index 0a20e935..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10StatsReplyVendorDeserializerTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsReplyVendorDeserializerTest { - - /** - * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 3, 2, 1, 0}; - buffer.writeBytes(data); - - OF10StatsReplyVendorDeserializer deserializer = - new OF10StatsReplyVendorDeserializer(); - MultipartReplyExperimenter message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getData()); - } - - /** - * Testing of {@link OF10StatsReplyVendorDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(42); - - OF10StatsReplyVendorDeserializer deserializer = - new OF10StatsReplyVendorDeserializer(); - MultipartReplyExperimenter message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong experimenter", 42, message.getExperimenter().intValue()); - Assert.assertNull("Unexpected data", message.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java deleted file mode 100644 index 4894fae1..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorActionDeserializerTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorActionDeserializerTest { - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(16); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF10VendorActionDeserializer deserializer = - new OF10VendorActionDeserializer(); - Action action = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF10VendorActionDeserializer deserializer = - new OF10VendorActionDeserializer(); - Action action = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeader() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF10VendorActionDeserializer deserializer = - new OF10VendorActionDeserializer(); - Action action = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeaderWithData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF10VendorActionDeserializer deserializer = - new OF10VendorActionDeserializer(); - Action action = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java deleted file mode 100644 index 02eb4b0f..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF10VendorMessageDeserializerTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorMessageDeserializerTest { - - /** - * Testing of {@link OF10VendorMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(12345); - buffer.writeInt(98765); - byte[] data = new byte[]{5, 6, 7, 8}; - buffer.writeBytes(data); - - OF10VendorMessageDeserializer deserializer = - new OF10VendorMessageDeserializer(); - ExperimenterMessage message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong version", 1, message.getVersion().shortValue()); - Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); - Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getData()); - } - - /** - * Testing of {@link OF10VendorMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(12345); - buffer.writeInt(98765); - - OF10VendorMessageDeserializer deserializer = - new OF10VendorMessageDeserializer(); - ExperimenterMessage message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong version", 1, message.getVersion().shortValue()); - Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); - Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); - Assert.assertNull("Unexpected data", message.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java deleted file mode 100644 index 3088c2e5..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterActionDeserializerTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterActionDeserializerTest { - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(16); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF13ExperimenterActionDeserializer deserializer = - new OF13ExperimenterActionDeserializer(); - Action action = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF13ExperimenterActionDeserializer deserializer = - new OF13ExperimenterActionDeserializer(); - Action action = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeader() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF13ExperimenterActionDeserializer deserializer = - new OF13ExperimenterActionDeserializer(); - Action action = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterActionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeaderWithData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF13ExperimenterActionDeserializer deserializer = - new OF13ExperimenterActionDeserializer(); - Action action = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, action.getType()); - ExperimenterAction experimenter = action.getAugmentation(ExperimenterAction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java deleted file mode 100644 index 5f3aa96d..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterErrorMessageDeserializerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterErrorMessageDeserializerTest { - - /** - * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(35000); - buffer.writeInt(70000); - byte[] data = new byte[]{5, 5, 5, 6, 7, 8, 9, 10}; - buffer.writeBytes(data); - - OF13ExperimenterErrorMessageDeserializer deserializer = - new OF13ExperimenterErrorMessageDeserializer(); - ExperimenterError message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); - Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getExpData()); - } - - /** - * Testing of {@link OF13ExperimenterErrorMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(35000); - buffer.writeInt(70000); - - OF13ExperimenterErrorMessageDeserializer deserializer = - new OF13ExperimenterErrorMessageDeserializer(); - ExperimenterError message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong exp-type", 35000, message.getExpType().intValue()); - Assert.assertEquals("Wrong experimenter", 70000, message.getExperimenter().intValue()); - Assert.assertNull("Unexpected data", message.getExpData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java deleted file mode 100644 index aed3fac4..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterInstructionDeserializerTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterInstructionDeserializerTest { - - /** - * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF13ExperimenterInstructionDeserializer deserializer = - new OF13ExperimenterInstructionDeserializer(); - Instruction instruction = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); - ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF13ExperimenterInstructionDeserializer deserializer = - new OF13ExperimenterInstructionDeserializer(); - Instruction instruction = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); - ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeader() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - - OF13ExperimenterInstructionDeserializer deserializer = - new OF13ExperimenterInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); - ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } - - /** - * Testing of {@link OF13ExperimenterInstructionDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testHeaderWithData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(8); - buffer.writeInt(42); - byte[] data = new byte[]{0, 1, 2, 3, 4, 0, 0, 0}; - buffer.writeBytes(data); - - OF13ExperimenterInstructionDeserializer deserializer = - new OF13ExperimenterInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - - Assert.assertEquals("Wrong type", Experimenter.class, instruction.getType()); - ExperimenterInstruction experimenter = instruction.getAugmentation(ExperimenterInstruction.class); - Assert.assertEquals("Wrong experimenter", 42, experimenter.getExperimenter().intValue()); - Assert.assertNull("Data not null", experimenter.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java deleted file mode 100644 index c1b0da7a..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13ExperimenterMessageDeserializerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterMessageDeserializerTest { - - /** - * Testing of {@link OF13ExperimenterMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(12345); - buffer.writeInt(98765); - buffer.writeInt(89123); - byte[] data = new byte[]{5, 6, 7, 8}; - buffer.writeBytes(data); - - OF13ExperimenterMessageDeserializer deserializer = - new OF13ExperimenterMessageDeserializer(); - ExperimenterMessage message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong version", 4, message.getVersion().shortValue()); - Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); - Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 89123, message.getExpType().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getData()); - } - - /** - * Testing of {@link OF13ExperimenterMessageDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(12345); - buffer.writeInt(98765); - buffer.writeInt(89123); - - OF13ExperimenterMessageDeserializer deserializer = - new OF13ExperimenterMessageDeserializer(); - ExperimenterMessage message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong version", 4, message.getVersion().shortValue()); - Assert.assertEquals("Wrong XID", 12345, message.getXid().intValue()); - Assert.assertEquals("Wrong experimenter", 98765, message.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 89123, message.getExpType().intValue()); - Assert.assertNull("Unexpected data", message.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java deleted file mode 100644 index dc789a98..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13MultipartReplyExperimenterDeserializerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; - -/** - * @author michal.polkorab - * - */ -public class OF13MultipartReplyExperimenterDeserializerTest { - - /** - * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(456654); - buffer.writeInt(888222); - byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3}; - buffer.writeBytes(data); - - OF13MultipartReplyExperimenterDeserializer deserializer = - new OF13MultipartReplyExperimenterDeserializer(); - MultipartReplyExperimenter message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue()); - Assert.assertArrayEquals("Wrong data", data, message.getData()); - } - - /** - * Testing of {@link OF13MultipartReplyExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeInt(456654); - buffer.writeInt(888222); - - OF13MultipartReplyExperimenterDeserializer deserializer = - new OF13MultipartReplyExperimenterDeserializer(); - MultipartReplyExperimenter message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong experimenter", 456654, message.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 888222, message.getExpType().intValue()); - Assert.assertNull("Unexpected data", message.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java deleted file mode 100644 index 27133e66..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13QueueGetConfigReplyExperimenterDeserializerTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.ext.util.ExtBufferUtils; -import org.opendaylight.openflowjava.protocol.ext.util.ExtConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; - -/** - * @author michal.polkorab - * - */ -public class OF13QueueGetConfigReplyExperimenterDeserializerTest { - - /** - * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(24); - ExtBufferUtils.padBuffer(4, buffer); - buffer.writeInt(128); - ExtBufferUtils.padBuffer(4, buffer); - byte[] data = new byte[]{0, 0, 1, 1, 2, 2, 3, 3}; - buffer.writeBytes(data); - - OF13QueueGetConfigReplyExperimenterDeserializer deserializer = - new OF13QueueGetConfigReplyExperimenterDeserializer(); - QueueProperty message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty()); - ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class); - Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue()); - Assert.assertArrayEquals("Wrong data", data, exp.getData()); - } - - /** - * Testing of {@link OF13QueueGetConfigReplyExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(ExtConstants.EXPERIMENTER_VALUE); - buffer.writeShort(16); - ExtBufferUtils.padBuffer(4, buffer); - buffer.writeInt(128); - ExtBufferUtils.padBuffer(4, buffer); - - OF13QueueGetConfigReplyExperimenterDeserializer deserializer = - new OF13QueueGetConfigReplyExperimenterDeserializer(); - QueueProperty message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong property", QueueProperties.OFPQTEXPERIMENTER, message.getProperty()); - ExperimenterQueueProperty exp = message.getAugmentation(ExperimenterQueueProperty.class); - Assert.assertEquals("Wrong experimenter", 128, exp.getExperimenter().intValue()); - Assert.assertNull("Unexpected data", exp.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java deleted file mode 100644 index e7cb027f..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/deserialization/OF13TableFeaturesExperimenterDeserializerTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class OF13TableFeaturesExperimenterDeserializerTest { - - /** - * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testExperimenter() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(65534); - buffer.writeShort(16); - buffer.writeInt(256); - buffer.writeInt(546); - byte[] data = new byte[]{1, 2, 3, 4}; - buffer.writeBytes(data); - - OF13TableFeaturesExperimenterDeserializer deserializer = - new OF13TableFeaturesExperimenterDeserializer(); - TableFeatureProperties message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTER, message.getType()); - ExperimenterRelatedTableFeatureProperty property = - message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); - Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); - Assert.assertArrayEquals("Wrong data", data, property.getData()); - } - - /** - * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testExperimenterWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(65534); - buffer.writeShort(12); - buffer.writeInt(256); - buffer.writeInt(546); - - OF13TableFeaturesExperimenterDeserializer deserializer = - new OF13TableFeaturesExperimenterDeserializer(); - TableFeatureProperties message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTER, message.getType()); - ExperimenterRelatedTableFeatureProperty property = - message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); - Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); - Assert.assertNull("Unexpected data", property.getData()); - } - - /** - * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testExperimenterMiss() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(65535); - buffer.writeShort(16); - buffer.writeInt(256); - buffer.writeInt(546); - byte[] data = new byte[]{1, 2, 3, 4}; - buffer.writeBytes(data); - - OF13TableFeaturesExperimenterDeserializer deserializer = - new OF13TableFeaturesExperimenterDeserializer(); - TableFeatureProperties message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, message.getType()); - ExperimenterRelatedTableFeatureProperty property = - message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); - Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); - Assert.assertArrayEquals("Wrong data", data, property.getData()); - } - - /** - * Testing of {@link OF13TableFeaturesExperimenterDeserializer} for correct translation into POJO - * @throws Exception - */ - @Test - public void testExperimenterMissWithoutData() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(65535); - buffer.writeShort(12); - buffer.writeInt(256); - buffer.writeInt(546); - - OF13TableFeaturesExperimenterDeserializer deserializer = - new OF13TableFeaturesExperimenterDeserializer(); - TableFeatureProperties message = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong type", TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, message.getType()); - ExperimenterRelatedTableFeatureProperty property = - message.getAugmentation(ExperimenterRelatedTableFeatureProperty.class); - Assert.assertEquals("Wrong experimenter", 256, property.getExperimenter().intValue()); - Assert.assertEquals("Wrong exp-type", 546, property.getExpType().intValue()); - Assert.assertNull("Unexpected data", property.getData()); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java deleted file mode 100644 index 7a55990b..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10StatsRequestVendorSerializerTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestVendorSerializerTest { - - /** - * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() { - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(42L); - byte[] data = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - expBuilder.setData(data); - MultipartRequestExperimenter message = expBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10StatsRequestVendorSerializer serializer = new OF10StatsRequestVendorSerializer(); - serializer.serialize(message, buffer); - - Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); - byte[] expData = new byte[8]; - buffer.readBytes(expData); - Assert.assertArrayEquals("Wrong experimenter data", data, expData); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(42L); - MultipartRequestExperimenter message = expBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10StatsRequestVendorSerializer serializer = new OF10StatsRequestVendorSerializer(); - serializer.serialize(message, buffer); - - Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java deleted file mode 100644 index 130fcc0e..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorActionSerializerTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorActionSerializerTest { - - /** - * Testing of {@link OF10VendorActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testVendorActionWithData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(82L); - byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; - expBuilder.setData(expData); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorActionSerializer serializer = new OF10VendorActionSerializer(); - serializer.serialize(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong data", expData, tmp); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF10VendorActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testVendorActionWithoutData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(102L); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorActionSerializer serializer = new OF10VendorActionSerializer(); - serializer.serialize(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java deleted file mode 100644 index 8c7f1c70..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF10VendorInputMessageFactoryTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10VendorInputMessageFactoryTest { - - /** - * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) 1); - builder.setXid(1024L); - builder.setExperimenter(0x0001020304L); - byte[] data = new byte[]{5, 6, 7, 8}; - builder.setData(data); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); - vendorFactory.serialize(message, out); - - Assert.assertEquals("Wrong version", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong xid", 1024, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - byte[] expData = new byte[4]; - out.readBytes(expData); - Assert.assertArrayEquals("Wrong data", data, expData); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } - - /** - * Testing of {@link OF10VendorInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void testWithoutData() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) 1); - builder.setXid(1024L); - builder.setExperimenter(0x0001020304L); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); - vendorFactory.serialize(message, out); - - Assert.assertEquals("Wrong version", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong xid", 1024, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } -} \ No newline at end of file diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java deleted file mode 100644 index e7cb7e76..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterActionSerializerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterActionSerializerTest { - - /** - * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testVendorActionWithData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(82L); - byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; - expBuilder.setData(expData); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); - serializer.serialize(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong data", expData, tmp); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testVendorActionWithoutData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(102L); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); - serializer.serialize(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testHeaderWithData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(82L); - byte[] expData = new byte[]{0, 0, 0, 0, 0, 0, 0, 1}; - expBuilder.setData(expData); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); - serializer.serializeHeader(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 82, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterActionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testHeaderWithoutData() { - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); - expBuilder.setExperimenter(102L); - actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); - Action action = actionBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterActionSerializer serializer = new OF13ExperimenterActionSerializer(); - serializer.serializeHeader(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 102, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java deleted file mode 100644 index ba0bbf4a..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInputMessageFactoryTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterInputMessageFactoryTest { - - /** - * Testing of {@link OF13ExperimenterInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) 4); - builder.setXid(888L); - builder.setExperimenter(0x0001020304L); - byte[] data = new byte[]{5, 6, 7, 8}; - builder.setData(data); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); - vendorFactory.serialize(message, out); - - Assert.assertEquals("Wrong version", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong xid", 888, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - byte[] expData = new byte[4]; - out.readBytes(expData); - Assert.assertArrayEquals("Wrong data", data, expData); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterInputMessageFactory} for correct translation from POJO - * @throws Exception - */ - @Test - public void testWithoutData() throws Exception { - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) 4); - builder.setXid(888L); - builder.setExperimenter(0x0001020304L); - ExperimenterInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF10VendorInputMessageFactory vendorFactory = new OF10VendorInputMessageFactory(); - vendorFactory.serialize(message, out); - - Assert.assertEquals("Wrong version", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong type", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong xid", 888, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter", 0x0001020304L, out.readUnsignedInt()); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java deleted file mode 100644 index cf01dffc..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13ExperimenterInstructionSerializerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ExperimenterInstructionSerializerTest { - - /** - * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() { - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(Experimenter.class); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(142L); - byte[] data = new byte[]{1, 2, 3, 4, 5, 6, 7, 8}; - expBuilder.setData(data); - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - Instruction instruction = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); - serializer.serialize(instruction, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); - byte[] expData = new byte[8]; - buffer.readBytes(expData); - Assert.assertArrayEquals("Wrong experimenter data", data, expData); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(Experimenter.class); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(142L); - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - Instruction instruction = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); - serializer.serialize(instruction, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testHeader() { - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(Experimenter.class); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(142L); - byte[] data = new byte[]{1, 2, 3, 4, 5, 6, 7, 8}; - expBuilder.setData(data); - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - Instruction instruction = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); - serializer.serializeHeader(instruction, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13ExperimenterInstructionSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testHeaderWithoutData() { - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(Experimenter.class); - ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); - expBuilder.setExperimenter(142L); - builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); - Instruction instruction = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13ExperimenterInstructionSerializer serializer = new OF13ExperimenterInstructionSerializer(); - serializer.serializeHeader(instruction, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 142, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java deleted file mode 100644 index 7cc5b493..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MeterBandExperimenterSerializerTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13MeterBandExperimenterSerializerTest { - - /** - * Testing of {@link OF13MeterBandExperimenterSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() { - MeterBandExperimenterBuilder builder = new MeterBandExperimenterBuilder(); - builder.setType(MeterBandType.OFPMBTEXPERIMENTER); - builder.setRate(128L); - builder.setBurstSize(256L); - builder.setExperimenter(512L); - MeterBandExperimenter band = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13MeterBandExperimenterSerializer serializer = new OF13MeterBandExperimenterSerializer(); - serializer.serialize(band, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong type", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong type", 128, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong type", 256, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong type", 512, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java deleted file mode 100644 index aa332ab4..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13MultipartExperimenterSerializerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13MultipartExperimenterSerializerTest { - - /** - * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void test() { - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(42L); - expBuilder.setExpType(84L); - byte[] data = new byte[]{0, 1, 2, 3, 4, 5, 6, 7}; - expBuilder.setData(data); - MultipartRequestExperimenter message = expBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13MultipartExperimenterSerializer serializer = new OF13MultipartExperimenterSerializer(); - serializer.serialize(message, buffer); - - Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 84, buffer.readUnsignedInt()); - byte[] expData = new byte[8]; - buffer.readBytes(expData); - Assert.assertArrayEquals("Wrong experimenter data", data, expData); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF10StatsRequestVendorSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testWithoutData() { - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - expBuilder.setExperimenter(42L); - expBuilder.setExpType(84L); - MultipartRequestExperimenter message = expBuilder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13MultipartExperimenterSerializer serializer = new OF13MultipartExperimenterSerializer(); - serializer.serialize(message, buffer); - - Assert.assertEquals("Wrong experimenter", 42, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 84, buffer.readUnsignedInt()); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } -} diff --git a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java b/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java deleted file mode 100644 index cee23f6a..00000000 --- a/openflow-protocol-ext/src/test/java/org/opendaylight/openflowjava/protocol/ext/serialization/OF13TableFeatExpSerializerTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.ext.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13TableFeatExpSerializerTest { - - /** - * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testExperimenter() { - TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); - builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); - ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - propBuilder.setExperimenter(891L); - propBuilder.setExpType(6546L); - byte[] data = new byte[]{0, 1, 2, 3}; - propBuilder.setData(data); - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, - propBuilder.build()); - TableFeatureProperties property = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); - serializer.serialize(property, buffer); - - Assert.assertEquals("Wrong type", 65534, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 891, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 6546, buffer.readUnsignedInt()); - byte[] expData = new byte[4]; - buffer.readBytes(expData); - Assert.assertArrayEquals("Wrong experimenter data", data, expData); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testExperimenterWithoutData() { - TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); - builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); - ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - propBuilder.setExperimenter(891L); - propBuilder.setExpType(6546L); - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, - propBuilder.build()); - TableFeatureProperties property = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); - serializer.serialize(property, buffer); - - Assert.assertEquals("Wrong type", 65534, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 891, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 6546, buffer.readUnsignedInt()); - buffer.skipBytes(4); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testExperimenterMiss() { - TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); - builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); - ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - propBuilder.setExperimenter(8L); - propBuilder.setExpType(6L); - byte[] data = new byte[]{4, 5, 6, 7}; - propBuilder.setData(data); - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, - propBuilder.build()); - TableFeatureProperties property = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); - serializer.serialize(property, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 8, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 6, buffer.readUnsignedInt()); - byte[] expData = new byte[4]; - buffer.readBytes(expData); - Assert.assertArrayEquals("Wrong experimenter data", data, expData); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Testing of {@link OF13TableFeatExpSerializer} for correct translation from POJO - * @throws Exception - */ - @Test - public void testExperimenterMissWithoutData() { - TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); - builder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); - ExperimenterRelatedTableFeaturePropertyBuilder propBuilder = - new ExperimenterRelatedTableFeaturePropertyBuilder(); - propBuilder.setExperimenter(8L); - propBuilder.setExpType(6L); - builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, - propBuilder.build()); - TableFeatureProperties property = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - OF13TableFeatExpSerializer serializer = new OF13TableFeatExpSerializer(); - serializer.serialize(property, buffer); - - Assert.assertEquals("Wrong type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong experimenter", 8, buffer.readUnsignedInt()); - Assert.assertEquals("Wrong exp-type", 6, buffer.readUnsignedInt()); - buffer.skipBytes(4); - Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - } -} diff --git a/pom.xml b/pom.xml index b691ee2e..05862144 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,6 @@ openflow-protocol-it feature simple-client - openflow-protocol-ext scm:git:ssh://git.opendaylight.org:29418/openflowjava.git From aaa45cd667863c40ca9abd797a794f34c243310a Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 16 Jul 2014 14:17:52 +0200 Subject: [PATCH 023/285] Created special extension keys for more easier (de)serializer (un)registration - these keys don't need special types in their constructors, because they always use the same type (e.g. Experimenter.class) - also created two marker interfaces (Experimenter(De)SerializerKey) to mark appropriate extension keys Signed-off-by: Michal Polkorab --- .../keys/ActionDeserializerKey.java | 2 +- .../keys/ActionSerializerKey.java | 2 +- .../keys/InstructionDeserializerKey.java | 2 +- .../keys/InstructionSerializerKey.java | 2 +- .../keys/MatchEntryDeserializerKey.java | 6 +- .../keys/MatchEntrySerializerKey.java | 7 ++- .../ExperimenterActionDeserializerKey.java | 53 ++++++++++++++++ .../ExperimenterActionSerializerKey.java | 61 ++++++++++++++++++ .../ExperimenterDeserializerKey.java | 17 +++++ ...xperimenterInstructionDeserializerKey.java | 53 ++++++++++++++++ .../ExperimenterInstructionSerializerKey.java | 62 +++++++++++++++++++ .../ExperimenterSerializerKey.java | 17 +++++ .../SwitchConnectionProviderImpl.java | 18 +++--- .../OF13SetFieldActionDeserializer.java | 2 +- .../action/OF13SetFieldActionSerializer.java | 2 +- .../MultipartRequestInputFactory.java | 2 +- .../ActionDeserializerRegistryHelper.java | 2 +- .../util/ActionSerializerRegistryHelper.java | 2 +- .../impl/util/CodeKeyMakerFactory.java | 6 +- ...InstructionDeserializerRegistryHelper.java | 2 +- .../InstructionSerializerRegistryHelper.java | 2 +- .../MatchEntryDeserializerRegistryHelper.java | 2 +- .../MatchEntrySerializerRegistryHelper.java | 2 +- .../impl/util/OF13MatchSerializer.java | 2 +- .../impl/util/TypeKeyMakerFactory.java | 6 +- .../impl/util/MatchDeserializerTest.java | 2 +- .../connection/SwitchConnectionProvider.java | 12 ++-- 27 files changed, 308 insertions(+), 40 deletions(-) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/ActionDeserializerKey.java (92%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/ActionSerializerKey.java (94%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/InstructionDeserializerKey.java (93%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/InstructionSerializerKey.java (94%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/MatchEntryDeserializerKey.java (85%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => }/keys/MatchEntrySerializerKey.java (86%) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java similarity index 92% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index f345c3bf..d329e7ef 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java similarity index 94% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 3956108e..623bdea4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java similarity index 93% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index ec4cc0bb..95a5715b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java similarity index 94% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index dee43ee8..738156a0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java similarity index 85% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index 6403a4d9..bf703561 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -6,16 +6,18 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** * @author michal.polkorab * */ -public class MatchEntryDeserializerKey extends MessageCodeKey { +public class MatchEntryDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { private int oxmField; private Long experimenterId; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java similarity index 86% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index e71ddb49..a367d535 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -6,9 +6,10 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility.keys; +package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; @@ -18,8 +19,8 @@ * @param oxm_class (see specification) * @param oxm_field (see specification) */ -public class MatchEntrySerializerKey extends MessageTypeKey{ +public class MatchEntrySerializerKey + extends MessageTypeKey implements ExperimenterSerializerKey{ private Class oxmClass; private Class oxmField; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java new file mode 100644 index 00000000..1b21379e --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterActionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, Action.class); + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ExperimenterActionDeserializerKey other = (ExperimenterActionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java new file mode 100644 index 00000000..23e4640c --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + */ +public class ExperimenterActionSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { + + private Class actionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) { + super(msgVersion, Action.class); + this.actionType = Experimenter.class; + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; + if (actionType == null) { + if (other.actionType != null) + return false; + } else if (!actionType.equals(other.actionType)) + return false; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java new file mode 100644 index 00000000..2b73858d --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter deserializer registration + * @author michal.polkorab + */ +public interface ExperimenterDeserializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java new file mode 100644 index 00000000..12270310 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param experimenterId + */ + public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, Instruction.class); + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ExperimenterInstructionDeserializerKey other = (ExperimenterInstructionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java new file mode 100644 index 00000000..0a4541b1 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + */ +public class ExperimenterInstructionSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { + + private Class instructionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { + super(msgVersion, Instruction.class); + this.instructionType = Experimenter.class; + this.experimenterId = experimenterId; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ExperimenterInstructionSerializerKey other = (ExperimenterInstructionSerializerKey) obj; + if (instructionType == null) { + if (other.instructionType != null) + return false; + } else if (!instructionType.equals(other.instructionType)) + return false; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " instructionType type: " + instructionType.getName() + + " vendorID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java new file mode 100644 index 00000000..a99990fe --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter serializer registration + * @author michal.polkorab + */ +public interface ExperimenterSerializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 0bab56a5..1ef55517 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -17,6 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializerFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; @@ -129,15 +131,15 @@ public ServerFacade getServerFacade() { } @Override - public void registerSerializer(MessageTypeKey key, + public void registerSerializer(ExperimenterSerializerKey key, OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(key, serializer); + serializerRegistry.registerSerializer((MessageTypeKey) key, serializer); } @Override - public void registerDeserializer(MessageCodeKey key, + public void registerDeserializer(ExperimenterDeserializerKey key, OFGeneralDeserializer deserializer) { - deserializerRegistry.registerDeserializer(key, deserializer); + deserializerRegistry.registerDeserializer((MessageCodeKey) key, deserializer); } @Override @@ -146,12 +148,12 @@ public void close() throws Exception { } @Override - public boolean unregisterSerializer(MessageTypeKey key) { - return serializerRegistry.unregisterSerializer(key); + public boolean unregisterSerializer(ExperimenterSerializerKey key) { + return serializerRegistry.unregisterSerializer((MessageTypeKey) key); } @Override - public boolean unregisterDeserializer(MessageCodeKey key) { - return deserializerRegistry.unregisterDeserializer(key); + public boolean unregisterDeserializer(ExperimenterDeserializerKey key) { + return deserializerRegistry.unregisterDeserializer((MessageCodeKey) key); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index e50baa4c..0182e8c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -16,7 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 86fb3212..94fd3736 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 29cc5898..4c174c8f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java index 13b9f915..a3fb7113 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index 48382ad1..d941f547 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index d2eabddd..0fab1ad9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -11,9 +11,9 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java index 211bf158..2b4ea9da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index 5c111088..3ee13cb8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index 0acb4686..e9e1c10e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index d3be60a4..21e30ece 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -9,7 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index d37c0a2b..8bc2632e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 13d68da9..4ba9294b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index b5ce1806..b0db8353 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index 8bae5c06..97a2948d 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -11,10 +11,10 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import com.google.common.util.concurrent.ListenableFuture; @@ -53,7 +53,7 @@ public interface SwitchConnectionProvider extends AutoCloseable { * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerSerializer(MessageTypeKey key, + public void registerSerializer(ExperimenterSerializerKey key, OFGeneralSerializer serializer); /** @@ -61,7 +61,7 @@ public void registerSerializer(MessageTypeKey key, * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer); + public void registerDeserializer(ExperimenterDeserializerKey key, OFGeneralDeserializer deserializer); /** * Unregisters custom serializer @@ -70,7 +70,7 @@ public void registerSerializer(MessageTypeKey key, * @return true if serializer was removed, * false if no serializer was found under specified key */ - public boolean unregisterSerializer(MessageTypeKey key); + public boolean unregisterSerializer(ExperimenterSerializerKey key); /** * Unregisters custom deserializer @@ -79,5 +79,5 @@ public void registerSerializer(MessageTypeKey key, * @return true if deserializer was removed, * false if no deserializer was found under specified key */ - public boolean unregisterDeserializer(MessageCodeKey key); + public boolean unregisterDeserializer(ExperimenterDeserializerKey key); } From 4892efadc4ef9a61831828bddfe0e939b4334779 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 17 Jul 2014 12:21:38 +0200 Subject: [PATCH 024/285] Bug 1373 - Fixed NullPointerException on incorrect input - now throws IllegalArgumentException. This is just logged and pushed into Future, the Future delegates the information further to upper ODL layers Change-Id: I64ac1e4904e8837ab5b26572235bdaf5fac984da Signed-off-by: Michal Polkorab --- .../impl/connection/ChannelOutboundQueue.java | 2 +- .../connection/MessageListenerWrapper.java | 50 +++++++++++++++++++ .../protocol/impl/core/OFEncoder.java | 14 +++--- .../DeserializerRegistryImpl.java | 6 +-- .../serialization/SerializerRegistryImpl.java | 9 ++-- .../protocol/impl/core/OFEncoderTest.java | 20 ++++++-- 6 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java index 765a9794..40af2791 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java @@ -180,8 +180,8 @@ private synchronized void flush() { break; } - final ChannelFuture p = channel.write(h.takeMessage()); final GenericFutureListener> l = h.takeListener(); + final ChannelFuture p = channel.write(new MessageListenerWrapper(h.takeMessage(), l)); if (l != null) { p.addListener(l); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java new file mode 100644 index 00000000..68311d23 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * @author michal.polkorab + */ +public class MessageListenerWrapper { + + private OfHeader msg; + private GenericFutureListener> listener; + + /** + * @param msg outgoing message + * @param listener listener attached to channel.write(msg) Future + */ + public MessageListenerWrapper(Object msg, GenericFutureListener> listener) { + this.msg = (OfHeader) msg; + this.listener = listener; + } + + /** + * @return outgoing message (downstream) + */ + public OfHeader getMsg() { + return msg; + } + + + /** + * @return listener listening on message sending success / failure + */ + public GenericFutureListener> getListener() { + return listener; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index c93f1fcf..6080003f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -11,9 +11,10 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; +import io.netty.util.concurrent.Future; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,7 +23,7 @@ * @author michal.polkorab * @author timotej.kubas */ -public class OFEncoder extends MessageToByteEncoder { +public class OFEncoder extends MessageToByteEncoder { private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class); private SerializationFactory serializationFactory; @@ -33,14 +34,15 @@ public OFEncoder() { } @Override - protected void encode(ChannelHandlerContext ctx, OfHeader msg, ByteBuf out) + protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, ByteBuf out) throws Exception { LOGGER.trace("Encoding"); try { - serializationFactory.messageToBuffer(msg.getVersion(), out, msg); + serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); } catch(Exception e) { - LOGGER.error("Message serialization failed"); - LOGGER.error(e.getMessage(), e); + LOGGER.warn("Message serialization failed: {}", e.getMessage()); + Future newFailedFuture = ctx.newFailedFuture(e); + wrapper.getListener().operationComplete(newFailedFuture); out.clear(); return; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index f78dbb85..a1efd1dc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -59,7 +59,7 @@ public DESERIALIZER_TYPE getDe OFGeneralDeserializer deserializer = registry.get(key); if (deserializer == null) { throw new NullPointerException("Deserializer for key: " + key.toString() - + " was not found"); + + " was not found - please verify that all needed deserializers ale loaded correctly"); } return (DESERIALIZER_TYPE) deserializer; } @@ -68,7 +68,7 @@ public DESERIALIZER_TYPE getDe public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) { if ((key == null) || (deserializer == null)) { - throw new NullPointerException("MessageCodeKey or Deserializer is null"); + throw new IllegalArgumentException("MessageCodeKey or Deserializer is null"); } if (deserializer instanceof DeserializerRegistryInjector) { ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this); @@ -79,7 +79,7 @@ public void registerDeserializer(MessageCodeKey key, @Override public boolean unregisterDeserializer(MessageCodeKey key) { if (key == null) { - throw new NullPointerException("MessageCodeKey is null"); + throw new IllegalArgumentException("MessageCodeKey is null"); } OFGeneralDeserializer deserializer = registry.remove(key); if (deserializer == null) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 47b2d4a5..e8a02bd7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -61,8 +61,9 @@ public SERIALIZER_TYPE g MessageTypeKey msgTypeKey) { OFGeneralSerializer serializer = registry.get(msgTypeKey); if (serializer == null) { - throw new NullPointerException("Serializer for key: " + msgTypeKey.toString() - + " was not found"); + throw new IllegalArgumentException("Serializer for key: {}" + msgTypeKey.toString() + + " was not found - please verify that you are using correct message" + + " combination (e.g. OF v1.0 message to OF v1.0 device)"); } return (SERIALIZER_TYPE) serializer; } @@ -71,7 +72,7 @@ public SERIALIZER_TYPE g public void registerSerializer( MessageTypeKey msgTypeKey, OFGeneralSerializer serializer) { if ((msgTypeKey == null) || (serializer == null)) { - throw new NullPointerException("MessageTypeKey or Serializer is null"); + throw new IllegalArgumentException("MessageTypeKey or Serializer is null"); } if (serializer instanceof SerializerRegistryInjector) { ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this); @@ -82,7 +83,7 @@ public void registerSerializer( @Override public boolean unregisterSerializer(MessageTypeKey msgTypeKey) { if (msgTypeKey == null) { - throw new NullPointerException("MessageTypeKey is null"); + throw new IllegalArgumentException("MessageTypeKey is null"); } OFGeneralSerializer serializer = registry.remove(msgTypeKey); if (serializer == null) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java index 11d2098a..9cb7dca0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java @@ -16,12 +16,16 @@ import static org.mockito.Mockito.when; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -34,8 +38,11 @@ public class OFEncoderTest { @Mock ChannelHandlerContext mockChHndlrCtx ; @Mock SerializationFactory mockSerializationFactory ; + @Mock MessageListenerWrapper wrapper; @Mock OfHeader mockMsg ; @Mock ByteBuf mockOut ; + @Mock Future future; + @Mock GenericFutureListener> listener; OFEncoder ofEncoder = new OFEncoder() ; @@ -55,8 +62,10 @@ public void setUp() { @Test public void testEncodeSuccess() { when(mockOut.readableBytes()).thenReturn(1); + when(wrapper.getMsg()).thenReturn(mockMsg); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); try { - ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); } catch (Exception e) { Assert.fail(); } @@ -70,9 +79,12 @@ public void testEncodeSuccess() { */ @Test public void testEncodeSerializationException() { + when(wrapper.getMsg()).thenReturn(mockMsg); + when(wrapper.getListener()).thenReturn(listener); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); doThrow(new IllegalArgumentException()).when(mockSerializationFactory).messageToBuffer(anyShort(),any(ByteBuf.class), any(DataObject.class)); try { - ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); } catch (Exception e) { Assert.fail(); } @@ -87,8 +99,10 @@ public void testEncodeSerializationException() { @Test public void testEncodeSerializesNoBytes() { when(mockOut.readableBytes()).thenReturn(0); + when(wrapper.getMsg()).thenReturn(mockMsg); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); try { - ofEncoder.encode(mockChHndlrCtx, mockMsg, mockOut); + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); } catch (Exception e) { Assert.fail(); } From 138faab735adbfe386941d9302853dd6b20c31be Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 17 Jul 2014 16:34:19 +0200 Subject: [PATCH 025/285] Renamed base identity for match oxm_classes - renamed from "Clazz" to "OxmClassBase" Signed-off-by: Michal Polkorab --- .../protocol/api/keys/MatchEntrySerializerKey.java | 4 ++-- .../src/main/yang/openflow-extensible-match.yang | 12 ++++++------ .../match/AbstractOxmMatchEntryDeserializer.java | 6 +++--- .../match/NxmTcpFlagDeserializer.java | 5 +++-- .../match/NxmTunnelIpv4DstDeserializer.java | 4 ++-- .../match/NxmTunnelIpv4SrcDeserializer.java | 4 ++-- .../deserialization/match/OxmArpOpDeserializer.java | 4 ++-- .../deserialization/match/OxmArpShaDeserializer.java | 4 ++-- .../deserialization/match/OxmArpSpaDeserializer.java | 4 ++-- .../deserialization/match/OxmArpThaDeserializer.java | 4 ++-- .../deserialization/match/OxmArpTpaDeserializer.java | 4 ++-- .../deserialization/match/OxmEthDstDeserializer.java | 4 ++-- .../deserialization/match/OxmEthSrcDeserializer.java | 4 ++-- .../match/OxmEthTypeDeserializer.java | 4 ++-- .../match/OxmIcmpv4CodeDeserializer.java | 4 ++-- .../match/OxmIcmpv4TypeDeserializer.java | 4 ++-- .../match/OxmIcmpv6CodeDeserializer.java | 4 ++-- .../match/OxmIcmpv6TypeDeserializer.java | 4 ++-- .../match/OxmInPhyPortDeserializer.java | 4 ++-- .../deserialization/match/OxmInPortDeserializer.java | 4 ++-- .../deserialization/match/OxmIpDscpDeserializer.java | 6 +++--- .../deserialization/match/OxmIpEcnDeserializer.java | 4 ++-- .../match/OxmIpProtoDeserializer.java | 4 ++-- .../match/OxmIpv4DstDeserializer.java | 4 ++-- .../match/OxmIpv4SrcDeserializer.java | 4 ++-- .../match/OxmIpv6DstDeserializer.java | 4 ++-- .../match/OxmIpv6ExtHdrDeserializer.java | 4 ++-- .../match/OxmIpv6FlabelDeserializer.java | 4 ++-- .../match/OxmIpv6NdSllDeserializer.java | 4 ++-- .../match/OxmIpv6NdTargetDeserializer.java | 4 ++-- .../match/OxmIpv6NdTllDeserializer.java | 4 ++-- .../match/OxmIpv6SrcDeserializer.java | 4 ++-- .../match/OxmMetadataDeserializer.java | 4 ++-- .../match/OxmMplsBosDeserializer.java | 4 ++-- .../match/OxmMplsLabelDeserializer.java | 4 ++-- .../deserialization/match/OxmMplsTcDeserializer.java | 4 ++-- .../match/OxmPbbIsidDeserializer.java | 4 ++-- .../match/OxmSctpDstDeserializer.java | 4 ++-- .../match/OxmSctpSrcDeserializer.java | 4 ++-- .../deserialization/match/OxmTcpDstDeserializer.java | 4 ++-- .../deserialization/match/OxmTcpSrcDeserializer.java | 4 ++-- .../match/OxmTunnelIdDeserializer.java | 4 ++-- .../deserialization/match/OxmUdpDstDeserializer.java | 4 ++-- .../deserialization/match/OxmUdpSrcDeserializer.java | 4 ++-- .../match/OxmVlanPcpDeserializer.java | 4 ++-- .../match/OxmVlanVidDeserializer.java | 4 ++-- .../util/MatchEntrySerializerRegistryHelper.java | 4 ++-- 47 files changed, 101 insertions(+), 100 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index a367d535..8ceb7ccb 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -10,8 +10,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** @@ -19,7 +19,7 @@ * @param oxm_class (see specification) * @param oxm_field (see specification) */ -public class MatchEntrySerializerKey +public class MatchEntrySerializerKey extends MessageTypeKey implements ExperimenterSerializerKey{ private Class oxmClass; diff --git a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang index ff3960aa..e265eb09 100644 --- a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang +++ b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang @@ -26,27 +26,27 @@ } // oxm classes - identity clazz { + identity oxm-class-base { description "Base identity for OXM classes"; } identity nxm-0-class { description "Match class for backward compatibility with NXM"; - base clazz; + base oxm-class-base; } identity nxm-1-class { description "Match class for backward compatibility with NXM"; - base clazz; + base oxm-class-base; } identity openflow-basic-class { description "Basic class for OpenFlow"; - base clazz; + base oxm-class-base; } identity experimenter-class { description "Marks Experimenter match type class. All experimenter match classes MUST use this class as a base."; - base clazz; + base oxm-class-base; } // field types @@ -236,7 +236,7 @@ config false; leaf oxm-class { type identityref { - base clazz; + base oxm-class-base; } } leaf oxm-match-field { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index 62c7a507..635cc757 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -36,7 +36,7 @@ public MatchEntries deserializeHeader(ByteBuf input) { /** * @return oxm_class class */ - protected abstract Class getOxmClass(); + protected abstract Class getOxmClass(); /** * Prepares match entry header - sets oxm_class, oxm_field, hasMask @@ -47,7 +47,7 @@ public MatchEntries deserializeHeader(ByteBuf input) { * @param input input bytebuf * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation */ - protected MatchEntriesBuilder processHeader(Class oxm_class, + protected MatchEntriesBuilder processHeader(Class oxm_class, Class oxm_field, ByteBuf input) { MatchEntriesBuilder builder = new MatchEntriesBuilder(); builder.setOxmClass(oxm_class); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java index 4295219e..41fde206 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java @@ -9,11 +9,12 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +47,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return Nxm1Class.class; } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java index 5aa38190..bca1b885 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return Nxm1Class.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java index 0d415f63..b081df9f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return Nxm1Class.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java index dc01fbc8..c2532ab0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java @@ -13,9 +13,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -45,7 +45,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java index a4f97508..09744aca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java index 8c750fec..8d99b44d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java index c3c7771e..cba0642e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java index a8039f56..dddb3ef4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java index bb80686b..257fde06 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java index 216b7bf3..ebcd01f8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java index e1c4eb74..ce4ea0c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java @@ -13,10 +13,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java index a52885a5..c0df85bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java index 5b3c3dbe..05f81a3f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java index 2c3bd5fc..930a4b31 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java index 5d47823c..11f9336c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -41,7 +41,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java index dfb050a1..d9685796 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java index 3bc97ee8..4f9af4fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index decbe54f..eb92d143 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -9,16 +9,16 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; /** * @author michal.polkorab @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java index de06e65f..7a534756 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -45,7 +45,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java index 52314f5f..f99ecba8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -45,7 +45,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java index 98b924d8..ae63c9d6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java index e24720e0..b03ca001 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java index e4599a0e..f4170d8c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index c14e69c4..e4925d47 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -14,10 +14,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -61,7 +61,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index 50e51b42..bcb7643e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -14,10 +14,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -51,7 +51,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java index 053b36fd..9e9c5ab4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java index 0a47593b..01c7dc8c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java index ea7d4c62..9b7f4b80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java index 8135b81e..bb7942a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java index 7bbc6ebb..b5dcf47c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java index ad39e04e..3fbd2ea0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -51,7 +51,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java index 794f6ea7..fdc657a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java index 22ed95ed..f7a06339 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java @@ -12,10 +12,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -46,7 +46,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java index 2cc2ed45..f6378763 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java @@ -13,9 +13,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -51,7 +51,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index 074eaf3d..e608ea63 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index ea5e3b4f..03e9bf91 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index cb8faba9..3a2f1612 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index 9d357c94..5d213431 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java index 0947e513..bba63ca5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index f95e4b5c..201266e1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index 6690268b..626d9d40 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; /** @@ -24,7 +24,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java index 35bd4201..0600d296 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java @@ -12,9 +12,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -45,7 +45,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index 6e7de9b7..7ba99e2b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -13,9 +13,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -51,7 +51,7 @@ protected Class getOxmField() { } @Override - protected Class getOxmClass() { + protected Class getOxmClass() { return OpenflowBasicClass.class; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 21e30ece..0bbd6ab9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -10,14 +10,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; /** * @author michal.polkorab * @param OXM class */ -public class MatchEntrySerializerRegistryHelper { +public class MatchEntrySerializerRegistryHelper { private short version; private Class generalClass; From 98724fe469dfe7823b66da14c6f90459ff871d27 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 17 Jul 2014 16:00:45 +0200 Subject: [PATCH 026/285] Simplified extension registration (part1) - introduced methods for match, action and instruction registration - other extension method will be added in part2 Change-Id: I928833e8df6d4a9037fea480ddef4d54d4ac46a6 Signed-off-by: Michal Polkorab --- .../SwitchConnectionProviderImpl.java | 44 ++++++++++++++ .../connection/SwitchConnectionProvider.java | 58 ++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 1ef55517..a6d15792 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -17,7 +17,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializerFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; @@ -26,6 +32,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -156,4 +164,40 @@ public boolean unregisterSerializer(ExperimenterSerializerKey key) { public boolean unregisterDeserializer(ExperimenterDeserializerKey key) { return deserializerRegistry.unregisterDeserializer((MessageCodeKey) key); } + + @Override + public void registerActionSerializer(ExperimenterActionSerializerKey key, + OFGeneralSerializer serializer) { + registerSerializer(key, serializer); + } + + @Override + public void registerActionDeserializer(ExperimenterActionDeserializerKey key, + OFGeneralDeserializer deserializer) { + registerDeserializer(key, deserializer); + } + + @Override + public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + OFGeneralSerializer serializer) { + registerSerializer(key, serializer); + } + + @Override + public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + OFGeneralDeserializer deserializer) { + registerDeserializer(key, deserializer); + } + + @Override + public void registerMatchEntrySerializer(MatchEntrySerializerKey key, + OFGeneralSerializer serializer) { + registerSerializer(key, serializer); + } + + @Override + public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + OFGeneralDeserializer deserializer) { + registerDeserializer(key, deserializer); + } } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index 97a2948d..ad7d741d 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -13,8 +13,16 @@ import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import com.google.common.util.concurrent.ListenableFuture; @@ -66,7 +74,6 @@ public void registerSerializer(ExperimenterSerializerKey key, /** * Unregisters custom serializer * @param key used for serializer lookup - * @param serializer serializer implementation * @return true if serializer was removed, * false if no serializer was found under specified key */ @@ -75,9 +82,56 @@ public void registerSerializer(ExperimenterSerializerKey key, /** * Unregisters custom deserializer * @param key used for deserializer lookup - * @param deserializer deserializer instance * @return true if deserializer was removed, * false if no deserializer was found under specified key */ public boolean unregisterDeserializer(ExperimenterDeserializerKey key); + + /** + * Registers action serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerActionSerializer(ExperimenterActionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers action deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerActionDeserializer(ExperimenterActionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers instruction serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers instruction deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers match entry serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); + + /** + * Registers match entry deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + OFGeneralDeserializer deserializer); } From cd45764e40ef43a4a43979b3e8f04e8b0865739f Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 4 Jul 2014 15:48:35 +0200 Subject: [PATCH 027/285] Extracted (De)SerializerExtensionProvider interfaces from SwitchConnectionProvider Signed-off-by: Michal Polkorab --- .../DeserializerExtensionProvider.java | 53 ++++++++++ .../extensibility/DeserializerRegistry.java | 11 ++- .../SerializerExtensionProvider.java | 56 +++++++++++ .../api/extensibility/SerializerRegistry.java | 16 +-- .../SwitchConnectionProviderImpl.java | 26 ++--- .../connection/SwitchConnectionProvider.java | 97 +------------------ 6 files changed, 136 insertions(+), 123 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java new file mode 100644 index 00000000..b821b168 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; + +/** + * Provides methods for deserialization part of extensibility + * @author michal.polkorab + */ +public interface DeserializerExtensionProvider { + + /** + * Unregisters custom deserializer + * @param key used for deserializer lookup + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + public boolean unregisterDeserializer(ExperimenterDeserializerKey key); + + /** + * Registers action deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerActionDeserializer(ExperimenterActionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers instruction deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers match entry deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + OFGeneralDeserializer deserializer); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 4266ab54..4afa95ae 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -27,15 +27,16 @@ public interface DeserializerRegistry { SERIALIZER_TYPE getDeserializer(MessageCodeKey key); /** - * Registers deserializer under key - * @param key used to registry lookup + * Registers deserializer + * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer); + public void registerDeserializer(MessageCodeKey key, + OFGeneralDeserializer deserializer); /** - * Unregisters deserializer under key - * @param key used to registry lookup + * Unregisters deserializer + * @param key used for deserializer lookup * @param deserializer deserializer instance * @return true if deserializer was removed, * false if no deserializer was found under specified key diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java new file mode 100644 index 00000000..025e3c2c --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + + +/** + * Provides methods for serialization part of extensibility + * @author michal.polkorab + */ +public interface SerializerExtensionProvider { + + /** + * Unregisters custom serializer + * @param key used for serializer lookup + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + public boolean unregisterSerializer(ExperimenterSerializerKey key); + + /** + * Registers action serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerActionSerializer(ExperimenterActionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers instruction serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers match entry serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 83b4ae8d..bf25a609 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; + + /** * Stores and handles serializers * @author michal.polkorab @@ -28,19 +30,19 @@ public interface SerializerRegistry { getSerializer(MessageTypeKey msgTypeKey); /** - * Registers serializer under key - * @param msgTypeKey lookup key + * Registers serializer + * @param key used for serializer lookup * @param serializer serializer implementation */ - public void - registerSerializer(MessageTypeKey msgTypeKey, OFGeneralSerializer serializer); + public void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer); /** - * Unregisters serializer under key - * @param msgTypeKey lookup key + * Unregisters serializer + * @param key used for serializer lookup * @param serializer serializer implementation * @return true if serializer was removed, * false if no serializer was found under specified key */ - public boolean unregisterSerializer(MessageTypeKey msgTypeKey); + public boolean unregisterSerializer(MessageTypeKey key); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index a6d15792..39a9829b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -138,18 +138,6 @@ public ServerFacade getServerFacade() { return serverFacade; } - @Override - public void registerSerializer(ExperimenterSerializerKey key, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer((MessageTypeKey) key, serializer); - } - - @Override - public void registerDeserializer(ExperimenterDeserializerKey key, - OFGeneralDeserializer deserializer) { - deserializerRegistry.registerDeserializer((MessageCodeKey) key, deserializer); - } - @Override public void close() throws Exception { shutdown(); @@ -168,36 +156,36 @@ public boolean unregisterDeserializer(ExperimenterDeserializerKey key) { @Override public void registerActionSerializer(ExperimenterActionSerializerKey key, OFGeneralSerializer serializer) { - registerSerializer(key, serializer); + serializerRegistry.registerSerializer(key, serializer); } @Override public void registerActionDeserializer(ExperimenterActionDeserializerKey key, OFGeneralDeserializer deserializer) { - registerDeserializer(key, deserializer); + deserializerRegistry.registerDeserializer(key, deserializer); } @Override public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, OFGeneralSerializer serializer) { - registerSerializer(key, serializer); + serializerRegistry.registerSerializer(key, serializer); } @Override public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, OFGeneralDeserializer deserializer) { - registerDeserializer(key, deserializer); + deserializerRegistry.registerDeserializer(key, deserializer); } @Override public void registerMatchEntrySerializer(MatchEntrySerializerKey key, OFGeneralSerializer serializer) { - registerSerializer(key, serializer); + serializerRegistry.registerSerializer(key, serializer); } @Override public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFGeneralDeserializer deserializer) { - registerDeserializer(key, deserializer); + deserializerRegistry.registerDeserializer(key, deserializer); } -} +} \ No newline at end of file diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index ad7d741d..69d08fbb 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -11,18 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider; import com.google.common.util.concurrent.ListenableFuture; @@ -31,7 +21,8 @@ * @author michal.polkorab * */ -public interface SwitchConnectionProvider extends AutoCloseable { +public interface SwitchConnectionProvider extends AutoCloseable, + SerializerExtensionProvider, DeserializerExtensionProvider { /** * @param configuration [protocol, port, address and supported features] @@ -56,82 +47,4 @@ public interface SwitchConnectionProvider extends AutoCloseable { */ void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler); - /** - * Registers custom serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - public void registerSerializer(ExperimenterSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers custom deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - public void registerDeserializer(ExperimenterDeserializerKey key, OFGeneralDeserializer deserializer); - - /** - * Unregisters custom serializer - * @param key used for serializer lookup - * @return true if serializer was removed, - * false if no serializer was found under specified key - */ - public boolean unregisterSerializer(ExperimenterSerializerKey key); - - /** - * Unregisters custom deserializer - * @param key used for deserializer lookup - * @return true if deserializer was removed, - * false if no deserializer was found under specified key - */ - public boolean unregisterDeserializer(ExperimenterDeserializerKey key); - - /** - * Registers action serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - public void registerActionSerializer(ExperimenterActionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers action deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - public void registerActionDeserializer(ExperimenterActionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers instruction serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers instruction deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers match entry serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - public void registerMatchEntrySerializer( - MatchEntrySerializerKey key,OFGeneralSerializer serializer); - - /** - * Registers match entry deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, - OFGeneralDeserializer deserializer); -} +} \ No newline at end of file From 05bc9fb5cb06c747be728f8d695d2723db911514 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 16 Jul 2014 13:36:24 +0200 Subject: [PATCH 028/285] Updated experimenter model - all extension-capable-messages have their augmentations (experimenter message is defined - so no augment needed here) - these augmentations will be used for vendor / experimenter differentiation Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-augments.yang | 65 +++++++++++-------- .../src/main/yang/openflow-protocol.yang | 34 ++-------- .../src/main/yang/openflow-types.yang | 8 ++- .../factories/ErrorMessageFactory.java | 8 +-- .../MultipartReplyMessageFactory.java | 26 ++++---- .../OF10StatsReplyMessageFactory.java | 11 ++-- .../action/OF13SetFieldActionSerializer.java | 5 +- .../MultipartRequestInputFactory.java | 5 +- .../impl/util/OF13MatchSerializer.java | 5 +- .../impl/util/TypeKeyMakerFactory.java | 17 +++-- .../MultipartReplyMessageFactoryTest.java | 61 ++--------------- 11 files changed, 97 insertions(+), 148 deletions(-) diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 44986927..910dfa5f 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -176,9 +176,9 @@ } } augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "experimenter-match-entry"; + ext:augment-identifier "experimenter-id-match-entry"; leaf experimenter { - type uint32; + type oft:experimenter-id; } } augment "/oxm:oxm-container/oxm:match-entries" { @@ -248,12 +248,9 @@ uses oxm:oxm-fields-grouping; } augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "experimenter-action"; + ext:augment-identifier "experimenter-id-action"; leaf experimenter { - type uint32; - } - leaf data { - type binary; + type oft:experimenter-id; } } // OF1.0 structures @@ -311,16 +308,13 @@ uses oxm:oxm-fields-grouping; } augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "experimenter-related-table-feature-property"; + ext:augment-identifier "experimenter-id-table-feature-property"; leaf experimenter { - type uint32; + type oft:experimenter-id; } leaf exp-type { type uint32; } - leaf data { - type binary; - } } // OFP_INSTRUCTION AUGMENTS @@ -350,12 +344,9 @@ } } augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "experimenter-instruction"; + ext:augment-identifier "experimenter-id-instruction"; leaf experimenter { - type uint32; - } - leaf data { - type binary; + type oft:experimenter-id; } } @@ -367,27 +358,45 @@ } } augment "/ofproto:queue-prop-container/ofproto:queue-property" { - ext:augment-identifier "experimenter-queue-property"; + ext:augment-identifier "experimenter-id-queue-property"; leaf experimenter { - type uint32; - } - leaf data { - type binary; + type oft:experimenter-id; } } // OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) - augment "/ofproto:error-message" { - ext:augment-identifier "experimenter-error"; - leaf exp_type { - type uint16; + augment "/ofproto:error-message" { + ext:augment-identifier "experimenter-id-error"; + leaf experimenter { + type oft:experimenter-id; } + } + +// OFP_MULTIPART AUGMENTS + augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { + ext:augment-identifier "experimenter-id-multipart-request"; leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { type uint32; } - leaf exp-data { - type binary; + } + augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { + ext:augment-identifier "experimenter-id-multipart-reply"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; } } +// OFP_METER_BAND AUGMENTS + augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { + ext:augment-identifier "experimenter-id-meter-band"; + leaf experimenter { + type oft:experimenter-id; + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 300dd7fe..32070d14 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -213,14 +213,11 @@ uses ofHeader; leaf experimenter { - type uint32; + type oft:experimenter-id; } leaf exp_type { type uint32; } - leaf data { - type binary; - } } /* Switch configuration messages. */ grouping features-request { @@ -682,15 +679,7 @@ } case multipart-request-experimenter-case { container multipart-request-experimenter { - leaf experimenter { - type uint32; - } - leaf exp-type { - type uint32; - } - leaf data { - type binary; - } + // empty body - used for experimenter augmentation } } } @@ -1057,15 +1046,7 @@ } case multipart-reply-experimenter-case { container multipart-reply-experimenter { - leaf experimenter { - type uint32; - } - leaf exp-type { - type uint32; - } - leaf data { - type binary; - } + // empty body - used for experimenter augmentation } } } @@ -1212,6 +1193,9 @@ } } + container meter-band-container { + uses meter-band-header; + } grouping meter-band-header { choice meter-band { case meter-band-drop-case { @@ -1230,12 +1214,6 @@ case meter-band-experimenter-case { container meter-band-experimenter { uses meter-band-commons; - leaf experimenter { - type uint32; - } - leaf data { - type binary; - } } } } diff --git a/openflow-protocol-api/src/main/yang/openflow-types.yang b/openflow-protocol-api/src/main/yang/openflow-types.yang index 47dc4a35..1a024089 100644 --- a/openflow-protocol-api/src/main/yang/openflow-types.yang +++ b/openflow-protocol-api/src/main/yang/openflow-types.yang @@ -226,7 +226,13 @@ typedef ether-type { type uint16; } - + typedef experimenter-id { + description "This type represents experimenter ID used in experimenter messages. + It also represents vendor ID - as it is the same for OF version 1.3+. + (VENDOR naming convention has been changed in OF v1.3 specification + to EXPERIMENTER)"; + type uint32; + } typedef error-type { type enumeration { enum HELLO_FAILED { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index 45b25aba..4b18f212 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterError; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdError; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode; @@ -55,10 +55,10 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { ErrorType errorType = ErrorType.forValue(type); if (ErrorType.EXPERIMENTER.equals(errorType)) { builder.setType(errorType.getIntValue()); - OFDeserializer deserializer = registry.getDeserializer(new MessageCodeKey( + OFDeserializer deserializer = registry.getDeserializer(new MessageCodeKey( EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, ErrorMessage.class)); - ExperimenterError error = deserializer.deserialize(rawMessage); - builder.addAugmentation(ExperimenterError.class, error); + ExperimenterIdError error = deserializer.deserialize(rawMessage); + builder.addAugmentation(ExperimenterIdError.class, error); } else { decodeType(builder, errorType, type); decodeCode(rawMessage, builder, errorType); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 98192092..4074339a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -673,14 +673,15 @@ private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build()); break; case 0xFFFF: - MeterBandExperimenterCaseBuilder bandExperimenterCaseBuilder = new MeterBandExperimenterCaseBuilder(); + MeterBandExperimenterCaseBuilder bandExperimenterCaseBuilder = new MeterBandExperimenterCaseBuilder(); MeterBandExperimenterBuilder bandExperimenterBuilder = new MeterBandExperimenterBuilder(); - bandExperimenterBuilder.setType(MeterBandType.forValue(bandType)); - actualLength += input.readUnsignedShort(); - bandExperimenterBuilder.setRate(input.readUnsignedInt()); - bandExperimenterBuilder.setBurstSize(input.readUnsignedInt()); - bandExperimenterBuilder.setExperimenter(input.readUnsignedInt()); - bandExperimenterCaseBuilder.setMeterBandExperimenter(bandExperimenterBuilder.build()); + // TODO - implement lookup into registry +// bandExperimenterBuilder.setType(MeterBandType.forValue(bandType)); +// actualLength += input.readUnsignedShort(); +// bandExperimenterBuilder.setRate(input.readUnsignedInt()); +// bandExperimenterBuilder.setBurstSize(input.readUnsignedInt()); +// bandExperimenterBuilder.setExperimenter(input.readUnsignedInt()); +// bandExperimenterCaseBuilder.setMeterBandExperimenter(bandExperimenterBuilder.build()); bandsBuilder.setMeterBand(bandExperimenterCaseBuilder.build()); break; default: @@ -697,13 +698,14 @@ private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { } private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { + // TODO - implement lookup into registry MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); - builder.setExperimenter(input.readUnsignedInt()); - builder.setExpType(input.readUnsignedInt()); - byte[] data = new byte[input.readableBytes()]; - input.readBytes(data); - builder.setData(data); +// builder.setExperimenter(input.readUnsignedInt()); +// builder.setExpType(input.readUnsignedInt()); +// byte[] data = new byte[input.readableBytes()]; +// input.readBytes(data); +// builder.setData(data); caseBuilder.setMultipartReplyExperimenter(builder.build()); return caseBuilder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 94885a50..5d27bdf5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -296,12 +296,13 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { } private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { - MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); + // TODO - implement lookup into registry + MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); - builder.setExperimenter(input.readUnsignedInt()); - byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(data); - builder.setData(data); +// builder.setExperimenter(input.readUnsignedInt()); +// byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; +// input.readBytes(data); +// builder.setData(data); caseBuilder.setMultipartReplyExperimenter(builder.build()); return caseBuilder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 94fd3736..bd6b9d8e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; @@ -44,7 +44,8 @@ public void serialize(Action action, ByteBuf outBuffer) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); } else { key.setExperimenterId(null); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 4c174c8f..5a428c2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; @@ -442,7 +442,8 @@ private void writeOxmRelatedTableProperty(final ByteBuf output, MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); } else { key.setExperimenterId(null); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index 8bc2632e..afa3e0dd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; @@ -81,7 +81,8 @@ public void serializeMatchEntries(List matchEntries, ByteBuf out) MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class).getExperimenter()); + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); } else { key.setExperimenterId(null); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 4ba9294b..80060e33 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -11,9 +11,9 @@ import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -39,8 +39,8 @@ public static TypeKeyMaker createMatchEntriesKeyMaker(short versio key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterMatchEntry.class) - .getExperimenter()); + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); return key; } key.setExperimenterId(null); @@ -59,7 +59,8 @@ public static TypeKeyMaker createActionKeyMaker(short version) { @Override public ActionSerializerKey make(Action entry) { if (entry.getType().equals(Experimenter.class)) { - return new ActionSerializerKey<>(getVersion(), entry.getType(), entry.getAugmentation(ExperimenterAction.class).getExperimenter()); + return new ActionSerializerKey<>(getVersion(), entry.getType(), + entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue()); } return new ActionSerializerKey<>(getVersion(), entry.getType(), null); } @@ -77,7 +78,9 @@ public static TypeKeyMaker createInstructionKeyMaker(short version) public InstructionSerializerKey make(Instruction entry) { if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common .instruction.rev130731.Experimenter.class)) { - return new InstructionSerializerKey<>(getVersion(), entry.getType(), entry.getAugmentation(ExperimenterInstruction.class).getExperimenter()); + return new InstructionSerializerKey<>(getVersion(), entry.getType(), + entry.getAugmentation(ExperimenterIdInstruction.class) + .getExperimenter().getValue()); } return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 5e6017a9..24985bb8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -60,13 +60,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; @@ -79,7 +76,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; @@ -702,7 +698,7 @@ public void testMultipartReplyMeterBodyMulti(){ @Test public void testMultipartReplyMeterConfigBody(){ ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+ - "00 38 "+//len + "00 28 "+//len "00 0A "+//flags "00 00 00 09 "+//meterId "00 01 "+//meterBandDrop.type @@ -715,13 +711,7 @@ public void testMultipartReplyMeterConfigBody(){ "00 00 00 11 "+//meterBandDscp.rate "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel - "00 00 00 "+//meterBandDscp.pad - "FF FF "+//meterBandExperimenter.type - "00 10 "+//meterBandExperimenter.len - "00 00 00 11 "+//meterBandExperimenter.rate - "00 00 00 20 "+//meterBandExperimenter.burstSize - "00 00 00 04"//meterBandExperimenter.experimenter - ); + "00 00 00");//meterBandDscp.pad MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); @@ -747,13 +737,6 @@ public void testMultipartReplyMeterConfigBody(){ Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - - MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); - MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter(); - Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); - Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue()); - Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue()); - Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue()); } /** @@ -762,7 +745,7 @@ public void testMultipartReplyMeterConfigBody(){ @Test public void testMultipartReplyMeterConfigBodyMulti(){ ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 "+ - "00 38 "+//len + "00 28 "+//len "00 06 "+//flags "00 00 00 09 "+//meterId "00 01 "+//meterBandDrop.type @@ -776,11 +759,6 @@ public void testMultipartReplyMeterConfigBodyMulti(){ "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel "00 00 00 "+//meterBandDscp.pad - "FF FF "+//meterBandExperimenter.type - "00 10 "+//meterBandExperimenter.len - "00 00 00 11 "+//meterBandExperimenter.rate - "00 00 00 20 "+//meterBandExperimenter.burstSize - "00 00 00 04 "+//meterBandExperimenter.experimenter "00 18 "+//len01 "00 03 "+//flags01 @@ -818,13 +796,6 @@ public void testMultipartReplyMeterConfigBodyMulti(){ Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - MeterBandExperimenterCase experimenterCase = (MeterBandExperimenterCase) message.getMeterConfig().get(0).getBands().get(2).getMeterBand(); - MeterBandExperimenter meterBandExperimenter = experimenterCase.getMeterBandExperimenter(); - Assert.assertEquals("Wrong meterBandExperimenter.type", 0xFFFF, meterBandExperimenter.getType().getIntValue()); - Assert.assertEquals("Wrong meterBandExperimenter.rate", 17, meterBandExperimenter.getRate().intValue()); - Assert.assertEquals("Wrong meterBandExperimenter.burstSize", 32, meterBandExperimenter.getBurstSize().intValue()); - Assert.assertEquals("Wrong meterBandExperimenter.experimenter", 4, meterBandExperimenter.getExperimenter().intValue()); - LOGGER.info(message.getMeterConfig().get(0).getFlags().toString()); Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags()); @@ -839,31 +810,7 @@ public void testMultipartReplyMeterConfigBodyMulti(){ Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue()); } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyExperimenterBody(){ - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+ - "00 00 00 0F "+//experimenterId - "00 00 00 FF "+//expType - "00 00 01 01 00 00 01 01" - ); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0xFFFF, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyExperimenterCase messageCase = (MultipartReplyExperimenterCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyExperimenter message = messageCase.getMultipartReplyExperimenter(); - Assert.assertEquals("Wrong experimenterId", 15, message.getExperimenter().intValue()); - Assert.assertEquals("Wrong expType", 255, message.getExpType().intValue()); - Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01}, - message.getData()); - } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ From 600a545bbfa20e1eed1ce76c28ad6f4048cb6673 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 8 Jul 2014 18:21:11 +0200 Subject: [PATCH 029/285] Example of openflowjava extension for nx_action_resubmit - configuration file is located in src/main/resources - use this file to load / register this bundle - configuration file is exemplary - it registers the NX_ACTION_RESUBMIT into ofjava 6633 and 6653 instances - change contains 2 yang files: - nx-resubmit-action.yang - shows how to augment existing structures - openflow-nx-resubmit-action.yang - shows how to configure custom bundle - unit tests test if the structure is (de)serialized correctly Change-Id: I6ed7226dba83f36deb100de88e5408ae32c060b2 Signed-off-by: Michal Polkorab --- openflow-nx-resubmit-action/pom.xml | 112 ++++++++++++++++++ .../nx/NxResubmitActionRegistrator.java | 87 ++++++++++++++ .../NxActionResubmitDeserializer.java | 61 ++++++++++ .../NxActionResubmitSerializer.java | 51 ++++++++ .../NxResubmitActionRegistratorModule.java | 27 +++++ ...esubmitActionRegistratorModuleFactory.java | 13 ++ .../43-openflow-nx-resubmit-config.xml | 35 ++++++ .../src/main/resources/log4j.xml | 20 ++++ .../src/main/yang/nx-resubmit-action.yang | 34 ++++++ .../yang/openflow-nx-resubmit-action.yang | 45 +++++++ .../NxActionResubmitDeserializerTest.java | 56 +++++++++ .../NxActionResubmitSerializerTest.java | 86 ++++++++++++++ pom.xml | 1 + 13 files changed, 628 insertions(+) create mode 100644 openflow-nx-resubmit-action/pom.xml create mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java create mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java create mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java create mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java create mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java create mode 100644 openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml create mode 100644 openflow-nx-resubmit-action/src/main/resources/log4j.xml create mode 100644 openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang create mode 100644 openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang create mode 100644 openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java create mode 100644 openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java diff --git a/openflow-nx-resubmit-action/pom.xml b/openflow-nx-resubmit-action/pom.xml new file mode 100644 index 00000000..1468d019 --- /dev/null +++ b/openflow-nx-resubmit-action/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.5-SNAPSHOT + + org.opendaylight.openflowjava + openflow-nx-resubmit-action + 0.5-SNAPSHOT + bundle + Openflow Protocol Library - Nx Resubmit Action + http://maven.apache.org + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${jmxGeneratorPath} + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + ${salGeneratorPath} + + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + ${project.build.directory}/site/models + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${config.version} + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.generator.version} + jar + + + + + + + + + + ${project.groupId} + openflow-protocol-api + ${project.version} + + + ${project.groupId} + openflow-protocol-spi + ${project.version} + + + org.opendaylight.yangtools.model + yang-ext + + + io.netty + netty-buffer + + + junit + junit + test + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + org.opendaylight.controller + config-api + ${config.version} + + + diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java new file mode 100644 index 00000000..4baf6d2d --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.nx; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer; +import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; + +/** + * @author michal.polkorab + * + */ +public class NxResubmitActionRegistrator implements AutoCloseable { + + /** Nicira experimenter ID */ + public static final Long NICIRA_EXPERIMENTER_ID = 0x00002320L; + private List providers; + + /** + * @param providers providers that shall be filled with serializers + */ + public void registerNxResubmitSerializer(List providers) { + if (providers != null) { + this.providers = providers; + for (SwitchConnectionProvider provider : providers) { + /* In case of handling multiple actions, instructions and other structures which + * are differentiated by vendor / experimenter subtype, vendor has to + * switch / choose between these subtypes. + * + * This has to be done in this way because of experimenter headers, which + * provide only vendor / experimenter ID. Subtype position may be different + * for different vendors (or not present at all) - that's why vendor has to + * handle it in his own implementations. + */ + provider.registerActionSerializer(new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID), + new NxActionResubmitSerializer()); + } + } + } + + /** + * @param providers providers that shall be filled with deserializers + */ + public void registerNxResubmitDeserializer(List providers) { + if (providers != null) { + this.providers = providers; + for (SwitchConnectionProvider provider : providers) { + /* In case of handling multiple actions, instructions and other structures which + * are differentiated by vendor / experimenter subtype, vendor has to + * switch / choose between these subtypes. + * + * This has to be done in this way because of experimenter headers, which + * provide only vendor / experimenter ID. Subtype position may be different + * for different vendors (or not present at all) - that's why vendor has to + * handle it in his own implementations. + */ + provider.registerActionDeserializer(new ExperimenterActionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID), + new NxActionResubmitDeserializer()); + } + } + } + + @Override + public void close() throws Exception { + for (SwitchConnectionProvider provider : providers) { + // unregister serializer + provider.unregisterSerializer(new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID)); + // unregister deserializer + provider.unregisterDeserializer(new ExperimenterActionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID)); + } + } +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java new file mode 100644 index 00000000..f5d50f50 --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.nx.deserialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugmentBuilder; + +/** + * @author michal.polkorab + * + */ +public class NxActionResubmitDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Action deserializeHeader(ByteBuf input) { + ActionBuilder builder = processHeader(input); + return builder.build(); + } + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = processHeader(input); + NxActionResubmitAugmentBuilder nxBuilder = new NxActionResubmitAugmentBuilder(); + nxBuilder.setSubtype(input.readUnsignedShort()); + nxBuilder.setInPort(input.readUnsignedShort()); + nxBuilder.setTable(input.readUnsignedByte()); + input.skipBytes(3); + builder.addAugmentation(NxActionResubmitAugment.class, nxBuilder.build()); + return builder.build(); + } + + private static ActionBuilder processHeader(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(Experimenter.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + // ExperimenterIdAction augmentation is used for vendor / experimenter differentiation + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(input.readUnsignedInt())); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + return builder; + } +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java new file mode 100644 index 00000000..a6a38c8a --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.nx.serialization; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class NxActionResubmitSerializer implements OFSerializer, + HeaderSerializer { + private static final Logger LOGGER = LoggerFactory + .getLogger(NxActionResubmitSerializer.class); + private static final byte NX_ACTION_RESUBMIT_LENGTH = 16; + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + LOGGER.error("SERIALIZING NX ACTION"); + outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + outBuffer.writeShort(NX_ACTION_RESUBMIT_LENGTH); + NxActionResubmitAugment expAction = action.getAugmentation(NxActionResubmitAugment.class); + outBuffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); + outBuffer.writeShort(expAction.getSubtype()); + outBuffer.writeShort(expAction.getInPort()); + outBuffer.writeByte(expAction.getTable()); + outBuffer.writeZero(3); + } + + @Override + public void serializeHeader(Action action, ByteBuf outBuffer) { + outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + outBuffer.writeShort(EncodeConstants.EXPERIMENTER_IDS_LENGTH); + outBuffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); + } +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java new file mode 100644 index 00000000..b2c8cd69 --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java @@ -0,0 +1,27 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709; + +import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; + +public class NxResubmitActionRegistratorModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.AbstractNxResubmitActionRegistratorModule { + public NxResubmitActionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NxResubmitActionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.NxResubmitActionRegistratorModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + NxResubmitActionRegistrator registrator = new NxResubmitActionRegistrator(); + registrator.registerNxResubmitSerializer(getOpenflowSwitchConnectionProviderDependency()); + registrator.registerNxResubmitDeserializer(getOpenflowSwitchConnectionProviderDependency()); + return registrator; + } + +} diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java new file mode 100644 index 00000000..38852232 --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: openflow-nx-resubmit-action yang module local name: openflow-nx-resubmit-action +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Wed Jul 09 18:42:22 CEST 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709; +public class NxResubmitActionRegistratorModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.AbstractNxResubmitActionRegistratorModuleFactory { + +} diff --git a/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml b/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml new file mode 100644 index 00000000..df43aa09 --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml @@ -0,0 +1,35 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:openflow:nx:resubmit:action?module=openflow-nx-resubmit-action&revision=2014-07-09 + + + + + + + + prefix:openflow-nx-resubmit-action + openflow-nx-resubmit-action-bundle + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-legacy + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-default + + + + + + + diff --git a/openflow-nx-resubmit-action/src/main/resources/log4j.xml b/openflow-nx-resubmit-action/src/main/resources/log4j.xml new file mode 100644 index 00000000..5077ef8f --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/resources/log4j.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang b/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang new file mode 100644 index 00000000..5ab94cd1 --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + module nx-resubmit-action { + namespace "urn:opendaylight:openflow:nx:resubmit:action"; + prefix "nx-resubmit"; + + import openflow-types {prefix oft;} + import openflow-action {prefix ofaction;} + import yang-ext {prefix ext;} + + revision "2013-07-31" { + description "OpenFlow 1.3 - action model"; + } + + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "nx-action-resubmit-augment"; + leaf subtype { + type uint16; + } + leaf in-port { + type uint16; + } + leaf table { + type uint8; + } + } + +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang b/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang new file mode 100644 index 00000000..45caf93a --- /dev/null +++ b/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +module openflow-nx-resubmit-action { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:openflow:nx:resubmit:action"; + prefix "openflow-nx-resubmit-action"; + + import config {prefix config; revision-date 2013-04-05;} + import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} + + + description + "openflow library default exemplary package"; + + revision "2014-07-09" { + description + "Initial revision"; + } + + identity openflow-nx-resubmit-action { + base config:module-type; + config:java-name-prefix NxResubmitActionRegistrator; + } + + augment "/config:modules/config:module/config:configuration" { + case openflow-nx-resubmit-action { + when "/config:modules/config:module/config:type = 'openflow-nx-resubmit-action'"; + + list openflow-switch-connection-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; + } + } + } + } + } +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java new file mode 100644 index 00000000..5fca9ce2 --- /dev/null +++ b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.nx.deserialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; + +/** + * @author michal.polkorab + * + */ +public class NxActionResubmitDeserializerTest { + + /** + * Test deserialization of NX_ACTION_RESUBMIT action + */ + @Test + public void test() { + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + buffer.writeShort(16); + buffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); + buffer.writeShort(1); + buffer.writeShort(42); + buffer.writeByte(5); + buffer.writeZero(3); + + NxActionResubmitDeserializer deserializer = new NxActionResubmitDeserializer(); + Action action = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.Experimenter", action.getType().getName()); + ExperimenterIdAction expAction = action.getAugmentation(ExperimenterIdAction.class); + Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), + expAction.getExperimenter().getValue().intValue()); + NxActionResubmitAugment nxResubmit = action.getAugmentation(NxActionResubmitAugment.class); + Assert.assertEquals("Wrong subtype", 1, nxResubmit.getSubtype().intValue()); + Assert.assertEquals("Wrong in-port", 42, nxResubmit.getInPort().intValue()); + Assert.assertEquals("Wrong table", 5, nxResubmit.getTable().intValue()); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java new file mode 100644 index 00000000..59a01389 --- /dev/null +++ b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.nx.serialization; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugmentBuilder; + +/** + * @author michal.polkorab + * + */ +public class NxActionResubmitSerializerTest { + + /** + * Test serialization of NX_ACTION_RESUBMIT action + */ + @Test + public void test() { + ActionBuilder builder = new ActionBuilder(); + builder.setType(Experimenter.class); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID)); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + NxActionResubmitAugmentBuilder nxBuilder = new NxActionResubmitAugmentBuilder(); + nxBuilder.setSubtype(1); + nxBuilder.setInPort(42); + nxBuilder.setTable((short) 5); + builder.addAugmentation(NxActionResubmitAugment.class, nxBuilder.build()); + Action action = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + NxActionResubmitSerializer serializer = new NxActionResubmitSerializer(); + serializer.serialize(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), + buffer.readUnsignedInt()); + Assert.assertEquals("Wrong subtype", 1, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong in-port", 42, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong table", 5, buffer.readUnsignedByte()); + buffer.skipBytes(3); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } + + /** + * Test serialization of NX_ACTION_RESUBMIT action + */ + @Test + public void testHeaderSerialization() { + ActionBuilder builder = new ActionBuilder(); + builder.setType(Experimenter.class); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID)); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + Action action = builder.build(); + + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + NxActionResubmitSerializer serializer = new NxActionResubmitSerializer(); + serializer.serializeHeader(action, buffer); + + Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), + buffer.readUnsignedInt()); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 05862144..ab183759 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ openflow-protocol-it feature simple-client + openflow-nx-resubmit-action scm:git:ssh://git.opendaylight.org:29418/openflowjava.git From f732586038a1a23ca775a1a7c73467cdc5899e05 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 18 Jul 2014 15:56:57 +0200 Subject: [PATCH 030/285] Fix: Correct key looked up on experimenter messages Signed-off-by: Michal Polkorab --- .../protocol/impl/util/CodeKeyMakerFactory.java | 6 ++++-- .../protocol/impl/util/TypeKeyMakerFactory.java | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 0fab1ad9..9b21226b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -14,6 +14,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** @@ -59,7 +61,7 @@ public MessageCodeKey make(ByteBuf input) { if (type == EncodeConstants.EXPERIMENTER_VALUE) { Long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ActionDeserializerKey(getVersion(), type, expId); + return new ExperimenterActionDeserializerKey(getVersion(), expId); } ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); return actionDeserializerKey; @@ -79,7 +81,7 @@ public MessageCodeKey make(ByteBuf input) { if (type == EncodeConstants.EXPERIMENTER_VALUE) { Long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new InstructionDeserializerKey(getVersion(), type, expId); + return new ExperimenterInstructionDeserializerKey(getVersion(), expId); } return new InstructionDeserializerKey(getVersion(), type, null); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 80060e33..6530ee2c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -8,9 +8,12 @@ package org.opendaylight.openflowjava.protocol.impl.util; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; @@ -57,9 +60,9 @@ public static TypeKeyMaker createMatchEntriesKeyMaker(short versio public static TypeKeyMaker createActionKeyMaker(short version) { return new AbstractTypeKeyMaker(version) { @Override - public ActionSerializerKey make(Action entry) { + public MessageTypeKey make(Action entry) { if (entry.getType().equals(Experimenter.class)) { - return new ActionSerializerKey<>(getVersion(), entry.getType(), + return new ExperimenterActionSerializerKey(getVersion(), entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue()); } return new ActionSerializerKey<>(getVersion(), entry.getType(), null); @@ -75,10 +78,10 @@ public ActionSerializerKey make(Action entry) { public static TypeKeyMaker createInstructionKeyMaker(short version) { return new AbstractTypeKeyMaker(version) { @Override - public InstructionSerializerKey make(Instruction entry) { + public MessageTypeKey make(Instruction entry) { if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common .instruction.rev130731.Experimenter.class)) { - return new InstructionSerializerKey<>(getVersion(), entry.getType(), + return new ExperimenterInstructionSerializerKey(getVersion(), entry.getAugmentation(ExperimenterIdInstruction.class) .getExperimenter().getValue()); } From c5a70b5ba23927a2797394393605e83316ba4061 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 22 Jul 2014 09:30:40 +0200 Subject: [PATCH 031/285] TcpFlag match entry serializer registration fix - TcpFlag and Tunnel match entry serializers used old keys for registration Change-Id: Ib0c3944d7d27b3ce8601aa3797d175dc94bce6dd Signed-off-by: Michal Polkorab --- .../impl/serialization/MatchEntriesInitializer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 49a70d3a..50827a77 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; @@ -51,8 +52,6 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.EnhancedKeyRegistryHelper; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; @@ -159,8 +158,9 @@ public static void registerMatchEntrySerializers(SerializerRegistry serializerRe // Register OpenFlow NXM1Class match entry serializer Class nxm1Class = Nxm1Class.class; - EnhancedKeyRegistryHelper nxm1RegistryHelper = - new EnhancedKeyRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, nxm1Class, serializerRegistry); + MatchEntrySerializerRegistryHelper nxm1RegistryHelper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + nxm1Class, serializerRegistry); nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); From d58ee5d9fb3dffc8bf395d2e29342dd5e16c9932 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 7 Jul 2014 16:28:18 +0200 Subject: [PATCH 032/285] Replaced usage of BytebufUtils.padBuffer() as it is deprecated - replaced with buffer.writeZero() Change-Id: Ica7ef6d244fc531419c42d4055f0d42b09e7ebf0 Signed-off-by: Michal Polkorab --- .../AbstractEthertypeActionSerializer.java | 3 +- .../AbstractHeaderActionSerializer.java | 3 +- ...F10AbstractMacAddressActionSerializer.java | 2 +- .../OF10AbstractPortActionSerializer.java | 3 +- .../action/OF10EnqueueActionSerializer.java | 3 +- .../action/OF10SetNwTosActionSerializer.java | 3 +- .../OF10SetVlanPcpActionSerializer.java | 3 +- .../OF10SetVlanVidActionSerializer.java | 3 +- .../action/OF13OutputActionSerializer.java | 3 +- .../action/OF13SetFieldActionSerializer.java | 5 ++-- .../OF13SetMplsTtlActionSerializer.java | 3 +- .../action/OF13SetNwTtlActionSerializer.java | 3 +- .../factories/FlowModInputMessageFactory.java | 4 +-- .../GetQueueConfigInputMessageFactory.java | 4 +-- .../GroupModInputMessageFactory.java | 6 ++-- .../factories/HelloInputMessageFactory.java | 6 ++-- .../MeterModInputMessageFactory.java | 6 ++-- .../MultipartRequestInputFactory.java | 30 +++++++++---------- .../OF10PortModInputMessageFactory.java | 2 +- ...OF10QueueGetConfigInputMessageFactory.java | 2 +- .../OF10StatsRequestInputFactory.java | 8 ++--- .../PacketOutInputMessageFactory.java | 2 +- .../factories/PortModInputMessageFactory.java | 6 ++-- .../RoleRequestInputMessageFactory.java | 2 +- .../TableModInputMessageFactory.java | 2 +- .../AbstractActionInstructionSerializer.java | 5 ++-- .../GoToTableInstructionSerializer.java | 3 +- .../WriteMetadataInstructionSerializer.java | 3 +- .../impl/util/OF10MatchSerializer.java | 4 +-- .../impl/util/OF13MatchSerializer.java | 3 +- .../MultipartReplyMessageFactoryTest.java | 13 ++++---- .../OF10StatsReplyMessageFactoryTest.java | 13 ++++---- 32 files changed, 72 insertions(+), 89 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java index 7af91fd6..9c4117a4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -26,7 +25,7 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); outBuffer.writeShort(ethertype.getEthertype().getValue()); - ByteBufUtils.padBuffer(ActionConstants.ETHERTYPE_ACTION_PADDING, outBuffer); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java index b9614676..aa82f49e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** @@ -23,7 +22,7 @@ public abstract class AbstractHeaderActionSerializer extends AbstractActionSeria @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_ACTION_HEADER, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java index e3cb27e3..f8c47352 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java @@ -26,7 +26,7 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java index fee943a5..a02df47e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -26,6 +25,6 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); PortAction port = action.getAugmentation(PortAction.class); outBuffer.writeShort(port.getPort().getValue().intValue()); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_TP_PORT_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index 8c55a732..dfc79768 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -27,7 +26,7 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); PortAction port = action.getAugmentation(PortAction.class); outBuffer.writeShort(port.getPort().getValue().intValue()); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_ENQUEUE_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); outBuffer.writeInt(queueId.getQueueId().intValue()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index cedae208..0d668248 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -25,7 +24,7 @@ public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 59cddfa3..29fdafe0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -25,7 +24,7 @@ public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index 11df22f3..e788f8d4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -25,7 +24,7 @@ public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); - ByteBufUtils.padBuffer(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 19acf948..2ac79f7d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -29,7 +28,7 @@ public void serialize(Action action, ByteBuf outBuffer) { outBuffer.writeInt(port.getPort().getValue().intValue()); MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); outBuffer.writeShort(maxlength.getMaxLength()); - ByteBufUtils.padBuffer(ActionConstants.OUTPUT_PADDING, outBuffer); + outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index bd6b9d8e..6b56fd09 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -16,9 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; @@ -53,7 +52,7 @@ public void serialize(Action action, ByteBuf outBuffer) { serializer.serialize(entry, outBuffer); int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { - ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer); + outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); } outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index 495c6bc1..480bc931 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -28,7 +27,7 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); outBuffer.writeByte(mplsTtl.getMplsTtl()); - ByteBufUtils.padBuffer(ActionConstants.SET_MPLS_TTL_PADDING, outBuffer); + outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index 02c01157..b30cf5d5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -11,7 +11,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -26,7 +25,7 @@ public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); outBuffer.writeByte(nwTtl.getNwTtl()); - ByteBufUtils.padBuffer(ActionConstants.SET_NW_TTL_PADDING, outBuffer); + outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 421bfc4a..0e1b3533 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -14,11 +14,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; @@ -50,7 +50,7 @@ public void serialize(final FlowModInput message, final ByteBuf outBuffer) { outBuffer.writeInt(message.getOutPort().getValue().intValue()); outBuffer.writeInt(message.getOutGroup().intValue()); outBuffer.writeShort(createFlowModFlagsBitmask(message.getFlags())); - ByteBufUtils.padBuffer(PADDING_IN_FLOW_MOD_MESSAGE, outBuffer); + outBuffer.writeZero(PADDING_IN_FLOW_MOD_MESSAGE); registry.>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)) .serialize(message.getMatch(), outBuffer); ListSerializer.serializeList(message.getInstruction(), INSTRUCTION_KEY_MAKER, registry, outBuffer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java index f107ccd9..f8ac9f7c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactory.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; /** @@ -29,7 +29,7 @@ public class GetQueueConfigInputMessageFactory implements OFSerializer buckets, ByteBuf outBuffer) { outBuffer.writeShort(currentBucket.getWeight().shortValue()); outBuffer.writeInt(currentBucket.getWatchPort().getValue().intValue()); outBuffer.writeInt(currentBucket.getWatchGroup().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_BUCKET, outBuffer); + outBuffer.writeZero(PADDING_IN_BUCKET); ListSerializer.serializeList(currentBucket.getAction(), TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, outBuffer); outBuffer.setShort(bucketLengthIndex, outBuffer.writerIndex() - bucketLengthIndex); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java index 26af4530..3d95646b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements; @@ -43,7 +43,7 @@ private static void serializeElementsList(HelloInput message, ByteBuf output) { } int length = output.writerIndex() - elementStartIndex; int padding = length - versionBitmap.length * 4 - HELLO_ELEMENT_HEADER_SIZE; - ByteBufUtils.padBuffer(padding , output); + output.writeZero(padding); output.setShort(elementLengthIndex, output.writerIndex() - elementStartIndex); } } @@ -58,7 +58,7 @@ public void serialize(HelloInput message, ByteBuf outBuffer) { int endWriterIndex = outBuffer.writerIndex(); int paddingRemainder = (endWriterIndex - startWriterIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { - ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer); + outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); } ByteBufUtils.updateOFHeaderLength(outBuffer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java index 50f59677..0c69f478 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; @@ -70,13 +70,13 @@ private void serializeBands(final List bands, final ByteBuf outBuffer) { MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand; MeterBandDrop dropBand = dropBandCase.getMeterBandDrop(); writeBandCommonFields(dropBand, outBuffer); - ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DROP, outBuffer); + outBuffer.writeZero(PADDING_IN_METER_BAND_DROP); } else if (meterBand instanceof MeterBandDscpRemarkCase) { MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand; MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark(); writeBandCommonFields(dscpRemarkBand, outBuffer); outBuffer.writeByte(dscpRemarkBand.getPrecLevel()); - ByteBufUtils.padBuffer(PADDING_IN_METER_BAND_DSCP_REMARK, outBuffer); + outBuffer.writeZero(PADDING_IN_METER_BAND_DSCP_REMARK); } else if (meterBand instanceof MeterBandExperimenterCase) { OFSerializer serializer = registry.getSerializer( new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MeterBandExperimenter.class)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 5a428c2f..507a636e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -107,7 +107,7 @@ public void serialize(final MultipartRequestInput message, final ByteBuf outBuff ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getType().getIntValue()); outBuffer.writeShort(createMultipartRequestFlagsBitmask(message.getFlags())); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_MESSAGE, outBuffer); + outBuffer.writeZero(PADDING_IN_MULTIPART_REQUEST_MESSAGE); if (message.getMultipartRequestBody() instanceof MultipartRequestDescCase){ serializeDescBody(message.getMultipartRequestBody(), outBuffer); @@ -215,10 +215,10 @@ private void serializeFlowBody(final MultipartRequestBody multipartRequestBody, MultipartRequestFlowCase flowCase = (MultipartRequestFlowCase) multipartRequestBody; MultipartRequestFlow flow = flowCase.getMultipartRequestFlow(); output.writeByte(flow.getTableId().byteValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01); output.writeInt(flow.getOutPort().intValue()); output.writeInt(flow.getOutGroup().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02); output.writeLong(flow.getCookie().longValue()); output.writeLong(flow.getCookieMask().longValue()); OFSerializer serializer = registry.getSerializer(new MessageTypeKey<>( @@ -230,10 +230,10 @@ private void serializeAggregateBody(final MultipartRequestBody multipartRequestB MultipartRequestAggregateCase aggregateCase = (MultipartRequestAggregateCase) multipartRequestBody; MultipartRequestAggregate aggregate = aggregateCase.getMultipartRequestAggregate(); output.writeByte(aggregate.getTableId().byteValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_01); output.writeInt(aggregate.getOutPort().intValue()); output.writeInt(aggregate.getOutGroup().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_AGREGGATE_BODY_02); output.writeLong(aggregate.getCookie().longValue()); output.writeLong(aggregate.getCookieMask().longValue()); OFSerializer serializer = registry.getSerializer(new MessageTypeKey<>( @@ -245,7 +245,7 @@ private static void serializePortStatsBody(final MultipartRequestBody multipartR MultipartRequestPortStatsCase portstatsCase = (MultipartRequestPortStatsCase) multipartRequestBody; MultipartRequestPortStats portstats = portstatsCase.getMultipartRequestPortStats(); output.writeInt(portstats.getPortNo().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_PORTSTATS_BODY); } private static void serializeQueueBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { @@ -259,21 +259,21 @@ private static void serializeeGroupStatsBody(final MultipartRequestBody multipar MultipartRequestGroupCase groupStatsCase = (MultipartRequestGroupCase) multipartRequestBody; MultipartRequestGroup groupStats = groupStatsCase.getMultipartRequestGroup(); output.writeInt(groupStats.getGroupId().getValue().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_GROUP_BODY); } private static void serializeMeterBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { MultipartRequestMeterCase meterCase = (MultipartRequestMeterCase) multipartRequestBody; MultipartRequestMeter meter = meterCase.getMultipartRequestMeter(); output.writeInt(meter.getMeterId().getValue().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_BODY, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_BODY); } private static void serializeMeterConfigBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { MultipartRequestMeterConfigCase meterConfigCase = (MultipartRequestMeterConfigCase) multipartRequestBody; MultipartRequestMeterConfig meterConfig = meterConfigCase.getMultipartRequestMeterConfig(); output.writeInt(meterConfig.getMeterId().getValue().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY); } private void serializeTableFeaturesBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { @@ -285,9 +285,9 @@ private void serializeTableFeaturesBody(final MultipartRequestBody multipartRequ int tableFeatureLengthIndex = output.writerIndex(); output.writeShort(EncodeConstants.EMPTY_LENGTH); output.writeByte(currTableFeature.getTableId()); - ByteBufUtils.padBuffer(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY, output); + output.writeZero(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES_BODY); output.writeBytes(currTableFeature.getName().getBytes()); - ByteBufUtils.padBuffer((32 - currTableFeature.getName().getBytes().length), output); + output.writeZero(32 - currTableFeature.getName().getBytes().length); output.writeLong(currTableFeature.getMetadataMatch().longValue()); output.writeLong(currTableFeature.getMetadataWrite().longValue()); output.writeInt(createTableConfigBitmask(currTableFeature.getConfig())); @@ -364,7 +364,7 @@ private void writeInstructionRelatedTableProperty(final ByteBuf output, padding = paddingNeeded(length); output.writeShort(length); } - ByteBufUtils.padBuffer(padding, output); + output.writeZero(padding); } private static void writeNextTableRelatedTableProperty(final ByteBuf output, @@ -385,7 +385,7 @@ private static void writeNextTableRelatedTableProperty(final ByteBuf output, padding = paddingNeeded(length); output.writeShort(length + padding); } - ByteBufUtils.padBuffer(padding, output); + output.writeZero(padding); } private static int paddingNeeded(final int length) { @@ -422,7 +422,7 @@ private void writeActionsRelatedTableProperty(final ByteBuf output, padding = paddingNeeded(length); output.writeShort(length); } - ByteBufUtils.padBuffer(padding, output); + output.writeZero(padding); } private void writeOxmRelatedTableProperty(final ByteBuf output, @@ -454,7 +454,7 @@ private void writeOxmRelatedTableProperty(final ByteBuf output, padding = paddingNeeded(length); output.writeShort(length); } - ByteBufUtils.padBuffer(padding, output); + output.writeZero(padding); } private void writeExperimenterRelatedTableProperty(final ByteBuf output, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java index d21838cc..4002b8fc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java @@ -34,7 +34,7 @@ public void serialize(final PortModInput message, final ByteBuf outBuffer) { outBuffer.writeInt(createPortConfigBitmask(message.getConfigV10())); outBuffer.writeInt(createPortConfigBitmask(message.getMaskV10())); outBuffer.writeInt(createPortFeaturesBitmask(message.getAdvertiseV10())); - ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE, outBuffer); + outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE); ByteBufUtils.updateOFHeaderLength(outBuffer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java index bbdd122c..606a98c5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java @@ -28,7 +28,7 @@ public class OF10QueueGetConfigInputMessageFactory implements OFSerializer { public void serialize(final PortModInput message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPortNo().getValue().intValue()); - ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_01, outBuffer); + outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01); outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue())); - ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_02, outBuffer); + outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02); outBuffer.writeInt(createPortConfigBitmask(message.getConfig())); outBuffer.writeInt(createPortConfigBitmask(message.getMask())); outBuffer.writeInt(createPortFeaturesBitmask(message.getAdvertise())); - ByteBufUtils.padBuffer(PADDING_IN_PORT_MOD_MESSAGE_03, outBuffer); + outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03); ByteBufUtils.updateOFHeaderLength(outBuffer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java index 43ec60cd..ce7d0cbf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactory.java @@ -30,7 +30,7 @@ public class RoleRequestInputMessageFactory implements OFSerializer public void serialize(final TableModInput message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getTableId().getValue().byteValue()); - ByteBufUtils.padBuffer(PADDING_IN_TABLE_MOD_MESSAGE, outBuffer); + outBuffer.writeZero(PADDING_IN_TABLE_MOD_MESSAGE); outBuffer.writeInt(createConfigBitmask(message.getConfig())); ByteBufUtils.updateOFHeaderLength(outBuffer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 8603f513..4b381d3b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -14,7 +14,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; @@ -44,13 +43,13 @@ public void serialize(final Instruction instruction, final ByteBuf outBuffer) { List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); int lengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - ByteBufUtils.padBuffer(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION, outBuffer); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); int instructionLength = outBuffer.writerIndex() - startIndex; outBuffer.setShort(lengthIndex, instructionLength); } else { outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - ByteBufUtils.padBuffer(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION, outBuffer); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 2ab3a517..3c65edff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -26,7 +25,7 @@ public void serialize(Instruction instruction, ByteBuf outBuffer) { outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); - ByteBufUtils.padBuffer(InstructionConstants.PADDING_IN_GOTO_TABLE, outBuffer); + outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 79e0725d..6c16ea39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -25,7 +24,7 @@ public class WriteMetadataInstructionSerializer extends AbstractInstructionSeria public void serialize(Instruction instruction, ByteBuf outBuffer) { outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); - ByteBufUtils.padBuffer(InstructionConstants.PADDING_IN_WRITE_METADATA, outBuffer); + outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); outBuffer.writeBytes(metadata.getMetadata()); outBuffer.writeBytes(metadata.getMetadataMask()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index 813b6084..bff38ae2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -39,11 +39,11 @@ public void serialize(final MatchV10 match, final ByteBuf outBuffer) { outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlDst().getValue())); outBuffer.writeShort(match.getDlVlan()); outBuffer.writeByte(match.getDlVlanPcp()); - ByteBufUtils.padBuffer(PADDING_IN_MATCH, outBuffer); + outBuffer.writeZero(PADDING_IN_MATCH); outBuffer.writeShort(match.getDlType()); outBuffer.writeByte(match.getNwTos()); outBuffer.writeByte(match.getNwProto()); - ByteBufUtils.padBuffer(PADDING_IN_MATCH_2, outBuffer); + outBuffer.writeZero(PADDING_IN_MATCH_2); Iterable srcGroups = ByteBufUtils.DOT_SPLITTER.split(match.getNwSrc().getValue()); for (String group : srcGroups) { outBuffer.writeByte(Short.parseShort(group)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index afa3e0dd..ceb5963f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -17,7 +17,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; @@ -54,7 +53,7 @@ public void serialize(Match match, ByteBuf outBuffer) { outBuffer.setShort(matchLengthIndex, matchLength); int paddingRemainder = matchLength % EncodeConstants.PADDING; if (paddingRemainder != 0) { - ByteBufUtils.padBuffer(EncodeConstants.PADDING - paddingRemainder, outBuffer); + outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 24985bb8..1920e07d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -21,7 +21,6 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; @@ -125,31 +124,31 @@ public void testMultipartReplyDescBody(){ byte[] mfrDescBytes = new byte[256]; mfrDescBytes = mfrDesc.getBytes(); bb.writeBytes(mfrDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); String hwDesc = "Hardware description"; byte[] hwDescBytes = new byte[256]; hwDescBytes = hwDesc.getBytes(); bb.writeBytes(hwDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - hwDescBytes.length); String swDesc = "Software description"; byte[] swDescBytes = new byte[256]; swDescBytes = swDesc.getBytes(); bb.writeBytes(swDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - swDescBytes.length); String serialNum = "SN0123456789"; byte[] serialNumBytes = new byte[32]; serialNumBytes = serialNum.getBytes(); bb.writeBytes(serialNumBytes); - ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb); + bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); String dpDesc = "switch3 in room 3120"; byte[] dpDescBytes = new byte[256]; dpDescBytes = dpDesc.getBytes(); bb.writeBytes(dpDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - dpDescBytes.length); MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); @@ -827,7 +826,7 @@ public void testMultipartReplyPortDescBody(){ byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN]; portNameBytes = portName.getBytes(); bb.writeBytes(portNameBytes); - ByteBufUtils.padBuffer((MAX_PORT_NAME_LEN - portNameBytes.length), bb); + bb.writeZero(MAX_PORT_NAME_LEN - portNameBytes.length); ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config "00 00 00 05 " + //port state diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 54cdd2ca..d5a1c779 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -17,10 +17,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; @@ -74,31 +73,31 @@ public void testDesc() { byte[] mfrDescBytes = new byte[256]; mfrDescBytes = mfrDesc.getBytes(); bb.writeBytes(mfrDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); String hwDesc = "Hardware description"; byte[] hwDescBytes = new byte[256]; hwDescBytes = hwDesc.getBytes(); bb.writeBytes(hwDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - hwDescBytes.length); String swDesc = "Software description"; byte[] swDescBytes = new byte[256]; swDescBytes = swDesc.getBytes(); bb.writeBytes(swDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - swDescBytes.length); String serialNum = "SN0123456789"; byte[] serialNumBytes = new byte[32]; serialNumBytes = serialNum.getBytes(); bb.writeBytes(serialNumBytes); - ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb); + bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); String dpDesc = "switch3 in room 3120"; byte[] dpDescBytes = new byte[256]; dpDescBytes = dpDesc.getBytes(); bb.writeBytes(dpDescBytes); - ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb); + bb.writeZero(DESC_STR_LEN - dpDescBytes.length); MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); From 22f437174ef99c1b7420274545a7fefcdf674dbb Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 7 Jul 2014 14:10:50 +0200 Subject: [PATCH 033/285] Simplified Multipart TableFeatureProperties serialization Change-Id: Ifdf3936b5985beba23c94bc1e64dde738a844ca2 Signed-off-by: Michal Polkorab --- .../MultipartRequestInputFactory.java | 102 ++++++------------ 1 file changed, 30 insertions(+), 72 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 507a636e..fff96d17 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -12,30 +12,25 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; @@ -75,7 +70,6 @@ public class MultipartRequestInputFactory implements OFSerializer, SerializerRegistryInjector { private static final byte MESSAGE_TYPE = 18; private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = 4; - private static final byte TABLE_FEAT_HEADER_LENGTH = 4; private static final byte INSTRUCTIONS_CODE = 0; private static final byte INSTRUCTIONS_MISS_CODE = 1; private static final byte NEXT_TABLE_CODE = 2; @@ -342,50 +336,38 @@ private void writeTableFeatureProperties(final ByteBuf output, final List instructions = property. getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction(); - int length = TABLE_FEAT_HEADER_LENGTH; - int padding = 0; if (instructions != null) { - for (Instruction instruction : instructions) { - if (instruction.getType().isAssignableFrom(Experimenter.class)) { - length += EncodeConstants.EXPERIMENTER_IDS_LENGTH; - } else { - length += STRUCTURE_HEADER_LENGTH; - } - } - padding = paddingNeeded(length); - output.writeShort(length); TypeKeyMaker keyMaker = TypeKeyMakerFactory .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output); - } else { - padding = paddingNeeded(length); - output.writeShort(length); } - output.writeZero(padding); + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); } private static void writeNextTableRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, final byte code) { + int startIndex = output.writerIndex(); output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); List nextTableIds = property. getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds(); - int length = TABLE_FEAT_HEADER_LENGTH; - int padding = 0; if (nextTableIds != null) { - length += nextTableIds.size(); - padding = paddingNeeded(length); - output.writeShort(length); for (NextTableIds next : nextTableIds) { output.writeByte(next.getTableId()); } - } else { - padding = paddingNeeded(length); - output.writeShort(length + padding); } - output.writeZero(padding); + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); } private static int paddingNeeded(final int length) { @@ -399,69 +381,45 @@ private static int paddingNeeded(final int length) { private void writeActionsRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, final byte code) { + int startIndex = output.writerIndex(); output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); List actions = property. getAugmentation(ActionRelatedTableFeatureProperty.class).getAction(); - int length = TABLE_FEAT_HEADER_LENGTH; - int padding = 0; if (actions != null) { - for (Action action : actions) { - if (action.getType().isAssignableFrom(Experimenter.class)) { - length += EncodeConstants.EXPERIMENTER_IDS_LENGTH; - } else { - length += STRUCTURE_HEADER_LENGTH; - } - } - length += actions.size() * STRUCTURE_HEADER_LENGTH; - padding += paddingNeeded(length); - output.writeShort(length); TypeKeyMaker keyMaker = TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); ListSerializer.serializeHeaderList(actions, keyMaker, registry, output); - } else { - padding = paddingNeeded(length); - output.writeShort(length); } - output.writeZero(padding); + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); } private void writeOxmRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, final byte code) { + int startIndex = output.writerIndex(); output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); List entries = property. getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntries(); - int length = TABLE_FEAT_HEADER_LENGTH; - int padding = 0; if (entries != null) { - // experimenter length / definition ? - length += entries.size() * STRUCTURE_HEADER_LENGTH; - padding = paddingNeeded(length); - output.writeShort(length); - - for (MatchEntries entry : entries) { - MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); - if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); - } else { - key.setExperimenterId(null); - } - HeaderSerializer entrySerializer = registry.getSerializer(key); - entrySerializer.serializeHeader(entry, output); - } - } else { - padding = paddingNeeded(length); - output.writeShort(length); + TypeKeyMaker keyMaker = TypeKeyMakerFactory + .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + ListSerializer.serializeHeaderList(entries, keyMaker, registry, output); } - output.writeZero(padding); + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); } private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) { - OFSerializer serializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, TableFeatureProperties.class)); - serializer.serialize(property, output); + OFSerializer serializer = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, TableFeatureProperties.class)); + serializer.serialize(property, output); } private static int createTableConfigBitmask(final TableConfig tableConfig) { From 7c7f4343f27895a9d714f30bec878fe79b2aa809 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 22 Jul 2014 11:58:45 +0200 Subject: [PATCH 034/285] Added switch TLS keys - this allows to finish exemplary TLS configuration - selfSignedSwitch and selfSignedController keystores were moved to src/test/resources as they are used only in test - other keystores located in src/main/resources were updated with "exemplary-" prefixes to clearly mark them for exemplary usage Change-Id: I821f79e1af8b50fc59e3e5067841a017ec9c1282 Signed-off-by: Michal Polkorab --- .../src/main/resources/exemplary-cacert.pem | 70 ++++++++++++++++++ .../{ctlKeystore => exemplary-ctlKeystore} | Bin ...{ctlTrustStore => exemplary-ctlTrustStore} | Bin .../main/resources/exemplary-switch-cert.pem | 70 ++++++++++++++++++ .../resources/exemplary-switch-privkey.pem | 27 +++++++ ...blishingChannelInitializerFactoryTest.java | 4 +- .../impl/core/SslContextFactoryTest.java | 4 +- .../resources/selfSignedController | Bin .../{main => test}/resources/selfSignedSwitch | Bin 9 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 openflow-protocol-impl/src/main/resources/exemplary-cacert.pem rename openflow-protocol-impl/src/main/resources/{ctlKeystore => exemplary-ctlKeystore} (100%) rename openflow-protocol-impl/src/main/resources/{ctlTrustStore => exemplary-ctlTrustStore} (100%) create mode 100644 openflow-protocol-impl/src/main/resources/exemplary-switch-cert.pem create mode 100644 openflow-protocol-impl/src/main/resources/exemplary-switch-privkey.pem rename openflow-protocol-impl/src/{main => test}/resources/selfSignedController (100%) rename openflow-protocol-impl/src/{main => test}/resources/selfSignedSwitch (100%) diff --git a/openflow-protocol-impl/src/main/resources/exemplary-cacert.pem b/openflow-protocol-impl/src/main/resources/exemplary-cacert.pem new file mode 100644 index 00000000..f726b928 --- /dev/null +++ b/openflow-protocol-impl/src/main/resources/exemplary-cacert.pem @@ -0,0 +1,70 @@ +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 3 (0x3) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=CA, O=Open vSwitch, OU=controllerca, CN=OVS controllerca CA Certificate (2012 Nov 30 22:32:42) + Validity + Not Before: May 27 07:25:06 2014 GMT + Not After : May 24 07:25:06 2024 GMT + Subject: C=US, ST=CA, O=Open vSwitch, OU=controllerca, CN=OVS controllerca CA Certificate (2012 Nov 30 22:32:42) + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:cd:ee:e0:69:c0:bb:06:76:35:dd:7d:cd:d2:1e: + 7a:eb:e3:39:c9:fb:e4:b1:63:2c:4b:29:83:88:b3: + a4:b3:96:de:cd:43:1e:1c:6c:82:88:23:6a:e6:fc: + 1b:69:68:a0:89:00:2f:76:2d:66:60:cf:6a:aa:15: + 22:3d:26:f1:36:c2:a4:af:70:ec:22:eb:ba:fe:43: + 24:42:b1:45:08:ce:51:12:14:03:55:27:74:ed:1b: + 2a:b9:21:ae:3c:a7:4d:63:92:7d:ed:d6:e2:e2:91: + c7:55:30:0b:6f:26:d2:78:67:c2:01:fc:89:f8:20: + 0f:e8:8b:3b:c0:41:bf:de:9f:a6:d2:3c:f2:25:71: + e1:89:81:a8:93:41:78:41:b8:20:df:77:39:39:a6: + 4a:5b:72:b8:ce:89:ad:2b:37:94:48:e0:94:bc:d0: + 7b:08:6a:6f:bb:16:33:03:11:4a:bb:17:19:fa:41: + 19:53:74:62:72:59:ac:b9:1b:81:7c:30:15:4e:e5: + 34:fd:fa:12:da:52:dc:f0:b9:4a:23:3c:69:7b:9d: + f3:62:76:7b:36:0a:3d:7e:77:d2:61:7e:84:20:6f: + 57:ad:9b:5a:1b:53:7b:43:fa:8f:68:d9:cb:a3:c2: + 7f:d8:ea:70:40:25:e0:de:2f:9c:dd:df:bd:d1:73: + be:8d + Exponent: 65537 (0x10001) + Signature Algorithm: md5WithRSAEncryption + 89:cd:f5:bc:e1:c8:ff:d8:9e:12:6d:59:2f:20:90:a4:bc:cb: + cd:13:2c:c0:de:24:81:6b:6a:54:32:6b:bd:2b:c1:1e:3b:b5: + d5:25:49:14:73:54:5b:93:0b:31:30:aa:10:2d:aa:be:41:4e: + ad:b9:1d:19:7d:1a:4b:a6:8b:d7:0b:47:6f:c5:b5:ca:e2:33: + 32:d0:c4:25:b3:b8:ee:f8:e6:34:0b:2b:fc:db:52:62:8b:42: + 00:d3:ba:10:9c:5b:41:c7:59:22:74:58:37:b7:08:7d:fc:ee: + 8a:86:2e:2c:95:d6:b1:26:08:72:a2:db:07:a0:ea:e9:af:db: + 78:64:c0:03:4e:70:b1:c7:42:b8:6b:80:af:0c:82:2a:f8:b4: + 67:34:d2:66:d8:20:66:8d:34:e6:1b:6a:de:94:58:2a:a5:dd: + dd:1e:66:e9:e7:8b:b5:d4:73:03:97:05:9e:f7:ce:f7:f8:fe: + cd:d0:b7:f4:57:0b:08:3b:98:99:6d:8d:00:46:fa:c5:9c:a4: + 42:ad:9c:d1:86:43:70:ae:2f:b2:91:4c:87:96:7e:ff:03:45: + 15:3f:99:1a:44:33:3c:ea:bd:6f:76:8c:09:2a:3b:13:38:a7: + 95:2b:ef:88:ed:f0:98:dc:17:0c:6f:4a:1e:11:03:17:9e:ae: + af:b4:d0:11 +-----BEGIN CERTIFICATE----- +MIIDiDCCAnACAQMwDQYJKoZIhvcNAQEEBQAwgYkxCzAJBgNVBAYTAlVTMQswCQYD +VQQIEwJDQTEVMBMGA1UEChMMT3BlbiB2U3dpdGNoMRUwEwYDVQQLEwxjb250cm9s +bGVyY2ExPzA9BgNVBAMTNk9WUyBjb250cm9sbGVyY2EgQ0EgQ2VydGlmaWNhdGUg +KDIwMTIgTm92IDMwIDIyOjMyOjQyKTAeFw0xNDA1MjcwNzI1MDZaFw0yNDA1MjQw +NzI1MDZaMIGJMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFTATBgNVBAoTDE9w +ZW4gdlN3aXRjaDEVMBMGA1UECxMMY29udHJvbGxlcmNhMT8wPQYDVQQDEzZPVlMg +Y29udHJvbGxlcmNhIENBIENlcnRpZmljYXRlICgyMDEyIE5vdiAzMCAyMjozMjo0 +MikwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDN7uBpwLsGdjXdfc3S +Hnrr4znJ++SxYyxLKYOIs6Szlt7NQx4cbIKII2rm/BtpaKCJAC92LWZgz2qqFSI9 +JvE2wqSvcOwi67r+QyRCsUUIzlESFANVJ3TtGyq5Ia48p01jkn3t1uLikcdVMAtv +JtJ4Z8IB/In4IA/oizvAQb/en6bSPPIlceGJgaiTQXhBuCDfdzk5pkpbcrjOia0r +N5RI4JS80HsIam+7FjMDEUq7Fxn6QRlTdGJyWay5G4F8MBVO5TT9+hLaUtzwuUoj +PGl7nfNidns2Cj1+d9JhfoQgb1etm1obU3tD+o9o2cujwn/Y6nBAJeDeL5zd373R +c76NAgMBAAEwDQYJKoZIhvcNAQEEBQADggEBAInN9bzhyP/YnhJtWS8gkKS8y80T +LMDeJIFralQya70rwR47tdUlSRRzVFuTCzEwqhAtqr5BTq25HRl9Gkumi9cLR2/F +tcriMzLQxCWzuO745jQLK/zbUmKLQgDTuhCcW0HHWSJ0WDe3CH387oqGLiyV1rEm +CHKi2weg6umv23hkwANOcLHHQrhrgK8Mgir4tGc00mbYIGaNNOYbat6UWCql3d0e +Zunni7XUcwOXBZ73zvf4/s3Qt/RXCwg7mJltjQBG+sWcpEKtnNGGQ3CuL7KRTIeW +fv8DRRU/mRpEMzzqvW92jAkqOxM4p5Ur74jt8JjcFwxvSh4RAxeerq+00BE= +-----END CERTIFICATE----- diff --git a/openflow-protocol-impl/src/main/resources/ctlKeystore b/openflow-protocol-impl/src/main/resources/exemplary-ctlKeystore similarity index 100% rename from openflow-protocol-impl/src/main/resources/ctlKeystore rename to openflow-protocol-impl/src/main/resources/exemplary-ctlKeystore diff --git a/openflow-protocol-impl/src/main/resources/ctlTrustStore b/openflow-protocol-impl/src/main/resources/exemplary-ctlTrustStore similarity index 100% rename from openflow-protocol-impl/src/main/resources/ctlTrustStore rename to openflow-protocol-impl/src/main/resources/exemplary-ctlTrustStore diff --git a/openflow-protocol-impl/src/main/resources/exemplary-switch-cert.pem b/openflow-protocol-impl/src/main/resources/exemplary-switch-cert.pem new file mode 100644 index 00000000..012f14b0 --- /dev/null +++ b/openflow-protocol-impl/src/main/resources/exemplary-switch-cert.pem @@ -0,0 +1,70 @@ +Certificate: + Data: + Version: 1 (0x0) + Serial Number: 4 (0x4) + Signature Algorithm: md5WithRSAEncryption + Issuer: C=US, ST=CA, O=Open vSwitch, OU=switchca, CN=OVS switchca CA Certificate (2012 Nov 30 22:32:42) + Validity + Not Before: Jun 9 10:53:04 2014 GMT + Not After : Jun 9 10:53:04 2015 GMT + Subject: C=US, ST=CA, O=Open vSwitch, OU=Open vSwitch certifier, CN=switch id:f7a54496-3eb7-41a2-b7a5-a635390c8510 + Subject Public Key Info: + Public Key Algorithm: rsaEncryption + Public-Key: (2048 bit) + Modulus: + 00:cd:51:74:8c:41:7b:ca:aa:54:b9:39:db:61:49: + 1e:86:a1:e3:ca:61:0c:e4:ec:bb:fd:c7:6c:96:32: + 05:f1:3e:55:60:5d:0a:22:21:dd:fd:07:dd:9e:be: + 32:e8:a0:46:88:5a:7a:ad:0e:32:05:58:60:e0:53: + 41:e2:ad:9d:ac:a7:da:98:04:2f:f9:ae:f3:1f:db: + 2f:4f:e3:46:d3:ed:8e:86:fb:42:06:75:e7:10:f9: + 10:f1:80:00:cd:17:d1:2b:74:5e:90:1e:48:78:46: + 5b:c1:8e:01:a5:8c:8b:08:fa:1d:c5:de:ae:e1:4d: + 47:c4:48:fa:4f:2a:83:c8:39:c8:1e:ac:9d:38:bf: + 46:ec:6f:96:e5:6f:3d:3e:75:e0:cf:58:bc:e6:9e: + 48:9c:e4:e6:bd:72:94:64:27:6c:ff:b6:2e:1a:62: + d5:b6:44:72:f7:d6:72:32:d1:e5:68:43:c2:15:9f: + 47:85:44:98:5c:18:35:4c:32:6a:b5:03:e6:a3:90: + 6f:5c:f6:33:37:a3:2c:ac:fd:f6:5a:eb:46:05:6e: + f3:13:0c:74:b1:3f:c6:31:68:cb:75:5c:f7:f9:c8: + 00:42:64:1b:d7:31:0b:5e:5c:8e:41:a1:1b:f1:af: + c2:d8:44:5a:5c:fa:a7:ad:d2:e9:ee:48:57:f2:bc: + c5:a7 + Exponent: 65537 (0x10001) + Signature Algorithm: md5WithRSAEncryption + 6f:23:ad:3f:62:3c:38:f5:02:8f:f3:e4:09:8b:79:ad:32:48: + e8:0d:01:13:11:d3:94:c7:9a:1b:4b:8c:f4:98:c1:97:e2:9b: + c6:3c:94:d4:52:e6:6d:a6:c8:72:b5:14:ce:d1:03:15:f8:88: + 10:34:36:7e:13:71:61:f5:73:84:e9:58:7a:dc:ae:0b:a8:b6: + d7:73:bb:f1:62:8c:5b:45:58:96:1f:fe:23:5a:fb:ce:d5:10: + a0:ac:1a:0e:ab:12:d3:45:c8:61:93:82:8c:b9:87:d7:9c:95: + 47:2f:d0:ce:5c:35:65:38:48:b3:67:a2:40:dd:55:45:db:7d: + c8:15:d9:cf:80:b6:57:2b:9d:07:c4:96:2a:ee:81:9d:4a:06: + b5:ef:89:13:4b:66:b0:03:23:82:5e:bb:86:65:07:64:49:6c: + 73:7b:38:21:5f:c5:97:e8:97:a7:f1:3d:50:83:c9:7e:c1:cf: + 90:88:a6:31:93:2e:e1:f1:00:e9:f7:9d:02:c4:0b:ce:24:68: + be:b9:6c:48:67:02:f1:d4:11:b0:c3:f8:4d:ee:a5:79:73:95: + 09:dd:4c:c6:ac:57:6e:ef:04:c5:65:af:36:e1:79:29:be:a6: + 06:29:7b:b8:fe:13:94:f6:43:30:3b:7e:67:50:06:7a:69:00: + 8d:04:6c:0e +-----BEGIN CERTIFICATE----- +MIIDgjCCAmoCAQQwDQYJKoZIhvcNAQEEBQAwgYExCzAJBgNVBAYTAlVTMQswCQYD +VQQIEwJDQTEVMBMGA1UEChMMT3BlbiB2U3dpdGNoMREwDwYDVQQLEwhzd2l0Y2hj +YTE7MDkGA1UEAxMyT1ZTIHN3aXRjaGNhIENBIENlcnRpZmljYXRlICgyMDEyIE5v +diAzMCAyMjozMjo0MikwHhcNMTQwNjA5MTA1MzA0WhcNMTUwNjA5MTA1MzA0WjCB +izELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRUwEwYDVQQKEwxPcGVuIHZTd2l0 +Y2gxHzAdBgNVBAsTFk9wZW4gdlN3aXRjaCBjZXJ0aWZpZXIxNzA1BgNVBAMTLnN3 +aXRjaCBpZDpmN2E1NDQ5Ni0zZWI3LTQxYTItYjdhNS1hNjM1MzkwYzg1MTAwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNUXSMQXvKqlS5OdthSR6GoePK +YQzk7Lv9x2yWMgXxPlVgXQoiId39B92evjLooEaIWnqtDjIFWGDgU0HirZ2sp9qY +BC/5rvMf2y9P40bT7Y6G+0IGdecQ+RDxgADNF9ErdF6QHkh4RlvBjgGljIsI+h3F +3q7hTUfESPpPKoPIOcgerJ04v0bsb5blbz0+deDPWLzmnkic5Oa9cpRkJ2z/ti4a +YtW2RHL31nIy0eVoQ8IVn0eFRJhcGDVMMmq1A+ajkG9c9jM3oyys/fZa60YFbvMT +DHSxP8YxaMt1XPf5yABCZBvXMQteXI5BoRvxr8LYRFpc+qet0unuSFfyvMWnAgMB +AAEwDQYJKoZIhvcNAQEEBQADggEBAG8jrT9iPDj1Ao/z5AmLea0ySOgNARMR05TH +mhtLjPSYwZfim8Y8lNRS5m2myHK1FM7RAxX4iBA0Nn4TcWH1c4TpWHrcrguottdz +u/FijFtFWJYf/iNa+87VEKCsGg6rEtNFyGGTgoy5h9eclUcv0M5cNWU4SLNnokDd +VUXbfcgV2c+AtlcrnQfElirugZ1KBrXviRNLZrADI4Jeu4ZlB2RJbHN7OCFfxZfo +l6fxPVCDyX7Bz5CIpjGTLuHxAOn3nQLEC84kaL65bEhnAvHUEbDD+E3upXlzlQnd +TMasV27vBMVlrzbheSm+pgYpe7j+E5T2QzA7fmdQBnppAI0EbA4= +-----END CERTIFICATE----- diff --git a/openflow-protocol-impl/src/main/resources/exemplary-switch-privkey.pem b/openflow-protocol-impl/src/main/resources/exemplary-switch-privkey.pem new file mode 100644 index 00000000..f107e0ed --- /dev/null +++ b/openflow-protocol-impl/src/main/resources/exemplary-switch-privkey.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAzVF0jEF7yqpUuTnbYUkehqHjymEM5Oy7/cdsljIF8T5VYF0K +IiHd/Qfdnr4y6KBGiFp6rQ4yBVhg4FNB4q2drKfamAQv+a7zH9svT+NG0+2OhvtC +BnXnEPkQ8YAAzRfRK3RekB5IeEZbwY4BpYyLCPodxd6u4U1HxEj6TyqDyDnIHqyd +OL9G7G+W5W89PnXgz1i85p5InOTmvXKUZCds/7YuGmLVtkRy99ZyMtHlaEPCFZ9H +hUSYXBg1TDJqtQPmo5BvXPYzN6MsrP32WutGBW7zEwx0sT/GMWjLdVz3+cgAQmQb +1zELXlyOQaEb8a/C2ERaXPqnrdLp7khX8rzFpwIDAQABAoIBAQDHf1EuguZEyvJd +s+D9C24UxTKvz1MXEQutD9vrqJlrifStGFojRiMLnFvzxb1zmWBPVxMCGdvyo6gl +7+AB4E5nmAVnVhJDmoFzv6aeCikk/RtS/sptupwVOt0CuyyMG4tLnNvRTwt9imfX +jyL8d64Uv+qz+6aTFmMYTwygZZ/8qKKwcXpg4sQ37ZXsvT02iqF0hZaF77ELC1rs +YTGsDk1jCRw9y6F2i/8S8FeOOVtmuUI80CzT17QSszm/04FShgRJIguSDpVxpP+x +epL9l4+eaflo0z6g9FlkTRM2qzgFnLnw4CffWefFSi7YDsOsqPnPDf/bqBXKKH95 +acwNA7+JAoGBAOoPolU1gDHqYef6Hfd9tgnYpaDL9yPZyA6xI7Xbuk7catqfmDhD +/86p83NHzH2qH/YwDYzN7u/gslsDMa7jZIeZcQMr0o5GNn6j1xZFpvjTmY7JOKkW +RolAgB+WamjBi10IRE9muB4LxUDEGwKu0uU0op2Q3mycaSoSovtnKxrdAoGBAOCQ +IH9YQZcZBHUk5cohN8TssXs/SazE9dk2Aj6nbgpjtAvVKk5SHv2Qb1BGnetxZnmd +o4pF6mWAHcgJlXFkuA5KORGFURs4KVtX1FPRoywrS105y9qLIlzpKgZtFSmIyjam +7fc1NDjSDO2ZtO027aTg3Rl92ZhAGys1coAj9lBTAoGAeI3C47Zhp9P7x3qo0p86 +Eoo2jMJhMWLrSr3sEa/xnsqicqY+xcQoTm50iMzTQ2pLega4A+zRg1WtJ3lWrqhK +UBk0/xgkI8mAKewDTWJkpMZ/0e5MM7LYc7r4Asz7U6dUO3+Vh3v1muwfFcOr0c7v +qsRYeWVzWmeZNuVQcsJpjjUCgYEA2Uj7+Nw30vElDAhgxB0yLjxsWvnY2vBVhhAp +SeCNrEXe79gZsGDrlaQM4RsDMM6wPhrXJDMUY5P8vRLw5CB1q3YMFDTwTqsf8T9h +tpzRCyr1KEaFRnh8DnSZ8k/YOzEdoJYTCbEUT6qHUdv5YdJVTcU6irDoO9ZDs6Jq +oSyq5/sCgYApxI2wxRj2kfI2x+0/EXjGtCkjt12T2T7aQkl1DyOKXcJPpuFyAVl2 +Q70egHEVM5n7JrMux6lQlapoK7fhyak1HPiwE27UbErVAExNJiCshhYKsPLi4YYJ +1S1Uo9Z8u3jlze4WgeeUxs+vshNu/Uw8k4kujRG1KBUjVTALte0K2A== +-----END RSA PRIVATE KEY----- diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java index c6ececd8..b24192a1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java @@ -42,8 +42,8 @@ public class PublishingChannelInitializerFactoryTest { public void setUp() { MockitoAnnotations.initMocks(this); factory = new PublishingChannelInitializerFactory(); - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/ctlTrustStore", - PathType.CLASSPATH, KeystoreType.JKS, "/ctlKeystore", PathType.CLASSPATH); + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", + PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH); factory.setDeserializationFactory(deserializationFactory); factory.setSerializationFactory(serializationFactory); factory.setSwitchConnectionHandler(switchConnectionHandler); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index 2c45c0b0..652e086c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -35,8 +35,8 @@ public class SslContextFactoryTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/ctlTrustStore", - PathType.CLASSPATH, KeystoreType.JKS, "/ctlKeystore", PathType.CLASSPATH) ; + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", + PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH) ; sslContextFactory = new SslContextFactory(tlsConfiguration); } diff --git a/openflow-protocol-impl/src/main/resources/selfSignedController b/openflow-protocol-impl/src/test/resources/selfSignedController similarity index 100% rename from openflow-protocol-impl/src/main/resources/selfSignedController rename to openflow-protocol-impl/src/test/resources/selfSignedController diff --git a/openflow-protocol-impl/src/main/resources/selfSignedSwitch b/openflow-protocol-impl/src/test/resources/selfSignedSwitch similarity index 100% rename from openflow-protocol-impl/src/main/resources/selfSignedSwitch rename to openflow-protocol-impl/src/test/resources/selfSignedSwitch From 0b1daa34f49ab93e08b5be06b50424c81efd0c82 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Thu, 24 Jul 2014 00:17:22 +0200 Subject: [PATCH 035/285] Corrected equals & hashcode methods in extension keys - corrected equals & hashcode methods in keys - tests for equals & hashcode methods in keys Signed-off-by: Martin Sunal --- .../api/extensibility/MessageCodeKey.java | 4 +- .../api/extensibility/MessageTypeKey.java | 7 +- .../api/keys/ActionDeserializerKey.java | 10 ++- .../api/keys/ActionSerializerKey.java | 14 +++- .../api/keys/InstructionDeserializerKey.java | 10 ++- .../api/keys/InstructionSerializerKey.java | 24 ++++--- .../api/keys/MatchEntryDeserializerKey.java | 11 +++- .../api/keys/MatchEntrySerializerKey.java | 17 +++-- .../ExperimenterActionDeserializerKey.java | 30 +-------- .../ExperimenterActionSerializerKey.java | 39 +---------- ...xperimenterInstructionDeserializerKey.java | 30 +-------- .../ExperimenterInstructionSerializerKey.java | 40 +----------- .../api/keys/extensibility/KeysTest.java | 65 +++++++++++++++++++ 13 files changed, 152 insertions(+), 149 deletions(-) create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index b850eae9..86d5a4d1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -34,6 +34,7 @@ public int hashCode() { int result = 1; result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); result = prime * result + msgType; + result = prime * result + msgVersion; return result; } @@ -43,7 +44,7 @@ public boolean equals(Object obj) { return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof MessageCodeKey)) return false; MessageCodeKey other = (MessageCodeKey) obj; if (clazz == null) { @@ -62,4 +63,5 @@ public boolean equals(Object obj) { public String toString() { return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java index 0ece4c61..d5d303e4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java @@ -38,7 +38,8 @@ public String toString() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((msgType == null) ? 0 : msgType.getName().hashCode()); + result = prime * result + ((msgType == null) ? 0 : msgType.hashCode()); + result = prime * result + msgVersion; return result; } @@ -48,13 +49,13 @@ public boolean equals(Object obj) { return true; if (obj == null) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof MessageTypeKey)) return false; MessageTypeKey other = (MessageTypeKey) obj; if (msgType == null) { if (other.msgType != null) return false; - } else if (!other.msgType.getName().equals(msgType.getName())) + } else if (!msgType.equals(other.msgType)) return false; if (msgVersion != other.msgVersion) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index d329e7ef..db17b3b5 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -29,13 +29,21 @@ public ActionDeserializerKey(short version, this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof ActionDeserializerKey)) return false; ActionDeserializerKey other = (ActionDeserializerKey) obj; if (experimenterId == null) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 623bdea4..38b8cd49 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -33,16 +33,24 @@ public ActionSerializerKey(short msgVersion, Class actionType, this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof ActionSerializerKey)) return false; - @SuppressWarnings("rawtypes") - ActionSerializerKey other = (ActionSerializerKey) obj; + ActionSerializerKey other = (ActionSerializerKey) obj; if (actionType == null) { if (other.actionType != null) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index 95a5715b..91f8977a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -29,13 +29,21 @@ public InstructionDeserializerKey(short version, int type, this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) + if (!(obj instanceof InstructionDeserializerKey)) return false; InstructionDeserializerKey other = (InstructionDeserializerKey) obj; if (experimenterId == null) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 738156a0..899568dc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -35,26 +35,34 @@ public InstructionSerializerKey(short msgVersion, Class instructionType, this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("rawtypes") - InstructionSerializerKey other = (InstructionSerializerKey) obj; - if (instructionType == null) { - if (other.instructionType != null) - return false; - } else if (!instructionType.equals(other.instructionType)) + if (!(obj instanceof InstructionSerializerKey)) return false; + InstructionSerializerKey other = (InstructionSerializerKey) obj; if (experimenterId == null) { if (other.experimenterId != null) return false; } else if (!experimenterId.equals(other.experimenterId)) return false; + if (instructionType == null) { + if (other.instructionType != null) + return false; + } else if (!instructionType.equals(other.instructionType)) + return false; return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index bf703561..593ca8d6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -16,7 +16,7 @@ * @author michal.polkorab * */ -public class MatchEntryDeserializerKey extends MessageCodeKey +public final class MatchEntryDeserializerKey extends MessageCodeKey implements ExperimenterDeserializerKey { private int oxmField; @@ -40,6 +40,15 @@ public void setExperimenterId(Long experimenterId) { this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + oxmField; + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index 8ceb7ccb..c7f07f62 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -19,8 +19,8 @@ * @param oxm_class (see specification) * @param oxm_field (see specification) */ -public class MatchEntrySerializerKey - extends MessageTypeKey implements ExperimenterSerializerKey{ +public final class MatchEntrySerializerKey + extends MessageTypeKey implements ExperimenterSerializerKey { private Class oxmClass; private Class oxmField; @@ -46,6 +46,16 @@ public void setExperimenterId(Long experimenterId) { this.experimenterId = experimenterId; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode()); + result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) @@ -54,8 +64,7 @@ public boolean equals(Object obj) { return false; if (getClass() != obj.getClass()) return false; - @SuppressWarnings("rawtypes") - MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; + MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; if (experimenterId == null) { if (other.experimenterId != null) return false; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java index 1b21379e..b700f04b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -8,46 +8,22 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** * @author michal.polkorab * */ -public class ExperimenterActionDeserializerKey extends MessageCodeKey +public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey implements ExperimenterDeserializerKey { - private Long experimenterId; /** * @param version protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterActionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, Action.class); - this.experimenterId = experimenterId; + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterActionDeserializerKey other = (ExperimenterActionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index 23e4640c..989e1ba7 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -8,54 +8,21 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; /** * @author michal.polkorab */ -public class ExperimenterActionSerializerKey extends MessageTypeKey +public final class ExperimenterActionSerializerKey extends ActionSerializerKey implements ExperimenterSerializerKey { - private Class actionType; - private Long experimenterId; - /** * @param msgVersion protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Action.class); - this.actionType = Experimenter.class; - this.experimenterId = experimenterId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; - if (actionType == null) { - if (other.actionType != null) - return false; - } else if (!actionType.equals(other.actionType)) - return false; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; + super(msgVersion, Experimenter.class, experimenterId); } - @Override - public String toString() { - return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java index 12270310..cfe99569 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -8,46 +8,22 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab * */ -public class ExperimenterInstructionDeserializerKey extends MessageCodeKey +public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey implements ExperimenterDeserializerKey { - private Long experimenterId; /** * @param version protocol wire version * @param experimenterId */ public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, Instruction.class); - this.experimenterId = experimenterId; + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterInstructionDeserializerKey other = (ExperimenterInstructionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java index 0a4541b1..28201506 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java @@ -8,55 +8,21 @@ package org.opendaylight.openflowjava.protocol.api.keys.experimenter; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; /** * @author michal.polkorab */ -public class ExperimenterInstructionSerializerKey extends MessageTypeKey +public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey implements ExperimenterSerializerKey { - private Class instructionType; - private Long experimenterId; - /** * @param msgVersion protocol wire version * @param experimenterId experimenter / vendor ID */ public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Instruction.class); - this.instructionType = Experimenter.class; - this.experimenterId = experimenterId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ExperimenterInstructionSerializerKey other = (ExperimenterInstructionSerializerKey) obj; - if (instructionType == null) { - if (other.instructionType != null) - return false; - } else if (!instructionType.equals(other.instructionType)) - return false; - if (experimenterId == null) { - if (other.experimenterId != null) - return false; - } else if (!experimenterId.equals(other.experimenterId)) - return false; - return true; + super(msgVersion, Experimenter.class, experimenterId); } - @Override - public String toString() { - return super.toString() + " instructionType type: " + instructionType.getName() - + " vendorID: " + experimenterId; - } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java new file mode 100644 index 00000000..9b4cf744 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java @@ -0,0 +1,65 @@ +package org.opendaylight.openflowjava.protocol.api.keys.extensibility; + +import junit.framework.Assert; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; + +/** + * @author michal.polkorab + */ +public class KeysTest { + + /** + * Testing equals() and hashcode() methods of extension deserializer's keys + */ + @Test + public void testEqualsAndHashcodeOfDeserializerKeys() { + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + EncodeConstants.EXPERIMENTER_VALUE, 1L); + ExperimenterActionDeserializerKey experimenterActionDeserializerKey = new ExperimenterActionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(actionDeserializerKey, experimenterActionDeserializerKey); + Assert.assertEquals(actionDeserializerKey.hashCode(), experimenterActionDeserializerKey.hashCode()); + + InstructionDeserializerKey instructionDeserializerKey = new InstructionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, 1L); + ExperimenterInstructionDeserializerKey experimenterInstructionDeserializerKey = new ExperimenterInstructionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey); + Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode()); + + + } + + /** + * Testing equals() and hashcode() methods of extension serializer's keys + */ + @Test + public void testEqualsAndHashcodeOfActionDeserializerKeys() { + ActionSerializerKey actionSerializerKey = new ActionSerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L); + ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey); + Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode()); + + InstructionSerializerKey instructionSerializerKey = new InstructionSerializerKey<>( + EncodeConstants.OF13_VERSION_ID, + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class, + 1L); + ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L); + Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey); + Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode()); + } + +} From 87de0af53cc031d417d917df7a8fe113a7e7f581 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Mon, 14 Jul 2014 14:27:09 +0200 Subject: [PATCH 036/285] Nicira extensions in OpenFlowJava library - creates and registers codecs(serializers & deserializers) for: actions: reg-load reg-move matches: NXM_NX_REG(0-7) NXM_NX_TUN_ID NXM_NX_ARP_SHA NXM_NX_ARP_THA NXM_OF_ARP_OP NXM_OF_ARP_SPA NXM_OF_ARP_TPA NXM_NX_TUN_IPV4_DST NXM_NX_TUN_IPV4_SRC NXM_OF_ETH_SRC NXM_OF_ETH_DST - moved CoSS config to appropriate place - added revision to ietf-yang-types Change-Id: If847b9098722337318109d3ffe34ddaca8b6b363 Signed-off-by: Martin Sunal Signed-off-by: Michal Rehak --- openflow-extension-nicira/pom.xml | 114 ++++++++++++ .../impl/NiciraExtensionProviderModule.java | 26 +++ .../NiciraExtensionProviderModuleFactory.java | 13 ++ .../openflowjava/nx/NiciraConstants.java | 8 + .../nx/NiciraExtensionsRegistrator.java | 132 ++++++++++++++ .../openflowjava/nx/NiciraMatchCodecs.java | 54 ++++++ .../nx/codec/action/ActionCodec.java | 84 +++++++++ .../nx/codec/action/RegLoadCodec.java | 33 ++++ .../nx/codec/action/RegMoveCodec.java | 35 ++++ .../nx/codec/match/AbstractMatchCodec.java | 88 +++++++++ .../nx/codec/match/AbstractRegCodec.java | 49 +++++ .../nx/codec/match/ArpOpCodec.java | 69 +++++++ .../nx/codec/match/ArpShaCodec.java | 74 ++++++++ .../nx/codec/match/ArpSpaCodec.java | 69 +++++++ .../nx/codec/match/ArpThaCodec.java | 74 ++++++++ .../nx/codec/match/ArpTpaCodec.java | 69 +++++++ .../nx/codec/match/EthDstCodec.java | 74 ++++++++ .../nx/codec/match/EthSrcCodec.java | 74 ++++++++ .../nx/codec/match/NxmHeader.java | 94 ++++++++++ .../nx/codec/match/Reg0Codec.java | 29 +++ .../nx/codec/match/Reg1Codec.java | 29 +++ .../nx/codec/match/Reg2Codec.java | 29 +++ .../nx/codec/match/Reg3Codec.java | 29 +++ .../nx/codec/match/Reg4Codec.java | 29 +++ .../nx/codec/match/Reg5Codec.java | 29 +++ .../nx/codec/match/Reg6Codec.java | 29 +++ .../nx/codec/match/Reg7Codec.java | 29 +++ .../nx/codec/match/TunIdCodec.java | 72 ++++++++ .../nx/codec/match/TunIpv4DstCodec.java | 69 +++++++ .../nx/codec/match/TunIpv4SrcCodec.java | 69 +++++++ .../initial/43-openflow-nx-config.xml | 28 +++ .../src/main/yang/nicira-action.yang | 57 ++++++ .../yang/nicira-extension-provider-impl.yang | 36 ++++ .../src/main/yang/nicira-match.yang | 171 ++++++++++++++++++ pom.xml | 1 + 35 files changed, 1968 insertions(+) create mode 100644 openflow-extension-nicira/pom.xml create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java create mode 100644 openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml create mode 100644 openflow-extension-nicira/src/main/yang/nicira-action.yang create mode 100644 openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang create mode 100644 openflow-extension-nicira/src/main/yang/nicira-match.yang diff --git a/openflow-extension-nicira/pom.xml b/openflow-extension-nicira/pom.xml new file mode 100644 index 00000000..750b209a --- /dev/null +++ b/openflow-extension-nicira/pom.xml @@ -0,0 +1,114 @@ + + + 4.0.0 + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.5-SNAPSHOT + + openflow-extension-nicira + bundle + Openflow Protocol Library - Nicira extensions + http://maven.apache.org + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${jmxGeneratorPath} + + + urn:opendaylight:params:xml:ns:yang:controller:config==org.opendaylight.controller.config.yang + + + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + ${salGeneratorPath} + + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + ${project.build.directory}/site/models + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${config.version} + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.generator.version} + jar + + + + + + + + + + ${project.groupId} + openflow-protocol-api + ${project.version} + + + ${project.groupId} + openflow-protocol-spi + ${project.version} + + + org.opendaylight.openflowjava + util + ${project.version} + + + org.opendaylight.yangtools.model + yang-ext + + + io.netty + netty-buffer + + + junit + junit + test + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + org.opendaylight.controller + config-api + + + diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java new file mode 100644 index 00000000..d62b4ea7 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java @@ -0,0 +1,26 @@ +package org.opendaylight.controller.config.yang.openflow.extension.nicira.impl; + +import org.opendaylight.openflowjava.nx.NiciraExtensionsRegistrator; + +public class NiciraExtensionProviderModule extends org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.AbstractNiciraExtensionProviderModule { + public NiciraExtensionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NiciraExtensionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.NiciraExtensionProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + NiciraExtensionsRegistrator niciraExtensionsRegistrator = new NiciraExtensionsRegistrator(getOpenflowSwitchConnectionProviderDependency()); + niciraExtensionsRegistrator.registerNiciraExtensions(); + return niciraExtensionsRegistrator; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java new file mode 100644 index 00000000..222747b6 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: nicira-extension-provider-impl yang module local name: openflow-extension-nicira +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Jul 11 13:27:17 CEST 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.openflow.extension.nicira.impl; +public class NiciraExtensionProviderModuleFactory extends org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.AbstractNiciraExtensionProviderModuleFactory { + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java new file mode 100644 index 00000000..b1ed1596 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java @@ -0,0 +1,8 @@ +package org.opendaylight.openflowjava.nx; + + +public class NiciraConstants { + + public static final Long NX_VENDOR_ID = 0x00002320L; + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java new file mode 100644 index 00000000..551b9e9d --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java @@ -0,0 +1,132 @@ +package org.opendaylight.openflowjava.nx; + +import java.util.List; + +import org.opendaylight.openflowjava.nx.codec.action.ActionCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; +import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg3Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec; +import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec; +import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec; +import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; + +import com.google.common.base.Preconditions; + +public class NiciraExtensionsRegistrator implements AutoCloseable { + + private static final ActionCodec ACTION_CODEC = new ActionCodec(); + private final List providers; + + /** + * @param providers cannot be null + */ + public NiciraExtensionsRegistrator(List providers) { + Preconditions.checkNotNull(providers); + this.providers = providers; + } + + public void registerNiciraExtensions() { + for (SwitchConnectionProvider provider : providers) { + provider.registerActionDeserializer(ActionCodec.DESERIALIZER_KEY, ACTION_CODEC); + provider.registerActionSerializer(ActionCodec.SERIALIZER_KEY, ACTION_CODEC); + provider.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); + provider.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); + provider.registerMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC); + provider.registerMatchEntryDeserializer(Reg1Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC); + provider.registerMatchEntrySerializer(Reg2Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG2_CODEC); + provider.registerMatchEntryDeserializer(Reg2Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG2_CODEC); + provider.registerMatchEntrySerializer(Reg3Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG3_CODEC); + provider.registerMatchEntryDeserializer(Reg3Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG3_CODEC); + provider.registerMatchEntrySerializer(Reg4Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG4_CODEC); + provider.registerMatchEntryDeserializer(Reg4Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG4_CODEC); + provider.registerMatchEntrySerializer(Reg5Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG5_CODEC); + provider.registerMatchEntryDeserializer(Reg5Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG5_CODEC); + provider.registerMatchEntrySerializer(Reg6Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG6_CODEC); + provider.registerMatchEntryDeserializer(Reg6Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG6_CODEC); + provider.registerMatchEntrySerializer(Reg7Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG7_CODEC); + provider.registerMatchEntryDeserializer(Reg7Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG7_CODEC); + provider.registerMatchEntrySerializer(TunIdCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_ID_CODEC); + provider.registerMatchEntryDeserializer(TunIdCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_ID_CODEC); + provider.registerMatchEntrySerializer(ArpOpCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_OP_CODEC); + provider.registerMatchEntryDeserializer(ArpOpCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_OP_CODEC); + provider.registerMatchEntrySerializer(ArpShaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_SHA_CODEC); + provider.registerMatchEntryDeserializer(ArpShaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_SHA_CODEC); + provider.registerMatchEntrySerializer(ArpSpaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_SPA_CODEC); + provider.registerMatchEntryDeserializer(ArpSpaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_SPA_CODEC); + provider.registerMatchEntrySerializer(ArpThaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_THA_CODEC); + provider.registerMatchEntryDeserializer(ArpThaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_THA_CODEC); + provider.registerMatchEntrySerializer(ArpTpaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_TPA_CODEC); + provider.registerMatchEntryDeserializer(ArpTpaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_TPA_CODEC); + provider.registerMatchEntrySerializer(EthDstCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC); + provider.registerMatchEntryDeserializer(EthDstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC); + provider.registerMatchEntrySerializer(EthSrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_SRC_CODEC); + provider.registerMatchEntryDeserializer(EthSrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_SRC_CODEC); + provider.registerMatchEntrySerializer(TunIpv4DstCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC); + provider.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC); + provider.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); + provider.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); + } + } + + public void unregisterExtensions() { + for (SwitchConnectionProvider provider : providers) { + provider.unregisterSerializer(ActionCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ActionCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg0Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg0Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg1Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg1Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg2Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg2Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg3Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg3Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg4Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg4Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg5Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg5Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg6Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg6Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(Reg7Codec.SERIALIZER_KEY); + provider.unregisterDeserializer(Reg7Codec.DESERIALIZER_KEY); + provider.unregisterSerializer(TunIdCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(TunIdCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(ArpOpCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ArpOpCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(ArpShaCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ArpShaCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(ArpSpaCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ArpSpaCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(ArpThaCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ArpThaCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(ArpTpaCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(ArpTpaCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(EthDstCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(EthDstCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(EthSrcCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(EthSrcCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(TunIpv4DstCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(TunIpv4SrcCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY); + } + } + + @Override + public void close() throws Exception { + unregisterExtensions(); + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java new file mode 100644 index 00000000..0e166ba8 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.nx; + +import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec; +import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; +import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg3Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec; +import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec; +import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec; +import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec; +import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec; + +/** + * @author msunal + * + */ +public class NiciraMatchCodecs { + + public static final Reg0Codec REG0_CODEC = new Reg0Codec(); + public static final Reg1Codec REG1_CODEC = new Reg1Codec(); + public static final Reg2Codec REG2_CODEC = new Reg2Codec(); + public static final Reg3Codec REG3_CODEC = new Reg3Codec(); + public static final Reg4Codec REG4_CODEC = new Reg4Codec(); + public static final Reg5Codec REG5_CODEC = new Reg5Codec(); + public static final Reg6Codec REG6_CODEC = new Reg6Codec(); + public static final Reg7Codec REG7_CODEC = new Reg7Codec(); + public static final TunIdCodec TUN_ID_CODEC = new TunIdCodec(); + public static final ArpOpCodec ARP_OP_CODEC = new ArpOpCodec(); + public static final ArpShaCodec ARP_SHA_CODEC = new ArpShaCodec(); + public static final ArpSpaCodec ARP_SPA_CODEC = new ArpSpaCodec(); + public static final ArpThaCodec ARP_THA_CODEC = new ArpThaCodec(); + public static final ArpTpaCodec ARP_TPA_CODEC = new ArpTpaCodec(); + public static final EthDstCodec ETH_DST_CODEC = new EthDstCodec(); + public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec(); + public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec(); + public static final TunIpv4SrcCodec TUN_IPV4_SRC_CODEC = new TunIpv4SrcCodec(); + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java new file mode 100644 index 00000000..3d58439c --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java @@ -0,0 +1,84 @@ +package org.opendaylight.openflowjava.nx.codec.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.nx.NiciraConstants; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxActionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ActionCodec implements OFSerializer, OFDeserializer { + + private static final Logger LOG = LoggerFactory.getLogger(ActionCodec.class); + + public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); + public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); + private static final RegMoveCodec regMoveCodec = new RegMoveCodec(); + private static final RegLoadCodec regLoadCodec = new RegLoadCodec(); + + @Override + public void serialize(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + OfjAugNxAction augNxAction = input.getAugmentation(OfjAugNxAction.class); + if (augNxAction == null) { + LOG.info("Action {} does not have any serializer.", input.getClass()); + return; + } + if (augNxAction.getActionRegMove() != null) { + writeMsgLengthVendorIdSubtypeToBuffer(RegMoveCodec.LENGTH, RegMoveCodec.SUBTYPE, outBuffer); + regMoveCodec.serialize(augNxAction.getActionRegMove(), outBuffer); + } else if (augNxAction.getActionRegLoad() != null) { + writeMsgLengthVendorIdSubtypeToBuffer(RegLoadCodec.LENGTH, RegLoadCodec.SUBTYPE, outBuffer); + regLoadCodec.serialize(augNxAction.getActionRegLoad(), outBuffer); + } else { + LOG.info("Action {} does not have any serializer.", input.getClass()); + } + } + + private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) { + outBuffer.writeShort(msgLength); + outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); + outBuffer.writeShort(subtype); + } + + @Override + public Action deserialize(ByteBuf message) { + // size of experimenter type + message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + // size of length + message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(message.readUnsignedInt())); + int subtype = message.readUnsignedShort(); + OfjAugNxActionBuilder augNxActionBuilder = new OfjAugNxActionBuilder(); + switch (subtype) { + case RegMoveCodec.SUBTYPE: + augNxActionBuilder.setActionRegMove(regMoveCodec.deserialize(message)); + break; + case RegLoadCodec.SUBTYPE: + augNxActionBuilder.setActionRegLoad(regLoadCodec.deserialize(message)); + break; + default: + LOG.info("Action {} does not have any deserializer.", subtype); + return null; + } + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Experimenter.class); + actionBuilder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + actionBuilder.addAugmentation(OfjAugNxAction.class, augNxActionBuilder.build()); + return actionBuilder.build(); + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java new file mode 100644 index 00000000..0776edd4 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java @@ -0,0 +1,33 @@ +package org.opendaylight.openflowjava.nx.codec.action; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder; + +public class RegLoadCodec implements OFSerializer, OFDeserializer { + + public static final int LENGTH = 24; + public static final byte SUBTYPE = 7; // NXAST_REG_LOAD + + @Override + public void serialize(ActionRegLoad input, ByteBuf outBuffer) { + outBuffer.writeShort(input.getOfsNbits()); + outBuffer.writeInt(input.getDst().intValue()); + outBuffer.writeLong(input.getValue().longValue()); + } + + @Override + public ActionRegLoad deserialize(ByteBuf message) { + ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder(); + actionRegLoadBuilder.setOfsNbits(message.readUnsignedShort()); + actionRegLoadBuilder.setDst(message.readUnsignedInt()); + actionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong())); + return actionRegLoadBuilder.build(); + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java new file mode 100644 index 00000000..c7965880 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java @@ -0,0 +1,35 @@ +package org.opendaylight.openflowjava.nx.codec.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMove; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMoveBuilder; + +public class RegMoveCodec implements OFSerializer, OFDeserializer { + + public static final int LENGTH = 24; + public static final byte SUBTYPE = 6; // NXAST_REG_MOVE + + @Override + public void serialize(ActionRegMove input, ByteBuf outBuffer) { + outBuffer.writeShort(input.getNBits()); + outBuffer.writeShort(input.getSrcOfs()); + outBuffer.writeShort(input.getDstOfs()); + outBuffer.writeInt(input.getSrc().intValue()); + outBuffer.writeInt(input.getDst().intValue()); + } + + @Override + public ActionRegMove deserialize(ByteBuf message) { + ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder(); + actionRegMoveBuilder.setNBits(message.readUnsignedShort()); + actionRegMoveBuilder.setSrcOfs(message.readUnsignedShort()); + actionRegMoveBuilder.setDstOfs(message.readUnsignedShort()); + actionRegMoveBuilder.setSrc(message.readUnsignedInt()); + actionRegMoveBuilder.setDst(message.readUnsignedInt()); + return actionRegMoveBuilder.build(); + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java new file mode 100644 index 00000000..f7d5b53e --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java @@ -0,0 +1,88 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.nx.NiciraConstants; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public abstract class AbstractMatchCodec implements OFSerializer, OFDeserializer { + + private NxmHeader headerWithMask; + private NxmHeader headerWithoutMask; + + protected MatchEntriesBuilder deserializeHeader(ByteBuf message) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(getOxmClass()); + // skip oxm_class - provided + message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setOxmMatchField(getNxmField()); + boolean hasMask = (message.readUnsignedByte() & 1) != 0; + builder.setHasMask(hasMask); + // skip match entry length - not needed + message.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + ExperimenterIdMatchEntryBuilder experimenterIdMatchEntryBuilder = new ExperimenterIdMatchEntryBuilder(); + experimenterIdMatchEntryBuilder.setExperimenter(new ExperimenterId(NiciraConstants.NX_VENDOR_ID)); + builder.addAugmentation(ExperimenterIdMatchEntry.class, experimenterIdMatchEntryBuilder.build()); + return builder; + } + + protected void serializeHeader(MatchEntries input, ByteBuf outBuffer) { + outBuffer.writeInt(serializeHeaderToLong(input.isHasMask()).intValue()); + } + + private Long serializeHeaderToLong(boolean hasMask) { + if (hasMask) { + return getHeaderWithHasMask().toLong(); + } + return getHeaderWithoutHasMask().toLong(); + } + + public NxmHeader getHeaderWithoutHasMask() { + if (headerWithoutMask == null) { + headerWithoutMask = new NxmHeader(getOxmClassCode(), getNxmFieldCode(), false, getValueLength()); + } + return headerWithoutMask; + } + + public NxmHeader getHeaderWithHasMask() { + if (headerWithMask == null) { + headerWithMask = new NxmHeader(getOxmClassCode(), getNxmFieldCode(), true, getValueLength()); + } + return headerWithMask; + } + + /** + * @return numeric representation of nxm_field + */ + public abstract int getNxmFieldCode(); + + /** + * @return numeric representation of oxm_class + */ + public abstract int getOxmClassCode(); + + /** + * @return match entry value length + */ + public abstract int getValueLength(); + + /** + * @return nxm_field class + */ + public abstract Class getNxmField(); + + /** + * @return oxm_class class + */ + public abstract Class getOxmClass(); + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java new file mode 100644 index 00000000..abafe097 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java @@ -0,0 +1,49 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.reg.grouping.RegValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public abstract class AbstractRegCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 4; + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setRegValues(new RegValuesBuilder().setValue(message.readUnsignedInt()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Long value = input.getAugmentation(OfjAugNxMatch.class).getRegValues().getValue(); + outBuffer.writeInt(value.intValue()); + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java new file mode 100644 index 00000000..9e410042 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.op.grouping.ArpOpValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class ArpOpCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 2; + private static final int NXM_FIELD_CODE = 15; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpOp.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Integer value = input.getAugmentation(OfjAugNxMatch.class).getArpOpValues().getValue(); + outBuffer.writeShort(value); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setArpOpValues(new ArpOpValuesBuilder().setValue(message.readUnsignedShort()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfArpOp.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java new file mode 100644 index 00000000..de8ca0c8 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java @@ -0,0 +1,74 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.arp.sha.grouping.ArpShaValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class ArpShaCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 6; + private static final int NXM_FIELD_CODE = 17; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpSha.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + String value = input.getAugmentation(OfjAugNxMatch.class).getArpShaValues().getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + byte[] address = new byte[VALUE_LENGTH]; + message.readBytes(address); + augNxMatchBuilder.setArpShaValues(new ArpShaValuesBuilder().setMacAddress( + new MacAddress(ByteBufUtils.macAddressToString(address))).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmNxArpSha.class; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java new file mode 100644 index 00000000..487c64c9 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.spa.grouping.ArpSpaValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class ArpSpaCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 4; + private static final int NXM_FIELD_CODE = 16; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpSpa.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Long value = input.getAugmentation(OfjAugNxMatch.class).getArpSpaValues().getValue(); + outBuffer.writeInt(value.intValue()); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setArpSpaValues(new ArpSpaValuesBuilder().setValue(message.readUnsignedInt()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfArpSpa.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java new file mode 100644 index 00000000..07cf46d8 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java @@ -0,0 +1,74 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.arp.tha.grouping.ArpThaValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class ArpThaCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 6; + private static final int NXM_FIELD_CODE = 18; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpTha.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + String value = input.getAugmentation(OfjAugNxMatch.class).getArpThaValues().getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + byte[] address = new byte[VALUE_LENGTH]; + message.readBytes(address); + augNxMatchBuilder.setArpThaValues(new ArpThaValuesBuilder().setMacAddress( + new MacAddress(ByteBufUtils.macAddressToString(address))).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmNxArpTha.class; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java new file mode 100644 index 00000000..04fc5ad1 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.tpa.grouping.ArpTpaValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class ArpTpaCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 4; + private static final int NXM_FIELD_CODE = 16; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Long value = input.getAugmentation(OfjAugNxMatch.class).getArpTpaValues().getValue(); + outBuffer.writeInt(value.intValue()); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setArpTpaValues(new ArpTpaValuesBuilder().setValue(message.readUnsignedInt()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfArpTpa.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java new file mode 100644 index 00000000..dacbe1f8 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java @@ -0,0 +1,74 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.dst.grouping.EthDstValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class EthDstCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 6; + private static final int NXM_FIELD_CODE = 2; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + String value = input.getAugmentation(OfjAugNxMatch.class).getEthDstValues().getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + byte[] address = new byte[VALUE_LENGTH]; + message.readBytes(address); + augNxMatchBuilder.setEthDstValues(new EthDstValuesBuilder().setMacAddress( + new MacAddress(ByteBufUtils.macAddressToString(address))).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfEthDst.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java new file mode 100644 index 00000000..38c27421 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java @@ -0,0 +1,74 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.src.grouping.EthSrcValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class EthSrcCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 6; + private static final int NXM_FIELD_CODE = 2; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthSrc.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + String value = input.getAugmentation(OfjAugNxMatch.class).getEthSrcValues().getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + byte[] address = new byte[VALUE_LENGTH]; + message.readBytes(address); + augNxMatchBuilder.setEthSrcValues(new EthSrcValuesBuilder().setMacAddress( + new MacAddress(ByteBufUtils.macAddressToString(address))).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfEthSrc.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java new file mode 100644 index 00000000..ebcf669b --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.nx.codec.match; + +import com.google.common.primitives.Ints; + +/** + * @author msunal + * + */ +public class NxmHeader { + + private final long headerAsLong; + private final int oxmClass; + private final int nxmField; + private final boolean hasMask; + private final int length; + + public NxmHeader(long header) { + this.headerAsLong = header; + this.oxmClass = Ints.checkedCast(extractSub(header, 16, 16)); + this.nxmField = Ints.checkedCast(extractSub(header, 7, 9)); + this.hasMask = extractSub(header, 1, 8) == 1 ? true : false; + this.length = Ints.checkedCast(extractSub(header, 8, 0)); + } + + public NxmHeader(int oxmClass, int nxmField, boolean hasMask, int length) { + this.oxmClass = oxmClass; + this.nxmField = nxmField; + this.hasMask = hasMask; + this.length = length; + this.headerAsLong = ((((long) oxmClass) << 16) | (nxmField << 9) | ((hasMask ? 1 : 0) << 8) | (length)); + } + + private static long extractSub(final long l, final int nrBits, final int offset) { + final long rightShifted = l >>> offset; + final long mask = (1L << nrBits) - 1L; + return rightShifted & mask; + } + + public long toLong() { + return headerAsLong; + } + + public int getOxmClass() { + return oxmClass; + } + + public int getNxmField() { + return nxmField; + } + + public boolean isHasMask() { + return hasMask; + } + + public int getLength() { + return length; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (headerAsLong ^ (headerAsLong >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NxmHeader other = (NxmHeader) obj; + if (headerAsLong != other.headerAsLong) + return false; + return true; + } + + @Override + public String toString() { + return "NxmHeader [headerAsLong=" + headerAsLong + ", oxmClass=" + oxmClass + ", nxmField=" + nxmField + + ", hasMask=" + hasMask + ", length=" + length + "]"; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java new file mode 100644 index 00000000..a8f83343 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg0; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg0Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 0; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg0.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg0.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java new file mode 100644 index 00000000..3a95c1d3 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg1; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg1Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 1; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg1.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg1.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java new file mode 100644 index 00000000..02a14cd5 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg2; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg2Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 2; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg2.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg2.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java new file mode 100644 index 00000000..7ab139e7 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg3; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg3Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 3; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg3.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg3.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java new file mode 100644 index 00000000..67e1b477 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg4; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg4Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 4; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg4.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg4.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java new file mode 100644 index 00000000..d148e265 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg5; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg5Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 5; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg5.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg5.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java new file mode 100644 index 00000000..b6a2a404 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg6Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 6; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg6.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg6.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java new file mode 100644 index 00000000..9f925c1a --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java @@ -0,0 +1,29 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg7; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; + +public class Reg7Codec extends AbstractRegCodec { + + private static final int NXM_FIELD_CODE = 7; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg7.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public Class getNxmField() { + return NxmNxReg7.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java new file mode 100644 index 00000000..8ee984db --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java @@ -0,0 +1,72 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.id.grouping.TunIdValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class TunIdCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 8; + private static final int NXM_FIELD_CODE = 16; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunId.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + BigInteger value = input.getAugmentation(OfjAugNxMatch.class).getTunIdValues().getValue(); + outBuffer.writeLong(value.longValue()); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setTunIdValues(new TunIdValuesBuilder().setValue(BigInteger.valueOf(message.readLong())) + .build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmNxTunId.class; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java new file mode 100644 index 00000000..4c2cb3ea --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunIpv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.ipv4.dst.grouping.TunIpv4DstValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class TunIpv4DstCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 4; + private static final int NXM_FIELD_CODE = 32; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Long value = input.getAugmentation(OfjAugNxMatch.class).getTunIpv4DstValues().getValue(); + outBuffer.writeInt(value.intValue()); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setTunIpv4DstValues(new TunIpv4DstValuesBuilder().setValue(message.readUnsignedInt()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmNxTunIpv4Dst.class; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java new file mode 100644 index 00000000..8e0cc0ed --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunIpv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class TunIpv4SrcCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 4; + private static final int NXM_FIELD_CODE = 31; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Src.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Long value = input.getAugmentation(OfjAugNxMatch.class).getTunIpv4SrcValues().getValue(); + outBuffer.writeInt(value.intValue()); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setTunIpv4SrcValues(new TunIpv4SrcValuesBuilder().setValue(message.readUnsignedInt()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmNxTunIpv4Src.class; + } + + @Override + public Class getOxmClass() { + return Nxm1Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml b/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml new file mode 100644 index 00000000..2fbad0d2 --- /dev/null +++ b/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml @@ -0,0 +1,28 @@ + + + + + urn:opendaylight:params:xml:ns:yang:controller:config:openflow:extension:nicira:impl?module=nicira-extension-provider-impl&revision=2014-07-11 + + + + + + + + prefix:openflow-extension-nicira + openflow-nx-bundle + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-legacy + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-default + + + + + + + diff --git a/openflow-extension-nicira/src/main/yang/nicira-action.yang b/openflow-extension-nicira/src/main/yang/nicira-action.yang new file mode 100644 index 00000000..7bb5faf7 --- /dev/null +++ b/openflow-extension-nicira/src/main/yang/nicira-action.yang @@ -0,0 +1,57 @@ +module nicira-action { + yang-version 1; + + namespace "urn:opendaylight:openflow:extension:nicira:action"; + prefix "nicira-action"; + + import openflow-action {prefix ofaction;} + import openflow-types {prefix oft;} + import yang-ext {prefix ext; revision-date "2013-07-09";} + + description + "Nicira openflow extensions of action."; + + revision "2014-04-21" { + description "Initial revision"; + } + + grouping ofj-nx-action-reg-load-grouping { + container action-reg-load { + leaf ofs_nbits { + type uint16; + } + leaf dst { + type uint32; + } + leaf value { + type uint64; + } + } + } + grouping ofj-nx-action-reg-move-grouping { + container action-reg-move { + leaf n_bits { + type uint16; + } + leaf src_ofs { + type uint16; + } + leaf dst_ofs { + type uint16; + } + leaf src { + type uint32; + } + leaf dst { + type uint32; + } + } + } + + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "ofj-aug-nx-action"; + uses ofj-nx-action-reg-load-grouping; + uses ofj-nx-action-reg-move-grouping; + } + +} \ No newline at end of file diff --git a/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang b/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang new file mode 100644 index 00000000..81d97565 --- /dev/null +++ b/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang @@ -0,0 +1,36 @@ +module nicira-extension-provider-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:config:openflow:extension:nicira:impl"; + prefix "openflow-nx"; + + import config {prefix config; revision-date 2013-04-05;} + import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} + + description + "Nicira extensions in openflow library."; + + revision "2014-07-11" { + description + "Initial revision"; + } + + identity openflow-extension-nicira { + base config:module-type; + config:java-name-prefix NiciraExtensionProvider; + } + + augment "/config:modules/config:module/config:configuration" { + case openflow-extension-nicira { + when "/config:modules/config:module/config:type = 'openflow-extension-nicira'"; + + list openflow-switch-connection-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; + } + } + } + } + } +} \ No newline at end of file diff --git a/openflow-extension-nicira/src/main/yang/nicira-match.yang b/openflow-extension-nicira/src/main/yang/nicira-match.yang new file mode 100644 index 00000000..edf8a3a3 --- /dev/null +++ b/openflow-extension-nicira/src/main/yang/nicira-match.yang @@ -0,0 +1,171 @@ +module nicira-match { + yang-version 1; + + namespace "urn:opendaylight:openflow:extension:nicira:match"; + prefix "nicira-match"; + + import openflow-extensible-match {prefix ofoxm;} + import openflow-types {prefix oft;} + import ietf-yang-types {prefix yang; revision-date "2010-09-24";} + import yang-ext {prefix ext; revision-date "2013-07-09";} + + description + "Nicira openflow extensions of match."; + + revision "2014-04-21" { + description "Initial revision"; + } + + identity nxm-nx-reg { + base ofoxm:match-field; + } + + identity nxm-nx-reg0 { + base nxm-nx-reg; + } + identity nxm-nx-reg1 { + base nxm-nx-reg; + } + identity nxm-nx-reg2 { + base nxm-nx-reg; + } + identity nxm-nx-reg3 { + base nxm-nx-reg; + } + identity nxm-nx-reg4 { + base nxm-nx-reg; + } + identity nxm-nx-reg5 { + base nxm-nx-reg; + } + identity nxm-nx-reg6 { + base nxm-nx-reg; + } + identity nxm-nx-reg7 { + base nxm-nx-reg; + } + identity nxm-nx-tun-id { + base ofoxm:match-field; + } + identity nxm-nx-arp-sha { + base ofoxm:match-field; + } + identity nxm-nx-arp-tha { + base ofoxm:match-field; + } + identity nxm-of-arp-op { + base ofoxm:match-field; + } + identity nxm-of-arp-spa { + base ofoxm:match-field; + } + identity nxm-of-arp-tpa { + base ofoxm:match-field; + } + identity nxm-nx-tun-ipv4-dst { + base ofoxm:match-field; + } + identity nxm-nx-tun-ipv4-src { + base ofoxm:match-field; + } + identity nxm-of-eth-src { + base ofoxm:match-field; + } + identity nxm-of-eth-dst { + base ofoxm:match-field; + } + + grouping ofj-nxm-nx-match-reg-grouping { + container reg-values { + leaf value { + type uint32; + } + } + } + grouping ofj-nxm-nx-match-tun-id-grouping { + container tun-id-values { + leaf value { + type uint64; + } + } + } + grouping ofj-nxm-nx-match-arp-sha-grouping { + container arp-sha-values { + leaf mac-address { + type yang:mac-address; + } + } + } + grouping ofj-nxm-nx-match-arp-tha-grouping { + container arp-tha-values { + leaf mac-address { + type yang:mac-address; + } + } + } + grouping ofj-nxm-of-match-arp-op-grouping { + container arp-op-values { + leaf value { + type uint16; + } + } + } + grouping ofj-nxm-of-match-arp-spa-grouping { + container arp-spa-values { + leaf value { + type uint32; + } + } + } + grouping ofj-nxm-of-match-arp-tpa-grouping { + container arp-tpa-values { + leaf value { + type uint32; + } + } + } + grouping ofj-nxm-nx-match-tun-ipv4-dst-grouping { + container tun-ipv4-dst-values { + leaf value { + type uint32; + } + } + } + grouping ofj-nxm-nx-match-tun-ipv4-src-grouping { + container tun-ipv4-src-values { + leaf value { + type uint32; + } + } + } + grouping ofj-nxm-of-match-eth-src-grouping { + container eth-src-values { + leaf mac-address { + type yang:mac-address; + } + } + } + grouping ofj-nxm-of-match-eth-dst-grouping { + container eth-dst-values { + leaf mac-address { + type yang:mac-address; + } + } + } + + augment "/ofoxm:oxm-container/ofoxm:match-entries" { + ext:augment-identifier "ofj-aug_nx_match"; + uses ofj-nxm-nx-match-reg-grouping; + uses ofj-nxm-nx-match-tun-id-grouping; + uses ofj-nxm-nx-match-arp-sha-grouping; + uses ofj-nxm-nx-match-arp-tha-grouping; + uses ofj-nxm-of-match-arp-op-grouping; + uses ofj-nxm-of-match-arp-spa-grouping; + uses ofj-nxm-of-match-arp-tpa-grouping; + uses ofj-nxm-nx-match-tun-ipv4-dst-grouping; + uses ofj-nxm-nx-match-tun-ipv4-src-grouping; + uses ofj-nxm-of-match-eth-src-grouping; + uses ofj-nxm-of-match-eth-dst-grouping; + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index ab183759..59cfa196 100644 --- a/pom.xml +++ b/pom.xml @@ -14,6 +14,7 @@ feature simple-client openflow-nx-resubmit-action + openflow-extension-nicira scm:git:ssh://git.opendaylight.org:29418/openflowjava.git From 01a3e436f6947964998fcf9a9f50e68d13e63e05 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Tue, 29 Jul 2014 12:21:56 +0200 Subject: [PATCH 037/285] Created experimenter subtype for vendor's actions ExperimenterActionSerializerKey has a new parameter which is type of vendor's action. It allows to select right serializer directly in OFJava so a vendor does not need to care about it. - created codec for Nicira match nxm_of_eth_type Change-Id: Id9bc0f06820cab7b897eb710a70ddc3d6af13a45 Signed-off-by: Martin Sunal --- .../nx/NiciraExtensionsRegistrator.java | 21 ++++-- .../openflowjava/nx/NiciraMatchCodecs.java | 2 + .../action/AbstractActionSerializer.java | 34 +++++++++ ...tionCodec.java => ActionDeserializer.java} | 45 +++--------- .../nx/codec/action/NiciraActionCodecs.java | 19 +++++ .../nx/codec/action/RegLoadCodec.java | 21 ++++-- .../nx/codec/action/RegMoveCodec.java | 25 ++++--- .../nx/codec/match/ArpTpaCodec.java | 2 +- .../nx/codec/match/EthDstCodec.java | 2 +- .../nx/codec/match/EthTypeCodec.java | 69 +++++++++++++++++++ .../src/main/yang/nicira-action.yang | 7 ++ .../src/main/yang/nicira-match.yang | 11 +++ .../nx/NxResubmitActionRegistrator.java | 14 +--- .../src/main/yang/nx-resubmit-action.yang | 4 ++ .../api/keys/ActionSerializerKey.java | 2 +- .../ExperimenterActionSerializerKey.java | 31 ++++++++- .../src/main/yang/openflow-action.yang | 6 +- .../src/main/yang/openflow-augments.yang | 5 ++ .../api/keys/extensibility/KeysTest.java | 11 ++- .../impl/util/TypeKeyMakerFactory.java | 2 +- 20 files changed, 258 insertions(+), 75 deletions(-) create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java rename openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/{ActionCodec.java => ActionDeserializer.java} (55%) create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java create mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java index 551b9e9d..1ed72236 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java @@ -2,7 +2,10 @@ import java.util.List; -import org.opendaylight.openflowjava.nx.codec.action.ActionCodec; +import org.opendaylight.openflowjava.nx.codec.action.ActionDeserializer; +import org.opendaylight.openflowjava.nx.codec.action.NiciraActionCodecs; +import org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec; +import org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec; import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec; import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec; import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec; @@ -10,6 +13,7 @@ import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec; import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; @@ -27,7 +31,6 @@ public class NiciraExtensionsRegistrator implements AutoCloseable { - private static final ActionCodec ACTION_CODEC = new ActionCodec(); private final List providers; /** @@ -40,8 +43,9 @@ public NiciraExtensionsRegistrator(List providers) { public void registerNiciraExtensions() { for (SwitchConnectionProvider provider : providers) { - provider.registerActionDeserializer(ActionCodec.DESERIALIZER_KEY, ACTION_CODEC); - provider.registerActionSerializer(ActionCodec.SERIALIZER_KEY, ACTION_CODEC); + provider.registerActionDeserializer(ActionDeserializer.DESERIALIZER_KEY, NiciraActionCodecs.ACTION_DESERIALIZER); + provider.registerActionSerializer(RegLoadCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_LOAD_CODEC); + provider.registerActionSerializer(RegMoveCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_MOVE_CODEC); provider.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); provider.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); provider.registerMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC); @@ -78,13 +82,16 @@ public void registerNiciraExtensions() { provider.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC); provider.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); provider.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); + provider.registerMatchEntrySerializer(EthTypeCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC); + provider.registerMatchEntryDeserializer(EthTypeCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC); } } public void unregisterExtensions() { for (SwitchConnectionProvider provider : providers) { - provider.unregisterSerializer(ActionCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ActionCodec.DESERIALIZER_KEY); + provider.unregisterDeserializer(ActionDeserializer.DESERIALIZER_KEY); + provider.unregisterSerializer(RegLoadCodec.SERIALIZER_KEY); + provider.unregisterSerializer(RegMoveCodec.SERIALIZER_KEY); provider.unregisterSerializer(Reg0Codec.SERIALIZER_KEY); provider.unregisterDeserializer(Reg0Codec.DESERIALIZER_KEY); provider.unregisterSerializer(Reg1Codec.SERIALIZER_KEY); @@ -121,6 +128,8 @@ public void unregisterExtensions() { provider.unregisterDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY); provider.unregisterSerializer(TunIpv4SrcCodec.SERIALIZER_KEY); provider.unregisterDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY); + provider.unregisterSerializer(EthTypeCodec.SERIALIZER_KEY); + provider.unregisterDeserializer(EthTypeCodec.DESERIALIZER_KEY); } } diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java index 0e166ba8..b9422f51 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; +import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec; import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; @@ -50,5 +51,6 @@ public class NiciraMatchCodecs { public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec(); public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec(); public static final TunIpv4SrcCodec TUN_IPV4_SRC_CODEC = new TunIpv4SrcCodec(); + public static final EthTypeCodec ETH_TYPE_CODEC = new EthTypeCodec(); } diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java new file mode 100644 index 00000000..b141d5ca --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.nx.codec.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.nx.NiciraConstants; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author msunal + * + */ +public abstract class AbstractActionSerializer implements OFSerializer { + + protected final static void serializeHeader(int msgLength, int subtype, ByteBuf outBuffer) { + outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); + writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer); + } + + private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) { + outBuffer.writeShort(msgLength); + outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); + outBuffer.writeShort(subtype); + } + +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java similarity index 55% rename from openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java rename to openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java index 3d58439c..43e3de09 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionCodec.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java @@ -4,9 +4,7 @@ import org.opendaylight.openflowjava.nx.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; @@ -14,44 +12,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxActionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ActionCodec implements OFSerializer, OFDeserializer { +public class ActionDeserializer implements OFDeserializer { - private static final Logger LOG = LoggerFactory.getLogger(ActionCodec.class); + private static final Logger LOG = LoggerFactory.getLogger(ActionDeserializer.class); - public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); - public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); - private static final RegMoveCodec regMoveCodec = new RegMoveCodec(); - private static final RegLoadCodec regLoadCodec = new RegLoadCodec(); - - @Override - public void serialize(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - OfjAugNxAction augNxAction = input.getAugmentation(OfjAugNxAction.class); - if (augNxAction == null) { - LOG.info("Action {} does not have any serializer.", input.getClass()); - return; - } - if (augNxAction.getActionRegMove() != null) { - writeMsgLengthVendorIdSubtypeToBuffer(RegMoveCodec.LENGTH, RegMoveCodec.SUBTYPE, outBuffer); - regMoveCodec.serialize(augNxAction.getActionRegMove(), outBuffer); - } else if (augNxAction.getActionRegLoad() != null) { - writeMsgLengthVendorIdSubtypeToBuffer(RegLoadCodec.LENGTH, RegLoadCodec.SUBTYPE, outBuffer); - regLoadCodec.serialize(augNxAction.getActionRegLoad(), outBuffer); - } else { - LOG.info("Action {} does not have any serializer.", input.getClass()); - } - } - - private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) { - outBuffer.writeShort(msgLength); - outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); - outBuffer.writeShort(subtype); - } + public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey( + EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); @Override public Action deserialize(ByteBuf message) { @@ -65,10 +38,12 @@ public Action deserialize(ByteBuf message) { OfjAugNxActionBuilder augNxActionBuilder = new OfjAugNxActionBuilder(); switch (subtype) { case RegMoveCodec.SUBTYPE: - augNxActionBuilder.setActionRegMove(regMoveCodec.deserialize(message)); + augNxActionBuilder.setActionRegMove(NiciraActionCodecs.REG_MOVE_CODEC.deserialize(message)); + expIdBuilder.setSubType(NxmNxRegMove.class); break; case RegLoadCodec.SUBTYPE: - augNxActionBuilder.setActionRegLoad(regLoadCodec.deserialize(message)); + augNxActionBuilder.setActionRegLoad(NiciraActionCodecs.REG_LOAD_CODEC.deserialize(message)); + expIdBuilder.setSubType(NxmNxRegLoad.class); break; default: LOG.info("Action {} does not have any deserializer.", subtype); diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java new file mode 100644 index 00000000..877b677f --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.nx.codec.action; + +/** + * @author msunal + * + */ +public class NiciraActionCodecs { + + public static final RegMoveCodec REG_MOVE_CODEC = new RegMoveCodec(); + public static final RegLoadCodec REG_LOAD_CODEC = new RegLoadCodec(); + public static final ActionDeserializer ACTION_DESERIALIZER = new ActionDeserializer(); +} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java index 0776edd4..0ccfa881 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java @@ -4,21 +4,30 @@ import java.math.BigInteger; +import org.opendaylight.openflowjava.nx.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder; -public class RegLoadCodec implements OFSerializer, OFDeserializer { +public class RegLoadCodec extends AbstractActionSerializer implements OFDeserializer { + public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegLoad.class); public static final int LENGTH = 24; public static final byte SUBTYPE = 7; // NXAST_REG_LOAD @Override - public void serialize(ActionRegLoad input, ByteBuf outBuffer) { - outBuffer.writeShort(input.getOfsNbits()); - outBuffer.writeInt(input.getDst().intValue()); - outBuffer.writeLong(input.getValue().longValue()); + public void serialize(Action input, ByteBuf outBuffer) { + ActionRegLoad actionRegLoad = input.getAugmentation(OfjAugNxAction.class).getActionRegLoad(); + serializeHeader(LENGTH, SUBTYPE, outBuffer); + outBuffer.writeShort(actionRegLoad.getOfsNbits()); + outBuffer.writeInt(actionRegLoad.getDst().intValue()); + outBuffer.writeLong(actionRegLoad.getValue().longValue()); } @Override diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java index c7965880..f9bf8716 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java @@ -2,23 +2,32 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.nx.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMove; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMoveBuilder; -public class RegMoveCodec implements OFSerializer, OFDeserializer { +public class RegMoveCodec extends AbstractActionSerializer implements OFDeserializer { + public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey( + EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegMove.class); public static final int LENGTH = 24; public static final byte SUBTYPE = 6; // NXAST_REG_MOVE @Override - public void serialize(ActionRegMove input, ByteBuf outBuffer) { - outBuffer.writeShort(input.getNBits()); - outBuffer.writeShort(input.getSrcOfs()); - outBuffer.writeShort(input.getDstOfs()); - outBuffer.writeInt(input.getSrc().intValue()); - outBuffer.writeInt(input.getDst().intValue()); + public void serialize(Action input, ByteBuf outBuffer) { + ActionRegMove actionRegMove = input.getAugmentation(OfjAugNxAction.class).getActionRegMove(); + serializeHeader(LENGTH, SUBTYPE, outBuffer); + outBuffer.writeShort(actionRegMove.getNBits()); + outBuffer.writeShort(actionRegMove.getSrcOfs()); + outBuffer.writeShort(actionRegMove.getDstOfs()); + outBuffer.writeInt(actionRegMove.getSrc().intValue()); + outBuffer.writeInt(actionRegMove.getDst().intValue()); } @Override diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java index 04fc5ad1..6962a529 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java @@ -19,7 +19,7 @@ public class ArpTpaCodec extends AbstractMatchCodec { private static final int VALUE_LENGTH = 4; - private static final int NXM_FIELD_CODE = 16; + private static final int NXM_FIELD_CODE = 17; public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class); public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java index dacbe1f8..9c25f936 100644 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java @@ -21,7 +21,7 @@ public class EthDstCodec extends AbstractMatchCodec { private static final int VALUE_LENGTH = 6; - private static final int NXM_FIELD_CODE = 2; + private static final int NXM_FIELD_CODE = 1; public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class); public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java new file mode 100644 index 00000000..4eccd373 --- /dev/null +++ b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java @@ -0,0 +1,69 @@ +package org.opendaylight.openflowjava.nx.codec.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +public class EthTypeCodec extends AbstractMatchCodec { + + private static final int VALUE_LENGTH = 2; + private static final int NXM_FIELD_CODE = 3; + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class); + public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( + EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); + + @Override + public void serialize(MatchEntries input, ByteBuf outBuffer) { + serializeHeader(input, outBuffer); + Integer value = input.getAugmentation(OfjAugNxMatch.class).getEthTypeValues().getValue(); + outBuffer.writeShort(value); + } + + @Override + public MatchEntries deserialize(ByteBuf message) { + MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); + OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); + augNxMatchBuilder.setEthTypeValues(new EthTypeValuesBuilder().setValue(message.readUnsignedShort()).build()); + matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); + return matchEntriesBuilder.build(); + } + + @Override + public int getNxmFieldCode() { + return NXM_FIELD_CODE; + } + + @Override + public int getOxmClassCode() { + return OxmMatchConstants.NXM_0_CLASS; + } + + @Override + public int getValueLength() { + return VALUE_LENGTH; + } + + @Override + public Class getNxmField() { + return NxmOfEthType.class; + } + + @Override + public Class getOxmClass() { + return Nxm0Class.class; + } + +} diff --git a/openflow-extension-nicira/src/main/yang/nicira-action.yang b/openflow-extension-nicira/src/main/yang/nicira-action.yang index 7bb5faf7..c43b1520 100644 --- a/openflow-extension-nicira/src/main/yang/nicira-action.yang +++ b/openflow-extension-nicira/src/main/yang/nicira-action.yang @@ -14,6 +14,13 @@ module nicira-action { revision "2014-04-21" { description "Initial revision"; } + + identity nxm-nx-reg-load { + base ofaction:experimenter-action-sub-type; + } + identity nxm-nx-reg-move { + base ofaction:experimenter-action-sub-type; + } grouping ofj-nx-action-reg-load-grouping { container action-reg-load { diff --git a/openflow-extension-nicira/src/main/yang/nicira-match.yang b/openflow-extension-nicira/src/main/yang/nicira-match.yang index edf8a3a3..3bff0351 100644 --- a/openflow-extension-nicira/src/main/yang/nicira-match.yang +++ b/openflow-extension-nicira/src/main/yang/nicira-match.yang @@ -74,6 +74,9 @@ module nicira-match { identity nxm-of-eth-dst { base ofoxm:match-field; } + identity nxm-of-eth-type { + base ofoxm:match-field; + } grouping ofj-nxm-nx-match-reg-grouping { container reg-values { @@ -152,6 +155,13 @@ module nicira-match { } } } + grouping ofj-nxm-of-match-eth-type-grouping { + container eth-type-values { + leaf value { + type uint16; + } + } + } augment "/ofoxm:oxm-container/ofoxm:match-entries" { ext:augment-identifier "ofj-aug_nx_match"; @@ -166,6 +176,7 @@ module nicira-match { uses ofj-nxm-nx-match-tun-ipv4-src-grouping; uses ofj-nxm-of-match-eth-src-grouping; uses ofj-nxm-of-match-eth-dst-grouping; + uses ofj-nxm-of-match-eth-type-grouping; } } \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java index 4baf6d2d..a9a04a53 100644 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java +++ b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer; import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxResubmitAction; /** * @author michal.polkorab @@ -34,17 +35,8 @@ public void registerNxResubmitSerializer(List provider if (providers != null) { this.providers = providers; for (SwitchConnectionProvider provider : providers) { - /* In case of handling multiple actions, instructions and other structures which - * are differentiated by vendor / experimenter subtype, vendor has to - * switch / choose between these subtypes. - * - * This has to be done in this way because of experimenter headers, which - * provide only vendor / experimenter ID. Subtype position may be different - * for different vendors (or not present at all) - that's why vendor has to - * handle it in his own implementations. - */ provider.registerActionSerializer(new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID), + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class), new NxActionResubmitSerializer()); } } @@ -78,7 +70,7 @@ public void close() throws Exception { for (SwitchConnectionProvider provider : providers) { // unregister serializer provider.unregisterSerializer(new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID)); + EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class)); // unregister deserializer provider.unregisterDeserializer(new ExperimenterActionDeserializerKey( EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID)); diff --git a/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang b/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang index 5ab94cd1..418611b5 100644 --- a/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang +++ b/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang @@ -17,6 +17,10 @@ revision "2013-07-31" { description "OpenFlow 1.3 - action model"; } + + identity nx-resubmit-action { + base ofaction:experimenter-action-sub-type; + } augment "/ofaction:actions-container/ofaction:action" { ext:augment-identifier "nx-action-resubmit-augment"; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 38b8cd49..bf1fe7dc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -48,7 +48,7 @@ public boolean equals(Object obj) { return true; if (!super.equals(obj)) return false; - if (!(obj instanceof ActionSerializerKey)) + if (getClass() != obj.getClass()) return false; ActionSerializerKey other = (ActionSerializerKey) obj; if (actionType == null) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index 989e1ba7..be18643c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -10,6 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; /** * @author michal.polkorab @@ -17,12 +18,40 @@ public final class ExperimenterActionSerializerKey extends ActionSerializerKey implements ExperimenterSerializerKey { + private Class actionSubType; + /** * @param msgVersion protocol wire version * @param experimenterId experimenter / vendor ID */ - public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) { + public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class actionSubType) { super(msgVersion, Experimenter.class, experimenterId); + this.actionSubType = actionSubType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; + if (actionSubType == null) { + if (other.actionSubType != null) + return false; + } else if (!actionSubType.equals(other.actionSubType)) + return false; + return true; } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 9cc200c4..482c1228 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -84,7 +84,11 @@ description ""; base oft:action-base; } - + + identity experimenter-action-sub-type { + description "The base identity for vendor's actions."; + } + container actions-container { uses actions-grouping; } diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 910dfa5f..a2e69293 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -252,6 +252,11 @@ leaf experimenter { type oft:experimenter-id; } + leaf sub-type { + type identityref { + base ofaction:experimenter-action-sub-type; + } + } } // OF1.0 structures augment "/ofaction:actions-container/ofaction:action" { diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java index 9b4cf744..0093e9c8 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; /** * @author michal.polkorab @@ -49,9 +50,9 @@ public void testEqualsAndHashcodeOfActionDeserializerKeys() { ActionSerializerKey actionSerializerKey = new ActionSerializerKey<>( EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L); ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, 1L); - Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey); - Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode()); + EncodeConstants.OF13_VERSION_ID, 1L, ExpSubType.class); + Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey)); + Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey)); InstructionSerializerKey instructionSerializerKey = new InstructionSerializerKey<>( EncodeConstants.OF13_VERSION_ID, @@ -61,5 +62,9 @@ public void testEqualsAndHashcodeOfActionDeserializerKeys() { Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey); Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode()); } + + private static class ExpSubType extends ExperimenterActionSubType { + + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 6530ee2c..1d3875df 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -63,7 +63,7 @@ public static TypeKeyMaker createActionKeyMaker(short version) { public MessageTypeKey make(Action entry) { if (entry.getType().equals(Experimenter.class)) { return new ExperimenterActionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue()); + entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); } return new ActionSerializerKey<>(getVersion(), entry.getType(), null); } From d89c89e361d256cdcb1ac48359913e56577ac906 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 6 Aug 2014 06:56:27 +0200 Subject: [PATCH 038/285] Fix UT coverage not reported in sonar Just a couple of properties and making sure jacoco runs. Change-Id: I75aeae7b74f5c7e94a0a237728dc2b6f0c4df090 Signed-off-by: Robert Varga --- pom.xml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 59cfa196..c8808c2b 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,11 @@ 2.3.2 0.6.2-SNAPSHOT 0.6.2-SNAPSHOT - 0.2.5-SNAPSHOT + 0.2.5-SNAPSHOT + + + jacoco + target/code-coverage/jacoco.exec @@ -199,6 +203,20 @@ + + org.jacoco + jacoco-maven-plugin + + + + prepare-agent + + + ${sonar.jacoco.reportPath} + + + + org.apache.felix maven-bundle-plugin From 57645a85fa2681d6e96ed74c03f73e62dd877a15 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 6 Aug 2014 13:55:41 +0200 Subject: [PATCH 039/285] More updates to sonar - per-test reports - integration test support - findbugs reports Change-Id: Ie6a8865551f3d4957be87ccef4b4820d30a1cbd1 Signed-off-by: Robert Varga --- pom.xml | 86 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index c8808c2b..a808355e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,8 +53,11 @@ 0.2.5-SNAPSHOT + 2.4 jacoco target/code-coverage/jacoco.exec + target/code-coverage/jacoco-it.exec + Sonar way with Findbugs @@ -179,6 +182,17 @@ + + + + + org.codehaus.sonar-plugins.java + sonar-jacoco-listeners + ${sonar-jacoco-listeners.version} + test + + + @@ -203,20 +217,6 @@ - - org.jacoco - jacoco-maven-plugin - - - - prepare-agent - - - ${sonar.jacoco.reportPath} - - - - org.apache.felix maven-bundle-plugin @@ -260,6 +260,34 @@ org.codehaus.mojo build-helper-maven-plugin + + org.jacoco + jacoco-maven-plugin + + + prepare-ut-agent + process-test-classes + + prepare-agent + + + ${sonar.jacoco.reportPath} + jacoco.agent.ut.arg + + + + prepare-it-agent + pre-integration-test + + prepare-agent + + + ${sonar.jacoco.itReportPath} + jacoco.agent.it.arg + + + + @@ -312,6 +340,36 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${jacoco.agent.it.arg} + + + listener + org.sonar.java.jacoco.JUnitListener + + + + ${project.build.directory}/surefire-reports + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${jacoco.agent.ut.arg} + + + listener + org.sonar.java.jacoco.JUnitListener + + + + org.eclipse.m2e From 9459954a216d61dfce69ffd90e45ea6a1d851584 Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Wed, 20 Aug 2014 11:09:15 -0500 Subject: [PATCH 040/285] Fix karaf features, and add testing for them. Change-Id: I272e0b92099d68e72f30138fe42935495ddf7d94 Signed-off-by: Ed Warnicke --- feature/pom.xml | 71 ----------- feature/src/main/resources/features.xml | 22 ---- features/pom.xml | 156 +++++++++++++++++++++++ features/src/main/resources/features.xml | 28 ++++ pom.xml | 38 +++++- 5 files changed, 221 insertions(+), 94 deletions(-) delete mode 100644 feature/pom.xml delete mode 100644 feature/src/main/resources/features.xml create mode 100644 features/pom.xml create mode 100644 features/src/main/resources/features.xml diff --git a/feature/pom.xml b/feature/pom.xml deleted file mode 100644 index bfd110c9..00000000 --- a/feature/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.5-SNAPSHOT - - openflowjava-features - Openflow Protocol Library - Karaf Features - - pom - - - features.xml - - - - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - - - scm:git:ssh://git.opendaylight.org:29418/openflowjava.git - scm:git:ssh://git.opendaylight.org:29418/openflowjava.git - HEAD - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - - diff --git a/feature/src/main/resources/features.xml b/feature/src/main/resources/features.xml deleted file mode 100644 index 1692a3d0..00000000 --- a/feature/src/main/resources/features.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - yangtools-concepts - yangtools-binding - yangtools-binding-generator - yangtools-models - odl-config-subsystem - mvn:io.netty/netty-buffer/${netty.version} - mvn:io.netty/netty-common/${netty.version} - mvn:io.netty/netty-transport/${netty.version} - mvn:io.netty/netty-codec/${netty.version} - mvn:io.netty/netty-handler/${netty.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-api/${project.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-spi/${project.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-impl/${project.version} - - \ No newline at end of file diff --git a/features/pom.xml b/features/pom.xml new file mode 100644 index 00000000..1ec17d83 --- /dev/null +++ b/features/pom.xml @@ -0,0 +1,156 @@ + + + 4.0.0 + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.5-SNAPSHOT + ../ + + features-openflowjava + + jar + + + features.xml + 1.4.2-SNAPSHOT + 0.6.2-SNAPSHOT + + + + + + org.opendaylight.yangtools + features-yangtools + features + xml + + + org.opendaylight.controller + features-config + features + xml + + + + + org.opendaylight.openflowjava + openflow-protocol-api + ${project.version} + + + org.opendaylight.openflowjava + openflow-protocol-spi + ${project.version} + + + org.opendaylight.openflowjava + openflow-protocol-impl + ${project.version} + + + org.opendaylight.openflowjava + util + ${project.version} + + + io.netty + netty-codec + + + io.netty + netty-handler + + + io.netty + netty-common + + + io.netty + netty-buffer + + + io.netty + netty-transport + + + + org.opendaylight.yangtools + features-test + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${karaf.distro.empty.version} + zip + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + org.opendaylight.controller + opendaylight-karaf-empty + ${karaf.empty.distro.version} + + + org.opendaylight.yangtools:features-test + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml new file mode 100644 index 00000000..2419f1ff --- /dev/null +++ b/features/src/main/resources/features.xml @@ -0,0 +1,28 @@ + + + + mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features + mvn:org.opendaylight.controller/features-config/${config.version}/xml/features + + odl-openflowjava-protocol + + + odl-yangtools-common + odl-yangtools-binding + odl-yangtools-binding-generator + odl-yangtools-models + odl-config-api + odl-mdsal-common + mvn:io.netty/netty-buffer/${netty.version} + mvn:io.netty/netty-common/${netty.version} + mvn:io.netty/netty-transport/${netty.version} + mvn:io.netty/netty-codec/${netty.version} + mvn:io.netty/netty-handler/${netty.version} + mvn:org.opendaylight.openflowjava/openflow-protocol-api/${project.version} + mvn:org.opendaylight.openflowjava/openflow-protocol-spi/${project.version} + mvn:org.opendaylight.openflowjava/openflow-protocol-impl/${project.version} + mvn:org.opendaylight.openflowjava/util/${project.version} + + diff --git a/pom.xml b/pom.xml index a808355e..29c8df68 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ util openflow-protocol-impl openflow-protocol-it - feature + features simple-client openflow-nx-resubmit-action openflow-extension-nicira @@ -36,6 +36,7 @@ 1.5.0 1.26.2 ${project.build.directory}/yang-gen-config + 1.4.2-SNAPSHOT ${project.build.directory}/yang-gen-sal ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 @@ -122,6 +123,21 @@ + + + org.opendaylight.yangtools + features-yangtools + ${yangtools.version} + features + xml + + + org.opendaylight.controller + features-config + ${config.version} + features + xml + org.slf4j slf4j-api @@ -137,6 +153,21 @@ netty-handler ${netty.version} + + io.netty + netty-codec + ${netty.version} + + + io.netty + netty-common + ${netty.version} + + + io.netty + netty-transport + ${netty.version} + com.google.guava guava @@ -180,6 +211,11 @@ 1.9.5 test + + org.opendaylight.yangtools + features-test + ${yangtools.version} + From fca679be4aad4ad8903a6dc92ea541cc6866046f Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 26 Aug 2014 10:54:26 +0200 Subject: [PATCH 041/285] Features.xml update - removed odl-yangtools-binding-generator feature as it is not needed Change-Id: Ia6a31f0fd235536a87d86fbd3b47305aab44460c Signed-off-by: Michal Polkorab --- features/src/main/resources/features.xml | 1 - pom.xml | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml index 2419f1ff..ace7ba14 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/resources/features.xml @@ -11,7 +11,6 @@ odl-yangtools-common odl-yangtools-binding - odl-yangtools-binding-generator odl-yangtools-models odl-config-api odl-mdsal-common diff --git a/pom.xml b/pom.xml index 29c8df68..43ae379a 100644 --- a/pom.xml +++ b/pom.xml @@ -70,11 +70,17 @@ false + + true + opendaylight-snapshot ${nexusproxy}/repositories/opendaylight.snapshot/ + + true + false @@ -91,12 +97,18 @@ false + + true + opendaylight-snapshot opendaylight-snapshot ${nexusproxy}/repositories/opendaylight.snapshot/ + + true + false From df67db32e6f1b3dbdfd6688945118a3bfa209c80 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 19 Aug 2014 15:45:29 +0200 Subject: [PATCH 042/285] Improve unit test coverage Change-Id: I374bcf2c76a4a3b6cba441dc0c0570be7855d8a9 Signed-off-by: Michal Polkorab --- .../connection/TlsConfigurationImplTest.java | 40 +++++ .../api/keys/extensibility/KeysTest.java | 21 ++- .../connection/ChannelOutboundQueueTest.java | 52 ++++++ .../ResponseExpectedRpcListenerTest.java | 130 ++++++++++++++ .../connection/SimpleRpcListenerTest.java | 57 +++++++ .../DeserializationFactoryTest.java | 56 ++++++ .../TypeToClassMapInitializerTest.java | 80 +++++++++ .../SerializationFactoryTest.java | 60 +++++++ .../match/OxmArpOpSerializerTest.java | 109 ++++++++++++ .../match/OxmArpShaSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmArpSpaSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmArpThaSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmArpTpaSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmEthDstSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmEthSrcSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmEthTypeSerializerTest.java | 111 ++++++++++++ .../match/OxmIcmpv4CodeSerializerTest.java | 110 ++++++++++++ .../match/OxmIcmpv4TypeSerializerTest.java | 110 ++++++++++++ .../match/OxmIcmpv6CodeSerializerTest.java | 109 ++++++++++++ .../match/OxmIcmpv6TypeSerializerTest.java | 110 ++++++++++++ .../match/OxmIpDscpSerializerTest.java | 110 ++++++++++++ .../match/OxmIpProtoSerializerTest.java | 109 ++++++++++++ .../match/OxmIpv4DstSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmIpv4SrcSerializerTest.java | 159 ++++++++++++++++++ .../match/OxmIpv6ExtHdrSerializerTest.java | 157 +++++++++++++++++ .../match/OxmIpv6NdSllSerializerTest.java | 120 +++++++++++++ .../match/OxmIpv6NdTllSerializerTest.java | 120 +++++++++++++ .../match/OxmMetadataSerializerTest.java | 158 +++++++++++++++++ .../match/OxmMplsBosSerializerTest.java | 110 ++++++++++++ .../match/OxmMplsLabelSerializerTest.java | 109 ++++++++++++ .../match/OxmMplsTcSerializerTest.java | 109 ++++++++++++ .../match/OxmPbbIsidSerializerTest.java | 154 +++++++++++++++++ .../match/OxmSctpDstSerializerTest.java | 110 ++++++++++++ .../match/OxmSctpSrcSerializerTest.java | 110 ++++++++++++ .../match/OxmTcpDstSerializerTest.java | 110 ++++++++++++ .../match/OxmTcpSrcSerializerTest.java | 110 ++++++++++++ .../match/OxmTunnelIdSerializerTest.java | 158 +++++++++++++++++ .../match/OxmUdpDstSerializerTest.java | 110 ++++++++++++ .../match/OxmUdpSrcSerializerTest.java | 110 ++++++++++++ .../match/OxmVlanPcpSerializerTest.java | 109 ++++++++++++ .../match/OxmVlanVidSerializerTest.java | 154 +++++++++++++++++ .../openflowjava/util/ByteBufUtilsTest.java | 117 ++++++++++++- 42 files changed, 4878 insertions(+), 3 deletions(-) create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java new file mode 100644 index 00000000..9816c250 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * @author michal.polkorab + * + */ +public class TlsConfigurationImplTest { + + /** + * Test correct TlsConfigurationImpl creation + */ + @Test + public void test() { + TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, + "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); + assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); + assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); + assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); + assertEquals("Wrong truststore type", KeystoreType.JKS, config.getTlsTruststoreType()); + assertEquals("Wrong keystore path type", PathType.PATH, config.getTlsKeystorePathType()); + assertEquals("Wrong truststore path type", PathType.CLASSPATH, config.getTlsTruststorePathType()); + assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); + assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); + assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java index 0093e9c8..5b464af2 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java @@ -7,13 +7,18 @@ import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; /** * @author michal.polkorab @@ -39,7 +44,12 @@ public void testEqualsAndHashcodeOfDeserializerKeys() { Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey); Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode()); - + MatchEntryDeserializerKey matchKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP); + MatchEntryDeserializerKey matchKey2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP); + Assert.assertEquals(matchKey, matchKey2); + Assert.assertEquals(matchKey.hashCode(), matchKey2.hashCode()); } /** @@ -61,10 +71,17 @@ public void testEqualsAndHashcodeOfActionDeserializerKeys() { ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L); Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey); Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode()); + + MatchEntrySerializerKey matchKey = new MatchEntrySerializerKey<>( + EncodeConstants.OF10_VERSION_ID, OpenflowBasicClass.class, InPort.class); + MatchEntrySerializerKey matchKey2 = new MatchEntrySerializerKey<>( + EncodeConstants.OF10_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertEquals(matchKey, matchKey2); + Assert.assertEquals(matchKey.hashCode(), matchKey2.hashCode()); } private static class ExpSubType extends ExperimenterActionSubType { - + // empty class - only used in test for comparation } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java new file mode 100644 index 00000000..060072d5 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.channel.Channel; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * @author michal.polkorab + * + */ +public class ChannelOutboundQueueTest { + + @Mock Channel channel; + + /** + * Initialize mocks + */ + public ChannelOutboundQueueTest() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test incorrect queue creation handling + */ + @Test(expected=IllegalArgumentException.class) + public void testIncorrectQueueCreation() { + new ChannelOutboundQueue(channel, 0); + } + + /** + * Test correct enqueue handling + */ + @Test + public void testEnqueue() { + ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1); + boolean enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertTrue("Enqueue problem", enqueued); + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertFalse("Enqueue problem", enqueued); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java new file mode 100644 index 00000000..a535c085 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class ResponseExpectedRpcListenerTest { + + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + private static final int RPC_RESPONSE_EXPIRATION = 1; + private Cache> responseCache = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", null, key); + } + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation2() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); + } + + /** + * Test object creation + */ + @Test + public void testDiscard() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.discard(); + RpcError rpcError = ConnectionAdapterImpl.buildRpcError("Failed to send message", + ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); + try { + Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), + listener.getResult().get().getErrors().iterator().next().getMessage()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testCompleted() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + BarrierInputBuilder barrierBuilder = new BarrierInputBuilder(); + BarrierInput barrierInput = barrierBuilder.build(); + listener.completed(barrierInput); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testOperationSuccessful() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.operationSuccessful(); + ResponseExpectedRpcListener present = responseCache.getIfPresent(key); + Assert.assertEquals(present, listener); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java new file mode 100644 index 00000000..db9d689e --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class SimpleRpcListenerTest { + + /** + * Test SimpleRpcListener creation + */ + @Test + public void test() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + Assert.assertEquals("Wrong message", "MESSAGE", listener.takeMessage()); + Assert.assertEquals("Wrong message", listener, listener.takeListener()); + } + + /** + * Test rpc success + */ + @Test + public void testSuccessfulRpc() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationSuccessful(); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java new file mode 100644 index 00000000..d456332b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class DeserializationFactoryTest { + + /** + * Test deserializer lookup & deserialization + */ + @Test + public void test() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, EncodeConstants.OF13_VERSION_ID); + assertEquals("Deserialization failed", 0, buffer.readableBytes()); + } + + /** + * Test deserializer lookup & deserialization + */ + @Test(expected=NullPointerException.class) + public void testNotExistingDeserializer() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, (short) 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java new file mode 100644 index 00000000..84d318f3 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassMapInitializerTest { + + private Map> messageClassMap; + + /** + * Tests correct map initialization + */ + @Test + public void test() { + messageClassMap = new HashMap<>(); + TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + version = EncodeConstants.OF13_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); + assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); + assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java new file mode 100644 index 00000000..9c170f8b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class SerializationFactoryTest { + + /** + * Test serializer lookup & serialization + */ + @Test + public void test() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build()); + assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes()); + } + + /** + * Test serializer not found scenario + */ + @Test(expected=IllegalArgumentException.class) + public void testNotExistingSerializer() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer((short) 0, buffer, helloBuilder.build()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java new file mode 100644 index 00000000..78b15e9e --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpSerializerTest { + + OxmArpOpSerializer serializer = new OxmArpOpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1402, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_OP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); + opBuilder.setOpCode(value); + builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpOp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java new file mode 100644 index 00000000..c23b9dbd --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaSerializerTest { + + OxmArpThaSerializer serializer = new OxmArpThaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java new file mode 100644 index 00000000..7af95a1b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaSerializerTest { + + OxmArpSpaSerializer serializer = new OxmArpSpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java new file mode 100644 index 00000000..714d6973 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaSerializerTest { + + OxmArpShaSerializer serializer = new OxmArpShaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java new file mode 100644 index 00000000..8a68a4c4 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaSerializerTest { + + OxmArpTpaSerializer serializer = new OxmArpTpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_TPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java new file mode 100644 index 00000000..3f0d6837 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstSerializerTest { + + OxmEthDstSerializer serializer = new OxmEthDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java new file mode 100644 index 00000000..4aed8e13 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcSerializerTest { + + OxmEthSrcSerializer serializer = new OxmEthSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java new file mode 100644 index 00000000..23f32491 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeSerializerTest { + + OxmEthTypeSerializer serializer = new OxmEthTypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 65535, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); + typeBuilder.setEthType(new EtherType(type)); + builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthType.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java new file mode 100644 index 00000000..69dbad6c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeSerializerTest { + + OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 200, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Code(value); + builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java new file mode 100644 index 00000000..3b9d2109 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeSerializerTest { + + OxmIcmpv4TypeSerializer serializer = new OxmIcmpv4TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 128, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Type(value); + builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java new file mode 100644 index 00000000..ed3089c0 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeSerializerTest { + + OxmIcmpv6CodeSerializer serializer = new OxmIcmpv6CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 101, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Code(value); + builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java new file mode 100644 index 00000000..2c2a60ea --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeSerializerTest { + + OxmIcmpv6TypeSerializer serializer = new OxmIcmpv6TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Type(value); + builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java new file mode 100644 index 00000000..34d9a9f2 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpSerializerTest { + + OxmIpDscpSerializer serializer = new OxmIpDscpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 58, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_DSCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp(value)); + builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpDscp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_DSCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java new file mode 100644 index 00000000..fbeb425a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoSerializerTest { + + OxmIpProtoSerializer serializer = new OxmIpProtoSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_PROTO, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(short value) { + MatchEntriesBuilder builder = prepareHeader(false); + ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + protoBuilder.setProtocolNumber(value); + builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpProto.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_PROTO, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java new file mode 100644 index 00000000..00c3dc87 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstSerializerTest { + + OxmIpv4DstSerializer serializer = new OxmIpv4DstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Dst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java new file mode 100644 index 00000000..5b2834b9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcSerializerTest { + + OxmIpv4SrcSerializer serializer = new OxmIpv4SrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Src.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java new file mode 100644 index 00000000..1983b1d9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrSerializerTest { + + OxmIpv6ExtHdrSerializer serializer = new OxmIpv6ExtHdrSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, + new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 358, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, + new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 153, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_EXTHDR, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + pseudoBuilder.setPseudoField(flags); + builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6Exthdr.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_EXTHDR, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java new file mode 100644 index 00000000..a3e4ff63 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllSerializerTest { + + OxmIpv6NdSllSerializer serializer = new OxmIpv6NdSllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_SLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdSll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_SLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java new file mode 100644 index 00000000..017652d9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllSerializerTest { + + OxmIpv6NdTllSerializer serializer = new OxmIpv6NdTllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_TLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdTll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_TLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java new file mode 100644 index 00000000..e8e53f17 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataSerializerTest { + + OxmMetadataSerializer serializer = new OxmMetadataSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.METADATA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Metadata.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.METADATA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java new file mode 100644 index 00000000..27c5d504 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosSerializerTest { + + OxmMplsBosSerializer serializer = new OxmMplsBosSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_BOS, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + bosBuilder.setBos(bos); + builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsBos.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_BOS, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java new file mode 100644 index 00000000..77e07f8a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelSerializerTest { + + OxmMplsLabelSerializer serializer = new OxmMplsLabelSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 168535, buffer.readUnsignedInt()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_LABEL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); + labelBuilder.setMplsLabel(label); + builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsLabel.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java new file mode 100644 index 00000000..8a387b6c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcSerializerTest { + + OxmMplsTcSerializer serializer = new OxmMplsTcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 16, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_TC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc(value); + builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsTc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java new file mode 100644 index 00000000..974ecb76 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidSerializerTest { + + OxmPbbIsidSerializer serializer = new OxmPbbIsidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 12345, buffer.readUnsignedMedium()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 6789, buffer.readUnsignedMedium()); + byte[] tmp = new byte[3]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.PBB_ISID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { + MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + isidBuilder.setIsid(value); + builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(PbbIsid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java new file mode 100644 index 00000000..606696c8 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstSerializerTest { + + OxmSctpDstSerializer serializer = new OxmSctpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java new file mode 100644 index 00000000..a28c60fe --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcSerializerTest { + + OxmSctpSrcSerializer serializer = new OxmSctpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java new file mode 100644 index 00000000..fb560554 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstSerializerTest { + + OxmTcpDstSerializer serializer = new OxmTcpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java new file mode 100644 index 00000000..9e532640 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcSerializerTest { + + OxmTcpSrcSerializer serializer = new OxmTcpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(512); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 512, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java new file mode 100644 index 00000000..cd4029ec --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdSerializerTest { + + OxmTunnelIdSerializer serializer = new OxmTunnelIdSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TUNNEL_ID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TunnelId.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java new file mode 100644 index 00000000..4cf55588 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstSerializerTest { + + OxmUdpDstSerializer serializer = new OxmUdpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(2048); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 2048, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java new file mode 100644 index 00000000..7348307d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcSerializerTest { + + OxmUdpSrcSerializer serializer = new OxmUdpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(1024); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1024, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java new file mode 100644 index 00000000..0ce0f64a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpSerializerTest { + + OxmVlanPcpSerializer serializer = new OxmVlanPcpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 42, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_PCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); + pcpBuilder.setVlanPcp(value); + builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanPcp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java new file mode 100644 index 00000000..3e9bf62c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidSerializerTest { + + OxmVlanVidSerializer serializer = new OxmVlanVidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4596, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 500, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_VID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { + MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); + vlanBuilder.setVlanVid(500); + vlanBuilder.setCfiBit(cfiBit); + builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanVid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } +} \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index e9c2d0c1..6ca0e7b0 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.util; import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator; import java.util.ArrayList; @@ -18,7 +19,10 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; /** * @author michal.polkorab @@ -219,15 +223,27 @@ public void testFillBitmaskFromRandomList() { public void testMacToBytes() { Assert.assertArrayEquals("Wrong byte array", new byte[]{0, 1, 2, 3, (byte) 255, 5}, ByteBufUtils.macAddressToBytes("00:01:02:03:FF:05")); + Assert.assertArrayEquals("Wrong byte array", new byte[]{11, 1, 2, 3, (byte) 255, 10}, + ByteBufUtils.macAddressToBytes("0b:01:02:03:FF:0a")); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytes2() { + Assert.assertArrayEquals("Wrong byte array", new byte[]{0, 1, 2, 3, (byte) 255, 5}, + ByteBufUtils.macAddressToBytes("00:01:02:03:FF:0G")); } /** * Test of {@link ByteBufUtils#macAddressToString(byte[])} */ - @Test + @Test(expected=IllegalArgumentException.class) public void testMacToString() { Assert.assertEquals("Wrong string decoded", "00:01:02:03:FF:05", ByteBufUtils.macAddressToString(new byte[]{0, 1, 2, 3, (byte) 255, 5})); + ByteBufUtils.macAddressToString(new byte[]{0, 1, 2, 3, (byte) 255, 5, 6}); } /** @@ -252,4 +268,103 @@ public void testByteBufToHexString() { Assert.assertEquals("Wrong data read", "04 05 06 07", ByteBufUtils.byteBufToHexString(buf)); } + /** + * Buffer padding test + */ + @Test + public void testPadBuffer() { + ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer(); + ByteBufUtils.padBuffer(4, buf); + Assert.assertEquals("Wrong padding", 0, buf.readUnsignedInt()); + ByteBufUtils.padBuffer(0, buf); + Assert.assertTrue("Wrong padding", buf.readableBytes() == 0); + } + + /** + * Write OF header test + */ + @Test + public void testWriteHeader() { + ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + helloBuilder.setXid(12345L); + helloBuilder.setElements(null); + HelloInput helloInput = helloBuilder.build(); + ByteBufUtils.writeOFHeader((byte) 0, helloInput, buf, EncodeConstants.OFHEADER_SIZE); + Assert.assertEquals("Wrong version", EncodeConstants.OF13_VERSION_ID, buf.readUnsignedByte()); + Assert.assertEquals("Wrong type", 0, buf.readUnsignedByte()); + Assert.assertEquals("Wrong length", EncodeConstants.OFHEADER_SIZE, buf.readUnsignedShort()); + Assert.assertEquals("Wrong xid", 12345, buf.readUnsignedInt()); + Assert.assertTrue("Unexpected data", buf.readableBytes() == 0); + } + + /** + * Fill bitmask test + */ + @Test + public void testFillBitmask() { + Assert.assertEquals("Wrong bitmask", 0, ByteBufUtils.fillBitMask(0, false)); + Assert.assertEquals("Wrong bitmask", 1, ByteBufUtils.fillBitMask(0, true)); + Assert.assertEquals("Wrong bitmask", 3, ByteBufUtils.fillBitMask(0, true, true)); + Assert.assertEquals("Wrong bitmask", 2, ByteBufUtils.fillBitMask(0, false, true)); + Assert.assertEquals("Wrong bitmask", 1, ByteBufUtils.fillBitMask(0, true, false)); + Assert.assertEquals("Wrong bitmask", 2, ByteBufUtils.fillBitMask(1, true, false)); + Assert.assertEquals("Wrong bitmask", 4, ByteBufUtils.fillBitMask(1, false, true)); + Assert.assertEquals("Wrong bitmask", 6, ByteBufUtils.fillBitMask(1, true, true)); + Assert.assertEquals("Wrong bitmask", 0, ByteBufUtils.fillBitMask(1)); + } + + /** + * Test bytes to hex string + */ + @Test + public void testBytesToHexString() { + byte[] array = new byte[]{10, 11, 12, 13, 14, 15, 16}; + Assert.assertEquals("Wrong conversion", "0a 0b 0c 0d 0e 0f 10", ByteBufUtils.bytesToHexString(array)); + byte[] empty = new byte[0]; + Assert.assertEquals("Wrong conversion", "", ByteBufUtils.bytesToHexString(empty)); + } + + /** + * Test ipv4 address conversion + */ + @Test(expected=IndexOutOfBoundsException.class) + public void testReadIpv4Address() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(10); + buffer.writeByte(20); + buffer.writeByte(30); + buffer.writeByte(40); + String ipv4Address = ByteBufUtils.readIpv4Address(buffer); + Assert.assertEquals("Wrong conversion", "10.20.30.40", ipv4Address); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + + ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(10); + ipv4Address = ByteBufUtils.readIpv4Address(buffer2); + } + + /** + * Test ipv6 address conversion + */ + @Test(expected=IndexOutOfBoundsException.class) + public void testReadIpv6Address() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(10); + buffer.writeShort(65535); + buffer.writeShort(4096); + buffer.writeShort(0); + buffer.writeShort(1024); + buffer.writeShort(42); + buffer.writeShort(2568); + buffer.writeShort(45689); + String ipv4Address = ByteBufUtils.readIpv6Address(buffer); + Assert.assertEquals("Wrong conversion", "000A:FFFF:1000:0000:0400:002A:0A08:B279", ipv4Address); + Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); + + ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeShort(10); + ipv4Address = ByteBufUtils.readIpv6Address(buffer2); + } } From 031f7e136bf446e9ce50fb2bf75cc721bf3ec335 Mon Sep 17 00:00:00 2001 From: Rob Adams Date: Fri, 18 Jul 2014 09:53:10 -0700 Subject: [PATCH 043/285] Fixed FIXME on MAC address serialization + Fix incorrect log message formatting Change-Id: Ifc523e1e67e1e29ee3c1271995ca79d6edc8b223 Signed-off-by: Michal Polkorab --- .../protocol/impl/core/OFEncoder.java | 2 +- .../openflowjava/util/ByteBufUtils.java | 40 +++++++--- .../openflowjava/util/ByteBufUtilsTest.java | 74 ++++++++++++++++++- 3 files changed, 101 insertions(+), 15 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 6080003f..493fa007 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -40,7 +40,7 @@ protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, try { serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); } catch(Exception e) { - LOGGER.warn("Message serialization failed: {}", e.getMessage()); + LOGGER.warn("Message serialization failed ", e); Future newFailedFuture = ctx.newFailedFuture(e); wrapper.getListener().operationComplete(newFailedFuture); out.clear(); diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index f03f1963..444cffc5 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -226,24 +226,40 @@ private static int hexValue(final char c) { * @param macAddress * @return byte representation of mac address * @see {@link MacAddress} - * - * FIXME: this method does not support shortened values, e.g. - * "0:1:2:3:4:5", only "00:11:22:33:44:55". */ public static byte[] macAddressToBytes(final String macAddress) { final byte[] result = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; final char[] mac = macAddress.toCharArray(); - int offset = 0; - for (int i = 0; i < EncodeConstants.MAC_ADDRESS_LENGTH - 1; ++i) { - result[i] = UnsignedBytes.checkedCast( - (hexValue(mac[offset++]) << 4) | hexValue(mac[offset++])); - Preconditions.checkArgument(mac[offset] == ':', "Invalid value: %s", macAddress); - offset++; - } + try { + int offset = 0; + for (int i = 0; i < EncodeConstants.MAC_ADDRESS_LENGTH - 1; ++i) { + if (mac[offset + EncodeConstants.SIZE_OF_BYTE_IN_BYTES] == ':') { + result[i] = UnsignedBytes.checkedCast(hexValue(mac[offset])); + offset++; + } else { + result[i] = UnsignedBytes.checkedCast( + (hexValue(mac[offset]) << 4) | hexValue(mac[offset +1])); + offset += 2; + } + Preconditions.checkArgument(mac[offset] == ':', "Invalid value: %s", macAddress); + offset++; + } - result[EncodeConstants.MAC_ADDRESS_LENGTH - 1] = - UnsignedBytes.checkedCast(hexValue(mac[offset++]) << 4 | hexValue(mac[offset])); + if (offset == (mac.length - 1)) { + result[EncodeConstants.MAC_ADDRESS_LENGTH - 1] = UnsignedBytes.checkedCast(hexValue(mac[offset])); + } else { + result[EncodeConstants.MAC_ADDRESS_LENGTH - 1] = + UnsignedBytes.checkedCast(hexValue(mac[offset]) << 4 | hexValue(mac[offset +1])); + offset++; + } + if (offset != (mac.length -1)) { + throw new IllegalArgumentException("Incorrect MAC address length"); + } + } catch (Exception e) { + throw new IllegalArgumentException("Unable to serialize MAC address for input: " + macAddress + + ". \n" + e); + } return result; } diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 6ca0e7b0..9bbb0d74 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -223,8 +223,14 @@ public void testFillBitmaskFromRandomList() { public void testMacToBytes() { Assert.assertArrayEquals("Wrong byte array", new byte[]{0, 1, 2, 3, (byte) 255, 5}, ByteBufUtils.macAddressToBytes("00:01:02:03:FF:05")); - Assert.assertArrayEquals("Wrong byte array", new byte[]{11, 1, 2, 3, (byte) 255, 10}, - ByteBufUtils.macAddressToBytes("0b:01:02:03:FF:0a")); + Assert.assertArrayEquals("Wrong byte array", new byte[]{1, 2, 3, 4, (byte) 255, 5}, + ByteBufUtils.macAddressToBytes("01:02:03:04:FF:05")); + Assert.assertArrayEquals("Wrong byte array", new byte[]{1, 2, 3, 4, (byte) 255, 5}, + ByteBufUtils.macAddressToBytes("1:2:3:4:FF:5")); + Assert.assertArrayEquals("Wrong byte array", new byte[]{1, 2, 3, 4, 5, (byte) 255}, + ByteBufUtils.macAddressToBytes("1:2:3:4:5:FF")); + Assert.assertArrayEquals("Wrong byte array", new byte[]{1, 15, 3, 4, 5, 6}, + ByteBufUtils.macAddressToBytes("1:F:3:4:5:6")); } /** @@ -236,6 +242,70 @@ public void testMacToBytes2() { ByteBufUtils.macAddressToBytes("00:01:02:03:FF:0G")); } + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesTooShort() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesTooShort2() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF:"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testIncorrectMacToBytes() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF::"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testIncorrectMacToBytes2() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF:::"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesTooLong() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF:05:85"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesInvalidOctet() { + ByteBufUtils.macAddressToBytes("00:01:02:03:FF:05d"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesInvalidOctet2() { + ByteBufUtils.macAddressToBytes("00:01:rr:03:FF:05"); + } + + /** + * Test of {@link ByteBufUtils#macAddressToBytes(String)} + */ + @Test(expected=IllegalArgumentException.class) + public void testMacToBytesInvalidOctet3() { + ByteBufUtils.macAddressToBytes("00:01:05d:03:FF:02"); + } + /** * Test of {@link ByteBufUtils#macAddressToString(byte[])} */ From 8fce3c0206141d1b955db61e1ac0c651d7eee4c3 Mon Sep 17 00:00:00 2001 From: Martin Sunal Date: Sat, 2 Aug 2014 19:24:09 +0200 Subject: [PATCH 044/285] Added a get method for InetSocketAddress of a remote OF switch Signed-off-by: Martin Sunal --- .../protocol/api/connection/ConnectionAdapter.java | 5 +++++ .../protocol/impl/connection/ConnectionAdapterImpl.java | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index cb3edd1f..d9d63228 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.api.connection; +import java.net.InetSocketAddress; import java.util.concurrent.Future; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; @@ -32,6 +33,10 @@ public interface ConnectionAdapter extends OpenflowProtocolService { */ public boolean isAlive(); + /** + * @return address of the remote end - address of a switch if connected + */ + public InetSocketAddress getRemoteAddress(); /** * @param messageListener here will be pushed all messages from switch */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 6fd5fd7f..44595d7c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -9,11 +9,11 @@ package org.opendaylight.openflowjava.protocol.impl.connection; -import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.socket.SocketChannel; import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; @@ -111,7 +111,7 @@ public void onRemoval( private final Cache> responseCache; private final ChannelOutboundQueue output; - private final Channel channel; + private final SocketChannel channel; private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; @@ -468,4 +468,9 @@ public void setConnectionReadyListener( final ConnectionReadyListener connectionReadyListener) { this.connectionReadyListener = connectionReadyListener; } + + @Override + public InetSocketAddress getRemoteAddress() { + return channel.remoteAddress(); + } } From 0068c8a3d6c870a24f16a53fc64a0eed4b1367a9 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 4 Aug 2014 16:04:10 +0200 Subject: [PATCH 045/285] Allow to configure number of threads used by Netty's EventLoopGroups Change-Id: I07e95b45069bcc3437add607cf5dc990f263eb0d Signed-off-by: Michal Polkorab --- .../connection/ConnectionConfiguration.java | 8 ++++-- .../api/connection/ThreadConfiguration.java | 26 +++++++++++++++++++ .../SwitchConnectionProviderImpl.java | 1 + .../protocol/impl/core/TcpHandler.java | 17 ++++++++++-- .../SwitchConnectionProviderModule.java | 20 ++++++++++++++ ...nflow-switch-connection-provider-impl.yang | 8 ++++++ .../ConnectionConfigurationImpl.java | 15 ++++++++++- 7 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index d877c0cc..8b344769 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -50,5 +50,9 @@ public interface ConnectionConfiguration { * @return seed for {@link SSLEngine} */ public Object getSslContext(); - -} + + /** + * @return thread numbers for TcpHandler's eventloopGroups + */ + public ThreadConfiguration getThreadConfiguration(); +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java new file mode 100644 index 00000000..6ce39ee3 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +/** + * @author michal.polkorab + * + */ +public interface ThreadConfiguration { + + /** + * @return desired number of workerThreads processing the Openflow I/O + */ + public int getWorkerThreadCount(); + + /** + * @return desired number of bossThreads registering incomming Openflow connections + */ + public int getBossThreadCount(); +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 39a9829b..b3785de6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -128,6 +128,7 @@ private TcpHandler createAndConfigureServer() { factory.setSerializationFactory(serializationFactory); factory.setDeserializationFactory(deserializationFactory); server.setChannelInitializer(factory.createPublishingChannelInitializer()); + server.setThreadConfig(connConfig.getThreadConfiguration()); return server; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 77e1bce6..72c5d07d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -21,6 +21,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,6 +54,7 @@ public class TcpHandler implements ServerFacade { private NioEventLoopGroup workerGroup; private NioEventLoopGroup bossGroup; private final SettableFuture isOnlineFuture; + private ThreadConfiguration threadConfig; private PublishingChannelInitializer channelInitializer; @@ -81,8 +83,13 @@ public TcpHandler(final InetAddress address, final int port) { */ @Override public void run() { - bossGroup = new NioEventLoopGroup(); - workerGroup = new NioEventLoopGroup(); + if (threadConfig != null) { + bossGroup = new NioEventLoopGroup(threadConfig.getBossThreadCount()); + workerGroup = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); + } else { + bossGroup = new NioEventLoopGroup(); + workerGroup = new NioEventLoopGroup(); + } /* * We generally do not perform IO-unrelated tasks, so we want to have @@ -194,4 +201,10 @@ public void setChannelInitializer(PublishingChannelInitializer channelInitialize this.channelInitializer = channelInitializer; } + /** + * @param threadConfig EventLoopGroup configuration + */ + public void setThreadConfig(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 04d16aab..1a22723a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -13,6 +13,7 @@ import java.net.UnknownHostException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; @@ -77,6 +78,7 @@ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHo final Integer port = getPort(); final long switchIdleTimeout = getSwitchIdleTimeout(); final Tls tlsConfig = getTls(); + final Threads threads = getThreads(); return new ConnectionConfiguration() { @Override @@ -145,6 +147,24 @@ public Object getSslContext() { // TODO Auto-generated method stub return null; } + @Override + public ThreadConfiguration getThreadConfiguration() { + if (threads == null) { + return null; + } + return new ThreadConfiguration() { + + @Override + public int getWorkerThreadCount() { + return threads.getWorkerThreads(); + } + + @Override + public int getBossThreadCount() { + return threads.getBossThreads(); + } + }; + } }; } diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index fe19560c..dbc48866 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -79,6 +79,14 @@ module openflow-switch-connection-provider-impl { type string; } } + container threads { + leaf boss-threads { + type uint16; + } + leaf worker-threads { + type uint16; + } + } } } } \ No newline at end of file diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java index 17058269..d0a76c8f 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java @@ -11,6 +11,7 @@ import java.net.InetAddress; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; /** @@ -24,6 +25,7 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration { private Object transferProtocol; private TlsConfiguration tlsConfig; private long switchIdleTimeout; + private ThreadConfiguration threadConfig; /** * Creates {@link ConnectionConfigurationImpl} @@ -70,4 +72,15 @@ public TlsConfiguration getTlsConfiguration() { return tlsConfig; } -} + @Override + public ThreadConfiguration getThreadConfiguration() { + return threadConfig; + } + + /** + * @param threadConfig thread model configuration (configures threads used) + */ + public void setThreadConfiguration(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } +} \ No newline at end of file From fbfd230558d9c43581f8b5d08eb51d0bbde02a4f Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 7 Aug 2014 11:54:00 +0200 Subject: [PATCH 046/285] UDP support implementation - unit tests will be added in another change Change-Id: I8b6fba59a82febf60c0ddfb97ef8e2e9267aff56 Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-configuration.yang | 17 ++ .../impl/connection/ChannelOutboundQueue.java | 14 +- .../connection/ConnectionAdapterFactory.java | 6 +- .../ConnectionAdapterFactoryImpl.java | 8 +- .../connection/ConnectionAdapterImpl.java | 11 +- .../impl/connection/ServerFacade.java | 8 +- .../SwitchConnectionProviderImpl.java | 19 +- .../connection/UdpMessageListenerWrapper.java | 45 ++++ ...ry.java => ChannelInitializerFactory.java} | 22 +- .../impl/core/OFDatagramPacketDecoder.java | 67 ++++++ .../impl/core/OFDatagramPacketEncoder.java | 56 +++++ .../impl/core/OFDatagramPacketHandler.java | 105 +++++++++ .../protocol/impl/core/PipelineHandlers.java | 63 ++++++ .../impl/core/ProtocolChannelInitializer.java | 101 +++++++++ .../core/PublishingChannelInitializer.java | 200 ------------------ .../impl/core/TcpChannelInitializer.java | 116 ++++++++++ .../protocol/impl/core/TcpHandler.java | 12 +- .../impl/core/UdpChannelInitializer.java | 32 +++ .../protocol/impl/core/UdpConnectionMap.java | 48 +++++ .../protocol/impl/core/UdpHandler.java | 151 +++++++++++++ .../impl/core/VersionMessageUdpWrapper.java | 40 ++++ .../SwitchConnectionProviderModule.java | 7 +- ...nflow-switch-connection-provider-impl.yang | 5 + ...blishingChannelInitializerFactoryTest.java | 8 +- .../PublishingChannelInitializerTest.java | 23 +- .../protocol/impl/core/TcpHandlerTest.java | 2 +- .../ConnectionConfigurationImpl.java | 10 + .../it/integration/IntegrationTest.java | 113 ++++++---- .../protocol/impl/clients/OFClient.java | 40 ++++ .../protocol/impl/clients/SimpleClient.java | 27 +-- .../impl/clients/SimpleClientInitializer.java | 6 +- .../impl/clients/UdpSimpleClient.java | 149 +++++++++++++ .../impl/clients/UdpSimpleClientFramer.java | 68 ++++++ .../clients/UdpSimpleClientInitializer.java | 50 +++++ 34 files changed, 1341 insertions(+), 308 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/{PublishingChannelInitializerFactory.java => ChannelInitializerFactory.java} (74%) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java diff --git a/openflow-protocol-api/src/main/yang/openflow-configuration.yang b/openflow-protocol-api/src/main/yang/openflow-configuration.yang index 36b163cb..8a1f8bbc 100644 --- a/openflow-protocol-api/src/main/yang/openflow-configuration.yang +++ b/openflow-protocol-api/src/main/yang/openflow-configuration.yang @@ -39,4 +39,21 @@ } } } + + typedef transport-protocol { + type enumeration { + enum TCP { + value 0; + description "Communication over TCP protocol."; + } + enum TLS { + value 1; + description "Communication over TLS protocol."; + } + enum UDP { + value 2; + description "Communication over UDP protocol."; + } + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java index 40af2791..6937a1fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java @@ -16,6 +16,7 @@ import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; @@ -95,6 +96,7 @@ public void run() { private final Queue> queue; private final long maxWorkTime; private final Channel channel; + private InetSocketAddress address; public ChannelOutboundQueue(final Channel channel, final int queueDepth) { Preconditions.checkArgument(queueDepth > 0, "Queue depth has to be positive"); @@ -181,7 +183,13 @@ private synchronized void flush() { } final GenericFutureListener> l = h.takeListener(); - final ChannelFuture p = channel.write(new MessageListenerWrapper(h.takeMessage(), l)); + + final ChannelFuture p; + if (address == null) { + p = channel.write(new MessageListenerWrapper(h.takeMessage(), l)); + } else { + p = channel.write(new UdpMessageListenerWrapper(h.takeMessage(), l, address)); + } if (l != null) { p.addListener(l); } @@ -268,4 +276,8 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { public String toString() { return String.format("Channel %s queue [%s messages flushing=%s]", channel, queue.size(), flushScheduled); } + + public void setAddress(InetSocketAddress address) { + this.address = address; + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java index 3070aba8..dba298b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java @@ -9,7 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.connection; -import io.netty.channel.socket.SocketChannel; +import java.net.InetSocketAddress; + +import io.netty.channel.Channel; /** * @author mirehak @@ -21,6 +23,6 @@ public interface ConnectionAdapterFactory { * @param ch * @return connection adapter tcp-implementation */ - public ConnectionFacade createConnectionFacade(SocketChannel ch) ; + public ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) ; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java index fda222ce..259dd6f5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java @@ -9,7 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.connection; -import io.netty.channel.socket.SocketChannel; +import java.net.InetSocketAddress; + +import io.netty.channel.Channel; /** * @author mirehak @@ -22,8 +24,8 @@ public class ConnectionAdapterFactoryImpl implements ConnectionAdapterFactory { * @return connection adapter tcp-implementation */ @Override - public ConnectionFacade createConnectionFacade(SocketChannel ch) { - return new ConnectionAdapterImpl(ch); + public ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) { + return new ConnectionAdapterImpl(ch, address); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 44595d7c..9fe040fc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.connection; +import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; -import io.netty.channel.socket.SocketChannel; import io.netty.util.concurrent.GenericFutureListener; import java.net.InetSocketAddress; @@ -111,7 +111,7 @@ public void onRemoval( private final Cache> responseCache; private final ChannelOutboundQueue output; - private final SocketChannel channel; + private final Channel channel; private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; @@ -121,14 +121,17 @@ public void onRemoval( /** * default ctor * @param channel the channel to be set - used for communication + * @param address client address (used only in case of UDP communication, + * as there is no need to store address over tcp (stable channel)) */ - public ConnectionAdapterImpl(final SocketChannel channel) { + public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address) { responseCache = CacheBuilder.newBuilder() .concurrencyLevel(1) .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); this.channel = Preconditions.checkNotNull(channel); this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH); + output.setAddress(address); channel.pipeline().addLast(output); LOG.debug("ConnectionAdapter created"); } @@ -471,6 +474,6 @@ public void setConnectionReadyListener( @Override public InetSocketAddress getRemoteAddress() { - return channel.remoteAddress(); + return (InetSocketAddress) channel.remoteAddress(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java index 84c84df7..39a6eb7e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java @@ -9,10 +9,16 @@ package org.opendaylight.openflowjava.protocol.impl.connection; +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; + /** * @author mirehak */ public interface ServerFacade extends ShutdownProvider, OnlineProvider, Runnable { - // empty unifying superinterface + /** + * Sets thread configuration + * @param threadConfig desired thread configuration + */ + public void setThreadConfig(ThreadConfiguration threadConfig); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index b3785de6..d8c38cd5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -25,13 +25,15 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializerFactory; +import org.opendaylight.openflowjava.protocol.impl.core.ChannelInitializerFactory; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; +import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.slf4j.Logger; @@ -118,16 +120,23 @@ public ListenableFuture startup() { /** * @return */ - private TcpHandler createAndConfigureServer() { + private ServerFacade createAndConfigureServer() { LOGGER.debug("Configuring .."); - TcpHandler server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); - PublishingChannelInitializerFactory factory = new PublishingChannelInitializerFactory(); + ServerFacade server = null; + ChannelInitializerFactory factory = new ChannelInitializerFactory(); factory.setSwitchConnectionHandler(switchConnectionHandler); factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout()); factory.setTlsConfig(connConfig.getTlsConfiguration()); factory.setSerializationFactory(serializationFactory); factory.setDeserializationFactory(deserializationFactory); - server.setChannelInitializer(factory.createPublishingChannelInitializer()); + TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol(); + if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { + server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); + ((TcpHandler) server).setChannelInitializer(factory.createPublishingChannelInitializer()); + } else { + server = new UdpHandler(connConfig.getAddress(), connConfig.getPort()); + ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer()); + } server.setThreadConfig(connConfig.getThreadConfiguration()); return server; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java new file mode 100644 index 00000000..84bf0b19 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * This object is used for UDP communication - it also carries recipient address + + * @author michal.polkorab + */ +public class UdpMessageListenerWrapper extends MessageListenerWrapper { + + private InetSocketAddress address; + + /** + * @param msg message to be sent + * @param listener listener attached to channel.write(msg) Future + * @param address recipient's address + */ + public UdpMessageListenerWrapper(Object msg, GenericFutureListener> listener, + InetSocketAddress address) { + super(msg, listener); + this.address = address; + } + + /** + * @return recipient address + */ + public InetSocketAddress getAddress() { + return address; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java similarity index 74% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java index 90351dc1..c453b0b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java @@ -17,7 +17,7 @@ * @author michal.polkorab * */ -public class PublishingChannelInitializerFactory { +public class ChannelInitializerFactory { private long switchIdleTimeOut; private DeserializationFactory deserializationFactory; @@ -28,8 +28,8 @@ public class PublishingChannelInitializerFactory { /** * @return PublishingChannelInitializer that initializes new channels */ - public PublishingChannelInitializer createPublishingChannelInitializer() { - PublishingChannelInitializer initializer = new PublishingChannelInitializer(); + public TcpChannelInitializer createPublishingChannelInitializer() { + TcpChannelInitializer initializer = new TcpChannelInitializer(); initializer.setSwitchIdleTimeout(switchIdleTimeOut); initializer.setDeserializationFactory(deserializationFactory); initializer.setSerializationFactory(serializationFactory); @@ -38,6 +38,18 @@ public PublishingChannelInitializer createPublishingChannelInitializer() { return initializer; } + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public UdpChannelInitializer createUdpChannelInitializer() { + UdpChannelInitializer initializer = new UdpChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + /** * @param switchIdleTimeOut */ @@ -72,6 +84,4 @@ public void setTlsConfig(TlsConfiguration tlsConfig) { public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { this.switchConnectionHandler = switchConnectionHandler; } - - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java new file mode 100644 index 00000000..7b4c3186 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageDecoder; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketDecoder extends MessageToMessageDecoder{ + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); + private DeserializationFactory deserializationFactory; + + @Override + protected void decode(ChannelHandlerContext ctx, + VersionMessageUdpWrapper msg, List out) throws Exception { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("UdpVersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + } + + DataObject dataObject = null; + try { + dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), + msg.getVersion()); + if (dataObject == null) { + LOGGER.warn("Translated POJO is null"); + } else { + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); + consumer.consume(dataObject); + } + } catch(Exception e) { + LOGGER.error("Message deserialization failed"); + LOGGER.error(e.getMessage(), e); + // TODO: delegate exception to allow easier deserialization + // debugging / deserialization problem awareness + } finally { + msg.getMessageBuffer().release(); + } + + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java new file mode 100644 index 00000000..631509d0 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.impl.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageEncoder; +import io.netty.util.concurrent.Future; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketEncoder extends MessageToMessageEncoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); + private SerializationFactory serializationFactory; + + @Override + protected void encode(ChannelHandlerContext ctx, + UdpMessageListenerWrapper wrapper, List out) throws Exception { + LOGGER.trace("Encoding"); + try { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); + out.add(new DatagramPacket(buffer, wrapper.getAddress())); + } catch(Exception e) { + LOGGER.warn("Message serialization failed: {}", e.getMessage()); + Future newFailedFuture = ctx.newFailedFuture(e); + wrapper.getListener().operationComplete(newFailedFuture); + return; + } + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java new file mode 100644 index 00000000..0f1b8236 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageDecoder; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketHandler extends MessageToMessageDecoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); + + /** Length of OpenFlow 1.3 header */ + public static final byte LENGTH_OF_HEADER = 8; + private static final byte LENGTH_INDEX_IN_HEADER = 2; + private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl(); + private SwitchConnectionHandler connectionHandler; + + /** + * Default constructor + * @param sch the switchConnectionHandler that decides + * what to do with incomming message / channel + */ + public OFDatagramPacketHandler(SwitchConnectionHandler sch) { + this.connectionHandler = sch; + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + LOGGER.warn("Unexpected exception from downstream.", cause); + LOGGER.warn("Closing connection."); + ctx.close(); + } + + @Override + protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, + List out) throws Exception { + LOGGER.debug("OFDatagramPacketFramer"); + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); + if (consumer == null) { + ConnectionFacade connectionFacade = + adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); + connectionHandler.onSwitchConnected(connectionFacade); + connectionFacade.checkListeners(); + UdpConnectionMap.addConnection(msg.sender(), connectionFacade); + } + ByteBuf bb = msg.content(); + int readableBytes = bb.readableBytes(); + if (readableBytes < LENGTH_OF_HEADER) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); + LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); + LOGGER.debug("length of actual message: {}", length); + + if (readableBytes < length) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for msg: " + + readableBytes + " < " + length); + LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + + + byte version = bb.readByte(); + if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { + LOGGER.debug("detected version: " + version); + ByteBuf messageBuffer = bb.slice(); + out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); + messageBuffer.retain(); + } else { + LOGGER.warn("detected version: " + version + " - currently not supported"); + } + bb.skipBytes(bb.readableBytes()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java new file mode 100644 index 00000000..9a9bf3c4 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +/** + * Stores names of handlers used in pipeline. + * + * @author michal.polkorab + */ +public enum PipelineHandlers { + + /** + * Detects switch idle state + */ + IDLE_HANDLER, + /** + * 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 byte messages into POJOs + */ + OF_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol byte messages + */ + OF_ENCODER, + /** + * Delegates translated POJOs into MessageConsumer + */ + DELEGATING_INBOUND_HANDLER, + /** + * Performs efficient flushing + */ + CHANNEL_OUTBOUNF_QUEUE, + /** + * Decodes incoming messages into message frames + * and filters them based on version supported + */ + OF_DATAGRAMPACKET_HANDLER, + /** + * Transforms OpenFlow Protocol datagram messages into POJOs + */ + OF_DATAGRAMPACKET_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol datagrams + */ + OF_DATAGRAMPACKET_ENCODER +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java new file mode 100644 index 00000000..2c486f00 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @param Channel type + * @author michal.polkorab + */ +public abstract class ProtocolChannelInitializer + extends ChannelInitializer { + + private SwitchConnectionHandler switchConnectionHandler; + private long switchIdleTimeout; + private SerializationFactory serializationFactory; + private DeserializationFactory deserializationFactory; + private TlsConfiguration tlsConfiguration; + + /** + * @param switchConnectionHandler the switchConnectionHandler to set + */ + public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } + + /** + * @param switchIdleTimeout the switchIdleTimeout to set + */ + public void setSwitchIdleTimeout(final long switchIdleTimeout) { + this.switchIdleTimeout = switchIdleTimeout; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(final SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param tlsConfiguration + */ + public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { + this.tlsConfiguration = tlsConfiguration; + } + + /** + * @return switch connection handler + */ + public SwitchConnectionHandler getSwitchConnectionHandler() { + return switchConnectionHandler; + } + + /** + * @return switch idle timeout + */ + public long getSwitchIdleTimeout() { + return switchIdleTimeout; + } + + /** + * @return serialization factory + */ + public SerializationFactory getSerializationFactory() { + return serializationFactory; + } + + /** + * @return deserialization factory + */ + public DeserializationFactory getDeserializationFactory() { + return deserializationFactory; + } + + /** + * @return TLS configuration + */ + public TlsConfiguration getTlsConfiguration() { + return tlsConfiguration; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java deleted file mode 100644 index 5d29e4be..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializer.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.group.DefaultChannelGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.ssl.SslHandler; - -import java.net.InetAddress; -import java.util.Iterator; -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.SSLEngine; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Initializes the channel - * @author michal.polkorab - */ -public class PublishingChannelInitializer extends ChannelInitializer { - - /** - * Enum used for storing names of used components (in pipeline). - */ - public static enum COMPONENT_NAMES { - - /** - * Detects switch idle state - */ - IDLE_HANDLER, - /** - * Detects 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 byte messages into POJOs - */ - OF_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol byte messages - */ - OF_ENCODER, - /** - * Delegates translated POJOs into MessageConsumer - */ - DELEGATING_INBOUND_HANDLER, - } - - private static final Logger LOGGER = LoggerFactory - .getLogger(PublishingChannelInitializer.class); - private final DefaultChannelGroup allChannels; - private SwitchConnectionHandler switchConnectionHandler; - private long switchIdleTimeout; - private SerializationFactory serializationFactory; - private DeserializationFactory deserializationFactory; - private ConnectionAdapterFactory connectionAdapterFactory; - private TlsConfiguration tlsConfiguration ; - - /** - * default ctor - */ - public PublishingChannelInitializer() { - this( new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl() ); - } - - /** - * Testing Constructor - * - */ - protected PublishingChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) { - allChannels = channelGroup ; - connectionAdapterFactory = connAdaptorFactory ; - } - - @Override - protected void initChannel(final SocketChannel ch) { - InetAddress switchAddress = ch.remoteAddress().getAddress(); - int port = ch.localAddress().getPort(); - int remotePort = ch.remoteAddress().getPort(); - LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString() - + ":" + remotePort + " --> :" + port); - if (!switchConnectionHandler.accept(switchAddress)) { - ch.disconnect(); - LOGGER.info("Incoming connection rejected"); - return; - } - LOGGER.info("Incoming connection accepted - building pipeline"); - allChannels.add(ch); - ConnectionFacade connectionFacade = null; - connectionFacade = connectionAdapterFactory.createConnectionFacade(ch); - try { - LOGGER.debug("calling plugin: " + switchConnectionHandler); - switchConnectionHandler.onSwitchConnected(connectionFacade); - connectionFacade.checkListeners(); - ch.pipeline().addLast(COMPONENT_NAMES.IDLE_HANDLER.name(), new IdleHandler(switchIdleTimeout, TimeUnit.MILLISECONDS)); - - // If this channel is configured to support SSL it will only support SSL - if (tlsConfiguration != null) { - SslContextFactory sslFactory = new SslContextFactory(tlsConfiguration); - SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); - engine.setNeedClientAuth(true); - engine.setUseClientMode(false); - ch.pipeline().addLast(COMPONENT_NAMES.SSL_HANDLER.name(), new SslHandler(engine)); - } - ch.pipeline().addLast(COMPONENT_NAMES.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade)); - ch.pipeline().addLast(COMPONENT_NAMES.OF_VERSION_DETECTOR.name(), new OFVersionDetector()); - OFDecoder ofDecoder = new OFDecoder(); - ofDecoder.setDeserializationFactory(deserializationFactory); - ch.pipeline().addLast(COMPONENT_NAMES.OF_DECODER.name(), ofDecoder); - OFEncoder ofEncoder = new OFEncoder(); - ofEncoder.setSerializationFactory(serializationFactory); - ch.pipeline().addLast(COMPONENT_NAMES.OF_ENCODER.name(), ofEncoder); - ch.pipeline().addLast(COMPONENT_NAMES.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); - if (tlsConfiguration == null) { - connectionFacade.fireConnectionReadyNotification(); - } - } catch (Exception e) { - LOGGER.error("Failed to initialize channel", e); - ch.close(); - } - } - - /** - * @return iterator through active connections - */ - public Iterator getConnectionIterator() { - return allChannels.iterator(); - } - - /** - * @return amount of active channels - */ - public int size() { - return allChannels.size(); - } - - /** - * @param switchConnectionHandler the switchConnectionHandler to set - */ - public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { - this.switchConnectionHandler = switchConnectionHandler; - } - - /** - * @param switchIdleTimeout the switchIdleTimeout to set - */ - public void setSwitchIdleTimeout(final long switchIdleTimeout) { - this.switchIdleTimeout = switchIdleTimeout; - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(final SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } - - /** - * @param tlsConfiguration - */ - public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { - this.tlsConfiguration = tlsConfiguration; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java new file mode 100644 index 00000000..d84126b8 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.Channel; +import io.netty.channel.group.DefaultChannelGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.ssl.SslHandler; + +import java.net.InetAddress; +import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +import javax.net.ssl.SSLEngine; + +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Initializes TCP / TLS channel + * @author michal.polkorab + */ +public class TcpChannelInitializer extends ProtocolChannelInitializer { + + private static final Logger LOGGER = LoggerFactory + .getLogger(TcpChannelInitializer.class); + private final DefaultChannelGroup allChannels; + private ConnectionAdapterFactory connectionAdapterFactory; + + /** + * default ctor + */ + public TcpChannelInitializer() { + this( new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl() ); + } + + /** + * Testing Constructor + * + */ + protected TcpChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) { + allChannels = channelGroup ; + connectionAdapterFactory = connAdaptorFactory ; + } + + @Override + protected void initChannel(final SocketChannel ch) { + InetAddress switchAddress = ch.remoteAddress().getAddress(); + int port = ch.localAddress().getPort(); + int remotePort = ch.remoteAddress().getPort(); + LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString() + + ":" + remotePort + " --> :" + port); + if (!getSwitchConnectionHandler().accept(switchAddress)) { + ch.disconnect(); + LOGGER.info("Incoming connection rejected"); + return; + } + LOGGER.info("Incoming connection accepted - building pipeline"); + allChannels.add(ch); + ConnectionFacade connectionFacade = null; + connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null); + try { + LOGGER.debug("calling plugin: " + getSwitchConnectionHandler()); + getSwitchConnectionHandler().onSwitchConnected(connectionFacade); + connectionFacade.checkListeners(); + ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); + + // If this channel is configured to support SSL it will only support SSL + if (getTlsConfiguration() != null) { + SslContextFactory sslFactory = new SslContextFactory(getTlsConfiguration()); + SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); + engine.setNeedClientAuth(true); + engine.setUseClientMode(false); + ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), new SslHandler(engine)); + } + ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade)); + ch.pipeline().addLast(PipelineHandlers.OF_VERSION_DETECTOR.name(), new OFVersionDetector()); + OFDecoder ofDecoder = new OFDecoder(); + ofDecoder.setDeserializationFactory(getDeserializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_DECODER.name(), ofDecoder); + OFEncoder ofEncoder = new OFEncoder(); + ofEncoder.setSerializationFactory(getSerializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofEncoder); + ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); + if (getTlsConfiguration() == null) { + connectionFacade.fireConnectionReadyNotification(); + } + } catch (Exception e) { + LOGGER.error("Failed to initialize channel", e); + ch.close(); + } + } + + /** + * @return iterator through active connections + */ + public Iterator getConnectionIterator() { + return allChannels.iterator(); + } + + /** + * @return amount of active channels + */ + public int size() { + return allChannels.size(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 72c5d07d..59675b27 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -30,7 +30,7 @@ import com.google.common.util.concurrent.SettableFuture; /** - * Class implementing server over TCP for handling incoming connections. + * Class implementing server over TCP / TLS for handling incoming connections. * * @author michal.polkorab */ @@ -56,7 +56,7 @@ public class TcpHandler implements ServerFacade { private final SettableFuture isOnlineFuture; private ThreadConfiguration threadConfig; - private PublishingChannelInitializer channelInitializer; + private TcpChannelInitializer channelInitializer; /** * Constructor of TCPHandler that listens on selected port. @@ -135,7 +135,7 @@ public void run() { LOGGER.debug("address from tcphandler: {}", address); isOnlineFuture.set(true); - LOGGER.info("Switch listener started and ready to accept incoming connections on port: {}", port); + LOGGER.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port); f.channel().closeFuture().sync(); } catch (InterruptedException e) { LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); @@ -197,13 +197,11 @@ public String getAddress() { /** * @param channelInitializer */ - public void setChannelInitializer(PublishingChannelInitializer channelInitializer) { + public void setChannelInitializer(TcpChannelInitializer channelInitializer) { this.channelInitializer = channelInitializer; } - /** - * @param threadConfig EventLoopGroup configuration - */ + @Override public void setThreadConfig(ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java new file mode 100644 index 00000000..51871440 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.socket.nio.NioDatagramChannel; + +/** + * @author michal.polkorab + * + */ +public class UdpChannelInitializer extends ProtocolChannelInitializer { + + @Override + protected void initChannel(NioDatagramChannel ch) throws Exception { + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), + new OFDatagramPacketHandler(getSwitchConnectionHandler())); + OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); + ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), + ofDatagramPacketDecoder); + OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); + ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); +// connectionFacade.fireConnectionReadyNotification(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java new file mode 100644 index 00000000..ce6d17f0 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import java.net.InetSocketAddress; +import java.util.HashMap; + +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; + +/** + * As UDP communication is handled only by one channel, it is needed + * to store MessageConsumers, so that we know which consumer handles which channel + + * @author michal.polkorab + */ +public class UdpConnectionMap { + + private static HashMap connectionMap = new HashMap<>(); + + /** + * @param address sender's address + * @return corresponding MessageConsumer + */ + public static MessageConsumer getMessageConsumer(InetSocketAddress address) { + return connectionMap.get(address); + } + + /** + * @param address sender's address + * @param consumer MessageConsumer to be added / paired with specified address + */ + public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { + connectionMap.put(address, consumer); + } + + /** + * @param address sender's address + */ + public static void removeConnection(InetSocketAddress address) { + connectionMap.remove(address); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java new file mode 100644 index 00000000..c0f958d2 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetAddress; +import java.net.InetSocketAddress; + +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; +import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +/** + * Class implementing server over UDP for handling incoming connections. + * + * @author michal.polkorab + */ +public final class UdpHandler implements ServerFacade { + + private static final Logger LOGGER = LoggerFactory + .getLogger(UdpHandler.class); + private int port; + private String address; + private EventLoopGroup group; + private final InetAddress startupAddress; + private final SettableFuture isOnlineFuture; + private UdpChannelInitializer channelInitializer; + private ThreadConfiguration threadConfig; + + /** + * Constructor of UdpHandler that listens on selected port. + * + * @param port listening port of UdpHandler server + */ + public UdpHandler(final int port) { + this(null, port); + } + + /** + * Constructor of UdpHandler that listens on selected address and port. + * @param address listening address of UdpHandler server + * @param port listening port of UdpHandler server + */ + public UdpHandler(final InetAddress address, final int port) { + this.port = port; + this.startupAddress = address; + isOnlineFuture = SettableFuture.create(); + } + + @Override + public void run() { + if (threadConfig != null) { + group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); + } else { + group = new NioEventLoopGroup(); + } + final ChannelFuture f; + try { + Bootstrap b = new Bootstrap(); + b.group(group) + .channel(NioDatagramChannel.class) + .option(ChannelOption.SO_BROADCAST, false) + .handler(channelInitializer); + + if (startupAddress != null) { + f = b.bind(startupAddress.getHostAddress(), port).sync(); + } else { + f = b.bind(port).sync(); + } + } catch (InterruptedException e) { + LOGGER.error("Interrupted while binding port {}", port, e); + return; + } + + try { + InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); + this.address = isa.getHostString(); + + // Update port, as it may have been specified as 0 + this.port = isa.getPort(); + + LOGGER.debug("Address from udpHandler: {}", address); + isOnlineFuture.set(true); + LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); + f.channel().closeFuture().sync(); + } catch (InterruptedException e) { + LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); + } finally { + shutdown(); + } + } + + @Override + public ListenableFuture shutdown() { + final SettableFuture result = SettableFuture.create(); + group.shutdownGracefully().addListener(new GenericFutureListener>() { + + @Override + public void operationComplete( + final io.netty.util.concurrent.Future downResult) throws Exception { + result.set(downResult.isSuccess()); + if (downResult.cause() != null) { + result.setException(downResult.cause()); + } + } + + }); + return result; + } + + @Override + public ListenableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + /** + * @return the port + */ + public int getPort() { + return port; + } + + /** + * @param channelInitializer + */ + public void setChannelInitializer(UdpChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; + } + + @Override + public void setThreadConfig(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java new file mode 100644 index 00000000..087bcb6b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; + +import java.net.InetSocketAddress; + +/** + * Wraps received messages (includes version) and sender address + + * @author michal.polkorab + */ +public class VersionMessageUdpWrapper extends VersionMessageWrapper { + + private InetSocketAddress address; + + /** + * @param version Openflow wire version + * @param messageBuffer ByteBuf containing binary message + * @param address sender address + */ + public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { + super(version, messageBuffer); + this.address = address; + } + + /** + * @return sender address + */ + public InetSocketAddress getAddress() { + return address; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 1a22723a..b3cbeb29 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -18,6 +18,7 @@ import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,6 +80,7 @@ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHo final long switchIdleTimeout = getSwitchIdleTimeout(); final Tls tlsConfig = getTls(); final Threads threads = getThreads(); + final TransportProtocol transportProtocol = getTransportProtocol(); return new ConnectionConfiguration() { @Override @@ -91,12 +93,11 @@ public int getPort() { } @Override public Object getTransferProtocol() { - // TODO Auto-generated method stub - return null; + return transportProtocol; } @Override public TlsConfiguration getTlsConfiguration() { - if (tlsConfig == null) { + if (tlsConfig == null || !(TransportProtocol.TLS.equals(transportProtocol))) { return null; } return new TlsConfiguration() { diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index dbc48866..6afd5c60 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -36,6 +36,11 @@ module openflow-switch-connection-provider-impl { description "address of local listening interface"; type ietf-inet:ip-address; } + leaf transport-protocol { + description "Transport protocol used for communication."; + type of-config:transport-protocol; + mandatory true; + } leaf switch-idle-timeout { description "idle timeout in [ms]"; type uint32; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java index b24192a1..6001e7f8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java @@ -29,7 +29,7 @@ public class PublishingChannelInitializerFactoryTest { TlsConfiguration tlsConfiguration ; - PublishingChannelInitializerFactory factory; + ChannelInitializerFactory factory; private final long switchIdleTimeOut = 60; @Mock SwitchConnectionHandler switchConnectionHandler ; @Mock SerializationFactory serializationFactory; @@ -41,7 +41,7 @@ public class PublishingChannelInitializerFactoryTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - factory = new PublishingChannelInitializerFactory(); + factory = new ChannelInitializerFactory(); tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH); factory.setDeserializationFactory(deserializationFactory); @@ -52,11 +52,11 @@ public void setUp() { } /** - * Test {@link PublishingChannelInitializer} creation + * Test {@link TcpChannelInitializer} creation */ @Test public void testCreatePublishingChannelInitializer() { - PublishingChannelInitializer initializer = factory.createPublishingChannelInitializer() ; + TcpChannelInitializer initializer = factory.createPublishingChannelInitializer() ; assertNotNull( initializer ); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index 6666da3d..2a503dd2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -36,7 +36,6 @@ import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.core.PublishingChannelInitializer.COMPONENT_NAMES; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; @@ -63,7 +62,7 @@ public class PublishingChannelInitializerTest { TlsConfiguration tlsConfiguration ; InetSocketAddress inetSockAddr; - PublishingChannelInitializer pubChInitializer ; + TcpChannelInitializer pubChInitializer ; /** * Sets up test environment @@ -72,7 +71,7 @@ public class PublishingChannelInitializerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - pubChInitializer= new PublishingChannelInitializer(mockChGrp, mockConnAdaptorFactory) ; + pubChInitializer= new TcpChannelInitializer(mockChGrp, mockConnAdaptorFactory) ; pubChInitializer.setSerializationFactory(mockSerializationFactory); pubChInitializer.setDeserializationFactory(mockDeserializationFactory); pubChInitializer.setSwitchIdleTimeout(1) ; @@ -83,7 +82,7 @@ public void setUp() throws Exception { inetSockAddr = new InetSocketAddress(InetAddress.getLocalHost(), 8675 ) ; - when(mockConnAdaptorFactory.createConnectionFacade(mockSocketCh)) + when(mockConnAdaptorFactory.createConnectionFacade(mockSocketCh, null)) .thenReturn(mockConnFacade); when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ; when(mockSocketCh.localAddress()).thenReturn(inetSockAddr) ; @@ -105,7 +104,7 @@ public void testinitChannelEncryptionSet() { pubChInitializer.initChannel(mockSocketCh) ; verifyCommonHandlers(); - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.SSL_HANDLER.name()),any(SslHandler.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.SSL_HANDLER.name()),any(SslHandler.class)) ; } /** @@ -117,7 +116,7 @@ public void testinitChannelEncryptionSetNullTls() { pubChInitializer.initChannel(mockSocketCh) ; verifyCommonHandlers(); - verify(mockChPipeline, times(0)).addLast(eq(COMPONENT_NAMES.SSL_HANDLER.name()),any(SslHandler.class)) ; + verify(mockChPipeline, times(0)).addLast(eq(PipelineHandlers.SSL_HANDLER.name()),any(SslHandler.class)) ; } /** @@ -160,12 +159,12 @@ public void testExceptionThrown() { * All paths should install these six handlers: */ private void verifyCommonHandlers() { - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.IDLE_HANDLER.name()),any(IdleHandler.class)) ; - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_DECODER.name()),any(OFDecoder.class)) ; - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_ENCODER.name()),any(OFEncoder.class)) ; - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_FRAME_DECODER.name()),any(OFFrameDecoder.class)) ; - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.OF_VERSION_DETECTOR.name()),any(OFVersionDetector.class)) ; - verify(mockChPipeline, times(1)).addLast(eq(COMPONENT_NAMES.DELEGATING_INBOUND_HANDLER.name()),any(DelegatingInboundHandler.class)); + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.IDLE_HANDLER.name()),any(IdleHandler.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.OF_DECODER.name()),any(OFDecoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.OF_ENCODER.name()),any(OFEncoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.OF_FRAME_DECODER.name()),any(OFFrameDecoder.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.OF_VERSION_DETECTOR.name()),any(OFVersionDetector.class)) ; + verify(mockChPipeline, times(1)).addLast(eq(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name()),any(DelegatingInboundHandler.class)); assertEquals(1, pubChInitializer.size()) ; } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java index 7092922f..129a8668 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java @@ -36,7 +36,7 @@ public class TcpHandlerTest { private InetAddress serverAddress = InetAddress.getLoopbackAddress() ; @Mock ChannelHandlerContext mockChHndlrCtx ; - @Mock PublishingChannelInitializer mockChannelInitializer; + @Mock TcpChannelInitializer mockChannelInitializer; @Mock SwitchConnectionHandler mockSwitchConnHndler ; @Mock SerializationFactory mockSerializationFactory ; @Mock DeserializationFactory mockDeserializationFactory ; diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java index d0a76c8f..47c1889b 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; /** * @author michal.polkorab @@ -26,6 +27,7 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration { private TlsConfiguration tlsConfig; private long switchIdleTimeout; private ThreadConfiguration threadConfig; + private TransportProtocol protocol; /** * Creates {@link ConnectionConfigurationImpl} @@ -56,6 +58,14 @@ public Object getTransferProtocol() { return transferProtocol; } + /** + * Used for testing - sets transport protocol + * @param protocol + */ + public void setTransferProtocol(TransportProtocol protocol) { + this.transferProtocol = protocol; + } + @Override public long getSwitchIdleTimeout() { return switchIdleTimeout; diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index c12ec55b..8a94cd05 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -20,17 +20,21 @@ import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.OFClient; import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory; import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler; import org.opendaylight.openflowjava.protocol.impl.clients.SendEvent; import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient; import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.UdpSimpleClient; import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; +import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +48,7 @@ public class IntegrationTest { .getLogger(IntegrationTest.class); private static int port; - private TlsConfiguration tlsConfiguration ; + private TlsConfiguration tlsConfiguration; private static final int SWITCH_IDLE_TIMEOUT = 2000; private static final long CONNECTION_TIMEOUT = 2000; private InetAddress startupAddress; @@ -53,31 +57,36 @@ public class IntegrationTest { private ConnectionConfigurationImpl connConfig; /** - * @param secured true if an encrypted connection should be used + * @param protocol communication protocol to be used during test * @throws Exception */ - public void setUp(boolean secured) throws Exception { + public void setUp(TransportProtocol protocol) throws Exception { LOGGER.debug("\n starting test -------------------------------"); String currentDir = System.getProperty("user.dir"); LOGGER.debug("Current dir using System:" +currentDir); startupAddress = InetAddress.getLocalHost(); - if (secured) { + tlsConfiguration = null; + if (protocol.equals(TransportProtocol.TLS)) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH) ; - connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); - } else { - connConfig = new ConnectionConfigurationImpl(startupAddress, 0, null, SWITCH_IDLE_TIMEOUT); } + connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + connConfig.setTransferProtocol(protocol); mockPlugin = new MockPlugin(); switchConnectionProvider = new SwitchConnectionProviderImpl(); switchConnectionProvider.setSwitchConnectionHandler(mockPlugin); switchConnectionProvider.setConfiguration(connConfig); switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); - TcpHandler tcpHandler = (TcpHandler) switchConnectionProvider.getServerFacade(); - port = tcpHandler.getPort(); + if (protocol.equals(TransportProtocol.TCP) || protocol.equals(TransportProtocol.TLS)) { + TcpHandler tcpHandler = (TcpHandler) switchConnectionProvider.getServerFacade(); + port = tcpHandler.getPort(); + } else { + UdpHandler udpHandler = (UdpHandler) switchConnectionProvider.getServerFacade(); + port = udpHandler.getPort(); + } } /** @@ -87,7 +96,6 @@ public void setUp(boolean secured) throws Exception { public void tearDown() throws Exception { switchConnectionProvider.close(); LOGGER.debug("\n ending test -------------------------------"); - } /** @@ -96,12 +104,12 @@ public void tearDown() throws Exception { */ @Test public void testHandshake() throws Exception { - setUp(false); + setUp(TransportProtocol.TCP); int amountOfCLients = 1; Stack scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, false); - SimpleClient firstClient = clients.get(0); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); + OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -109,17 +117,17 @@ public void testHandshake() throws Exception { } /** - * Library integration and communication test with handshake + * Library integration and secured communication test with handshake * @throws Exception */ @Test public void testTlsHandshake() throws Exception { - setUp(true); + setUp(TransportProtocol.TLS); int amountOfCLients = 1; Stack scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, true); - SimpleClient firstClient = clients.get(0); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); + OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -132,7 +140,7 @@ public void testTlsHandshake() throws Exception { */ @Test public void testHandshakeAndEcho() throws Exception { - setUp(false); + setUp(TransportProtocol.TCP); int amountOfCLients = 1; Stack scenario = ScenarioFactory.createHandshakeScenario(); scenario.add(0, new SleepEvent(1000)); @@ -140,20 +148,20 @@ public void testHandshakeAndEcho() throws Exception { scenario.add(0, new SleepEvent(1000)); scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, false); - SimpleClient firstClient = clients.get(0); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); + OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); LOGGER.debug("testHandshakeAndEcho() Finished") ; } /** - * Library integration and communication test with handshake + echo exchange + * Library integration and secured communication test with handshake + echo exchange * @throws Exception */ @Test public void testTlsHandshakeAndEcho() throws Exception { - setUp(true); + setUp(TransportProtocol.TLS); int amountOfCLients = 1; Stack scenario = ScenarioFactory.createHandshakeScenario(); scenario.add(0, new SleepEvent(1000)); @@ -161,40 +169,69 @@ public void testTlsHandshakeAndEcho() throws Exception { scenario.add(0, new SleepEvent(1000)); scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, true); - SimpleClient firstClient = clients.get(0); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); + OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); LOGGER.debug("testTlsHandshakeAndEcho() Finished") ; } /** - * Library integration and communication test (with virtual machine) - * @throws Exception - */ - //@Test - public void testCommunicationWithVM() throws Exception { - mockPlugin.getFinishedFuture().get(); + * Library udp integration and communication test with handshake + echo exchange + * @throws Exception + */ + @Test + public void testUdpHandshakeAndEcho() throws Exception { + setUp(TransportProtocol.UDP); + int amountOfCLients = 1; + Stack scenario = ScenarioFactory.createHandshakeScenario(); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.add(0, new SleepEvent(1000)); + scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP); + OFClient firstClient = clients.get(0); + firstClient.getScenarioDone().get(); + + LOGGER.debug("testUdpHandshakeAndEcho() Finished") ; + } + + /** + * Library integration and communication test (with virtual machine) + * @throws Exception + */ + //@Test + public void testCommunicationWithVM() throws Exception { + mockPlugin.getFinishedFuture().get(); } /** * @param amountOfCLients - * @param secured true if encrypted connection should be used + * @param protocol true if encrypted connection should be used * @return new clients up and running * @throws ExecutionException if some client could not start */ - private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler, - boolean secured) throws ExecutionException { - List clientsHorde = new ArrayList<>(); + private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler, + TransportProtocol protocol) throws ExecutionException { + List clientsHorde = new ArrayList<>(); for (int i = 0; i < amountOfCLients; i++) { LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress()); - SimpleClient sc = new SimpleClient(startupAddress.getHostAddress(), port); - sc.setSecuredClient(secured); + OFClient sc = null; + if (protocol.equals(TransportProtocol.TCP)) { + sc = new SimpleClient(startupAddress.getHostAddress(), port); + sc.setSecuredClient(false); + } else if (protocol.equals(TransportProtocol.TLS)) { + sc = new SimpleClient(startupAddress.getHostAddress(), port); + sc.setSecuredClient(true); + } else { + sc = new UdpSimpleClient(startupAddress.getHostAddress(), port); + } sc.setScenarioHandler(scenarioHandler); clientsHorde.add(sc); - sc.start(); + sc.run(); } - for (SimpleClient sc : clientsHorde) { + for (OFClient sc : clientsHorde) { try { sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); } catch (Exception e) { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java new file mode 100644 index 00000000..f7b4bafa --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * Unifying interface for simple clients / switch simulators + * + * @author michal.polkorab + */ +public interface OFClient extends Runnable { + + /** + * @return the isOnlineFuture which is set when client is started + */ + public SettableFuture getIsOnlineFuture(); + + /** + * @return the scenarioDone when scenario is successfully finished + */ + public SettableFuture getScenarioDone(); + + /** + * @param scenario list of desired actions + */ + public void setScenarioHandler(ScenarioHandler scenario); + + /** + * @param securedClient true is client should use encrypted communication, + * false otherwise + */ + public void setSecuredClient(boolean securedClient); +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index 72ef9d43..e31c3674 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -27,7 +27,7 @@ * * @author michal.polkorab */ -public class SimpleClient extends Thread { +public class SimpleClient implements OFClient { private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClient.class); private final String host; @@ -98,9 +98,7 @@ public Future disconnect() { return group.shutdownGracefully(); } - /** - * @param securedClient - */ + @Override public void setSecuredClient(boolean securedClient) { this.securedClient = securedClient; } @@ -131,27 +129,20 @@ public static void main(String[] args) throws Exception { sc = new SimpleClient(host, port); sc.setSecuredClient(Boolean.parseBoolean(args[2])); } - sc.start(); - + sc.run(); } - - /** - * @return the isOnlineFuture - */ + + @Override public SettableFuture getIsOnlineFuture() { return isOnlineFuture; } - - /** - * @return the scenarioDone - */ + + @Override public SettableFuture getScenarioDone() { return scenarioDone; } - - /** - * @param scenario list of wanted actions - */ + + @Override public void setScenarioHandler(ScenarioHandler scenario) { this.scenarioHandler = scenario; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index 1d74bc0d..c44a660c 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -11,7 +11,7 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.ssl.SslHandler; import javax.net.ssl.SSLEngine; @@ -22,7 +22,7 @@ * * @author michal.polkorab */ -public class SimpleClientInitializer extends ChannelInitializer { +public class SimpleClientInitializer extends ChannelInitializer { private SettableFuture isOnlineFuture; private boolean secured; @@ -38,7 +38,7 @@ public SimpleClientInitializer(SettableFuture isOnlineFuture, boolean s } @Override - public void initChannel(SocketChannel ch) throws Exception { + public void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (secured) { SSLEngine engine = ClientSslContextFactory.getClientContext() diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java new file mode 100644 index 00000000..685dbd2a --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.util.concurrent.Future; + +import java.net.InetAddress; +import java.util.concurrent.ExecutionException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * Simple client for testing purposes + * + * @author michal.polkorab + */ +public class UdpSimpleClient implements OFClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(UdpSimpleClient.class); + private final String host; + private final int port; + private EventLoopGroup group; + private SettableFuture isOnlineFuture; + private SettableFuture scenarioDone; + private UdpSimpleClientInitializer clientInitializer; + private ScenarioHandler scenarioHandler; + + /** + * Constructor of class + * + * @param host address of host + * @param port host listening port + */ + public UdpSimpleClient(String host, int port) { + this.host = host; + this.port = port; + init(); + } + + private void init() { + isOnlineFuture = SettableFuture.create(); + scenarioDone = SettableFuture.create(); + } + + /** + * Starting class of {@link UdpSimpleClient} + */ + @Override + public void run() { + group = new NioEventLoopGroup(); + clientInitializer = new UdpSimpleClientInitializer(isOnlineFuture); + clientInitializer.setScenario(scenarioHandler); + try { + Bootstrap b = new Bootstrap(); + b.group(group) + .channel(NioDatagramChannel.class) + .option(ChannelOption.SO_BROADCAST, false) + .handler(clientInitializer); + + b.connect(host, port).sync(); + + synchronized (scenarioHandler) { + LOGGER.debug("WAITING FOR SCENARIO"); + scenarioHandler.wait(); + } + } catch (Exception ex) { + LOGGER.error(ex.getMessage(), ex); + } finally { + LOGGER.debug("shutting down"); + try { + group.shutdownGracefully().get(); + LOGGER.debug("shutdown succesful"); + } catch (InterruptedException | ExecutionException e) { + LOGGER.error(e.getMessage(), e); + } + } + scenarioDone.set(true); + } + + /** + * @return close future + */ + public Future disconnect() { + LOGGER.debug("disconnecting client"); + return group.shutdownGracefully(); + } + + /** + * Sets up {@link UdpSimpleClient} and fires run() + * + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + String host; + int port; + UdpSimpleClient sc; + if (args.length != 2) { + LOGGER.error("Usage: " + UdpSimpleClient.class.getSimpleName() + + " "); + LOGGER.error("Trying to use default setting."); + InetAddress ia = InetAddress.getLocalHost(); + InetAddress[] all = InetAddress.getAllByName(ia.getHostName()); + host = all[0].getHostAddress(); + port = 6633; + sc = new UdpSimpleClient(host, port); + } else { + host = args[0]; + port = Integer.parseInt(args[1]); + sc = new UdpSimpleClient(host, port); + } + sc.run(); + + } + + @Override + public SettableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + @Override + public SettableFuture getScenarioDone() { + return scenarioDone; + } + + @Override + public void setScenarioHandler(ScenarioHandler scenario) { + this.scenarioHandler = scenario; + } + + @Override + public void setSecuredClient(boolean securedClient) { + // TODO: Finish implementation when DTLS is supported + } +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java new file mode 100644 index 00000000..d5f8e7be --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageDecoder; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class for decoding incoming udp messages into message frames. + * + * @author michal.polkorab + */ +public class UdpSimpleClientFramer extends MessageToMessageDecoder { + + /** Length of OpenFlow 1.3 header */ + public static final byte LENGTH_OF_HEADER = 8; + private static final byte LENGTH_INDEX_IN_HEADER = 2; + private static final Logger LOGGER = LoggerFactory.getLogger(UdpSimpleClientFramer.class); + + /** + * Constructor of class. + */ + public UdpSimpleClientFramer() { + LOGGER.trace("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, DatagramPacket msg, List list) throws Exception { + ByteBuf bb = msg.content(); + if (bb.readableBytes() < LENGTH_OF_HEADER) { + LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes()); + return; + } + + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); + if (bb.readableBytes() < length) { + LOGGER.debug("skipping bb - too few data for msg: " + + bb.readableBytes() + " < " + length); + return; + } + LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + + ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); + list.add(messageBuffer); + messageBuffer.retain(); + bb.skipBytes(length); + } +} \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java new file mode 100644 index 00000000..cd7a8a8a --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.nio.NioDatagramChannel; + +import com.google.common.util.concurrent.SettableFuture; + +/** Initializes udp pipeline + * + * @author michal.polkorab + */ +public class UdpSimpleClientInitializer extends ChannelInitializer { + + private SettableFuture isOnlineFuture; + private ScenarioHandler scenarioHandler; + + /** + * @param isOnlineFuture future notifier of connected channel + */ + public UdpSimpleClientInitializer(SettableFuture isOnlineFuture) { + this.isOnlineFuture = isOnlineFuture; + } + + @Override + public void initChannel(NioDatagramChannel ch) throws Exception { + ChannelPipeline pipeline = ch.pipeline(); + SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler); + simpleClientHandler.setScenario(scenarioHandler); + pipeline.addLast("framer", new UdpSimpleClientFramer()); + pipeline.addLast("handler", simpleClientHandler); + isOnlineFuture = null; + } + + /** + * @param scenarioHandler handler of scenario events + */ + public void setScenario(ScenarioHandler scenarioHandler) { + this.scenarioHandler = scenarioHandler; + } +} \ No newline at end of file From 62ce17ffcb5733ff7299fb13221921f870e11c3a Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 2 Sep 2014 15:23:08 +0200 Subject: [PATCH 047/285] Added missing extension registration methods + keys (deserialization part) Change-Id: Id997a3fc52ab8e4491ee74ba61bddec20d23c2d9 Signed-off-by: Michal Polkorab --- .../DeserializerExtensionProvider.java | 56 ++++++++++++- .../ExperimenterIdDeserializerKey.java | 63 ++++++++++++++ .../SwitchConnectionProviderImpl.java | 43 ++++++++++ .../factories/ErrorMessageFactory.java | 26 +++--- .../factories/ExperimenterMessageFactory.java | 43 ++++++++++ .../MultipartReplyMessageFactory.java | 54 +++++------- .../OF10StatsReplyMessageFactory.java | 20 ++--- .../QueueGetConfigReplyMessageFactory.java | 19 ++--- .../factories/VendorMessageFactory.java | 43 ++++++++++ .../ExperimenterDeserializerKeyFactory.java | 84 +++++++++++++++++++ 10 files changed, 378 insertions(+), 73 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java create mode 100644 util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index b821b168..0d1d9cd6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -11,7 +11,13 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; /** * Provides methods for deserialization part of extensibility @@ -50,4 +56,52 @@ public void registerInstructionDeserializer(ExperimenterInstructionDeserializerK */ public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFGeneralDeserializer deserializer); -} + + /** + * Registers error message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerErrorDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers experimenter (vendor) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply (stats) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply table-features message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers meter band deserializer (used in multipart-reply meter-config) + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers queue property (QUEUE_GET_CONFIG_REPLY message) deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java new file mode 100644 index 00000000..cfb19c63 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterIdDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private Long experimenterId; + + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of created object + */ + public ExperimenterIdDeserializerKey(short version, Long experimenterId, Class objectClass) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); + this.experimenterId = experimenterId; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (!(obj instanceof ExperimenterIdDeserializerKey)) + return false; + ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index d8c38cd5..706ad538 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; @@ -22,6 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; @@ -36,6 +38,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -198,4 +205,40 @@ public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } + + @Override + public void registerErrorDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } + + @Override + public void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } + + @Override + public void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } + + @Override + public void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, + OFGeneralDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } + + @Override + public void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } + + @Override + public void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index 4b18f212..8e341bd0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -12,10 +12,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdError; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadActionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadInstructionCode; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.BadMatchCode; @@ -48,23 +47,24 @@ public class ErrorMessageFactory implements OFDeserializer, @Override public ErrorMessage deserialize(ByteBuf rawMessage) { + int startIndex = rawMessage.readerIndex(); ErrorMessageBuilder builder = new ErrorMessageBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); ErrorType errorType = ErrorType.forValue(type); if (ErrorType.EXPERIMENTER.equals(errorType)) { - builder.setType(errorType.getIntValue()); - OFDeserializer deserializer = registry.getDeserializer(new MessageCodeKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, ErrorMessage.class)); - ExperimenterIdError error = deserializer.deserialize(rawMessage); - builder.addAugmentation(ExperimenterIdError.class, error); - } else { - decodeType(builder, errorType, type); - decodeCode(rawMessage, builder, errorType); - if (rawMessage.readableBytes() > 0) { - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); - } + OFDeserializer deserializer = registry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( + EncodeConstants.OF13_VERSION_ID, rawMessage.getUnsignedInt( + rawMessage.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES))); + rawMessage.readerIndex(startIndex); + return deserializer.deserialize(rawMessage); + } + decodeType(builder, errorType, type); + decodeCode(rawMessage, builder, errorType); + if (rawMessage.readableBytes() > 0) { + builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); } return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java new file mode 100644 index 00000000..effe6923 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + private static final byte EXPERIMENTER_ID_INDEX = 8; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 4074339a..1379071d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -18,11 +18,12 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; @@ -62,16 +63,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; @@ -98,7 +97,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; @@ -378,6 +376,7 @@ private List createTableFeaturesProperties(ByteBuf input List properties = new ArrayList<>(); int tableFeaturesLength = length; while (tableFeaturesLength > 0) { + int propStartIndex = input.readerIndex(); TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort()); builder.setType(type); @@ -430,12 +429,11 @@ private List createTableFeaturesProperties(ByteBuf input builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) { - // return index to property start, so that the experimenter properties are deserialized - // correctly - as whole ofp_table_feature_prop_experimenter property - input.readerIndex(input.readerIndex() - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + long expId = input.readUnsignedInt(); + input.readerIndex(propStartIndex); OFDeserializer propDeserializer = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - type.getIntValue(), TableFeatureProperties.class)); + ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); TableFeatureProperties expProp = propDeserializer.deserialize(input); properties.add(expProp); continue; @@ -634,7 +632,7 @@ private static MultipartReplyMeterCase setMeter(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { + private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder(); MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder(); List meterConfigList = new ArrayList<>(); @@ -646,6 +644,7 @@ private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { int actualLength = METER_CONFIG_LENGTH; List bandsList = new ArrayList<>(); while (actualLength < meterConfigBodyLength) { + int bandStartIndex = input.readerIndex(); BandsBuilder bandsBuilder = new BandsBuilder(); int bandType = input.readUnsignedShort(); switch (bandType) { @@ -673,16 +672,13 @@ private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build()); break; case 0xFFFF: - MeterBandExperimenterCaseBuilder bandExperimenterCaseBuilder = new MeterBandExperimenterCaseBuilder(); - MeterBandExperimenterBuilder bandExperimenterBuilder = new MeterBandExperimenterBuilder(); - // TODO - implement lookup into registry -// bandExperimenterBuilder.setType(MeterBandType.forValue(bandType)); -// actualLength += input.readUnsignedShort(); -// bandExperimenterBuilder.setRate(input.readUnsignedInt()); -// bandExperimenterBuilder.setBurstSize(input.readUnsignedInt()); -// bandExperimenterBuilder.setExperimenter(input.readUnsignedInt()); -// bandExperimenterCaseBuilder.setMeterBandExperimenter(bandExperimenterBuilder.build()); - bandsBuilder.setMeterBand(bandExperimenterCaseBuilder.build()); + actualLength += input.readUnsignedShort(); + long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES); + input.readerIndex(bandStartIndex); + OFDeserializer deserializer = registry.getDeserializer( + ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + bandsBuilder.setMeterBand(deserializer.deserialize(input)); break; default: break; @@ -697,17 +693,9 @@ private static MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { - // TODO - implement lookup into registry - MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); - MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); -// builder.setExperimenter(input.readUnsignedInt()); -// builder.setExpType(input.readUnsignedInt()); -// byte[] data = new byte[input.readableBytes()]; -// input.readBytes(data); -// builder.setData(data); - caseBuilder.setMultipartReplyExperimenter(builder.build()); - return caseBuilder.build(); + private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { + return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, input.readUnsignedInt())); } private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 5d27bdf5..f1370acd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -18,12 +18,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -35,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; @@ -46,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; @@ -295,16 +294,9 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { - // TODO - implement lookup into registry - MultipartReplyExperimenterCaseBuilder caseBuilder = new MultipartReplyExperimenterCaseBuilder(); - MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder(); -// builder.setExperimenter(input.readUnsignedInt()); -// byte[] data = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; -// input.readBytes(data); -// builder.setData(data); - caseBuilder.setMultipartReplyExperimenter(builder.build()); - return caseBuilder.build(); + private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { + return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, input.readUnsignedInt())); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java index ab05b53c..a85b996e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java @@ -15,9 +15,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; @@ -43,7 +43,6 @@ public class QueueGetConfigReplyMessageFactory implements OFDeserializer createPropertiesList(ByteBuf input, int length){ int propertiesLength = length; List propertiesList = new ArrayList<>(); while (propertiesLength > 0) { + int propertyStartIndex = input.readerIndex(); QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder(); QueueProperties property = QueueProperties.forValue(input.readUnsignedShort()); propertiesBuilder.setProperty(property); @@ -87,16 +87,12 @@ private List createPropertiesList(ByteBuf input, int length){ propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build()); input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY); } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) { - // return index to property start, so that the experimenter properties are deserialized - // correctly - as whole ofp_queue_prop_experimenter property - input.readerIndex(input.readerIndex() - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES - - PADDING_IN_QUEUE_PROPERTY_HEADER); + long expId = input.readUnsignedInt(); + input.readerIndex(propertyStartIndex); OFDeserializer deserializer = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EXPERIMENTER_VALUE, QueueProperty.class)); - QueueProperty expProp = deserializer.deserialize(input.slice(input.readerIndex(), - currentPropertyLength - QUEUE_PROP_HEADER_SIZE)); - propertiesList.add(expProp); + ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + propertiesList.add(deserializer.deserialize(input)); continue; } propertiesList.add(propertiesBuilder.build()); @@ -108,5 +104,4 @@ private List createPropertiesList(ByteBuf input, int length){ public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { this.registry = deserializerRegistry; } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java new file mode 100644 index 00000000..7c421538 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class VendorMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + private static final byte VENDOR_ID_INDEX = 8; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } +} \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java new file mode 100644 index 00000000..1f3b7b25 --- /dev/null +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterDeserializerKeyFactory { + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ErrorMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyTFDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, TableFeatureProperties.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createQueuePropertyDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, QueueProperty.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); + } +} \ No newline at end of file From 9e08a4f5084193144692b3dce28dc39983c48cd3 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 3 Sep 2014 14:29:18 +0200 Subject: [PATCH 048/285] Added missing extension registration methods + keys (serialization part) Change-Id: I44bd91a975c8bd6e56e9c13aa152999d34c8546f Signed-off-by: Michal Polkorab --- .../SerializerExtensionProvider.java | 37 +++++++++++ .../ExperimenterIdDeserializerKey.java | 4 +- .../ExperimenterIdSerializerKey.java | 62 +++++++++++++++++++ .../SwitchConnectionProviderImpl.java | 29 +++++++++ .../ExperimenterInputMessageFactory.java | 42 +++++++++++++ .../MeterModInputMessageFactory.java | 15 +++-- .../MultipartRequestInputFactory.java | 16 +++-- .../OF10StatsRequestInputFactory.java | 19 +++--- .../factories/VendorInputMessageFactory.java | 42 +++++++++++++ .../ExperimenterSerializerKeyFactory.java | 62 +++++++++++++++++++ 10 files changed, 308 insertions(+), 20 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java create mode 100644 util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 025e3c2c..9ee873bf 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -10,10 +10,15 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; /** @@ -53,4 +58,36 @@ public void registerInstructionSerializer(ExperimenterInstructionSerializerKey k */ public void registerMatchEntrySerializer( MatchEntrySerializerKey key,OFGeneralSerializer serializer); + + /** + * Registers experimenter (vendor) message serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request (stats-request) serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request table-features serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers meter band serializer (used in meter-mod messages) + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + public void registerMeterBandSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java index cfb19c63..d4841f20 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -10,6 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; /** * @author michal.polkorab @@ -25,7 +26,8 @@ public final class ExperimenterIdDeserializerKey extends MessageCodeKey * @param experimenterId experimenter / vendor ID * @param objectClass class of created object */ - public ExperimenterIdDeserializerKey(short version, Long experimenterId, Class objectClass) { + public ExperimenterIdDeserializerKey(short version, + Long experimenterId, Class objectClass) { super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); this.experimenterId = experimenterId; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java new file mode 100644 index 00000000..1e9325e9 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * @param class of object to be serialized + */ +public class ExperimenterIdSerializerKey extends MessageTypeKey { + + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of object to be serialized + */ + public ExperimenterIdSerializerKey(short msgVersion, + Long experimenterId, Class objectClass) { + super(msgVersion, objectClass); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (!(obj instanceof ExperimenterIdSerializerKey)) + return false; + ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) + return false; + } else if (!experimenterId.equals(other.experimenterId)) + return false; + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 706ad538..c2072ba5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -24,6 +25,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; @@ -39,10 +41,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -241,4 +246,28 @@ public void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } + + @Override + public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } + + @Override + public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } + + @Override + public void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } + + @Override + public void registerMeterBandSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java new file mode 100644 index 00000000..6dd5f663 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; + +/** + * Translates Experimenter messages + * @author michal.polkorab + */ +public class ExperimenterInputMessageFactory implements OFSerializer, + SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + public void serialize(ExperimenterInput message, ByteBuf outBuffer) { + long expId = message.getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + serializer.serialize(message, outBuffer); + } + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java index 0c69f478..1da3fb3c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -12,12 +12,13 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMeterBand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; @@ -78,11 +79,14 @@ private void serializeBands(final List bands, final ByteBuf outBuffer) { outBuffer.writeByte(dscpRemarkBand.getPrecLevel()); outBuffer.writeZero(PADDING_IN_METER_BAND_DSCP_REMARK); } else if (meterBand instanceof MeterBandExperimenterCase) { - OFSerializer serializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MeterBandExperimenter.class)); MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand; MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter(); - serializer.serialize(experimenterBand, outBuffer); + long expId = experimenterBand.getAugmentation(ExperimenterIdMeterBand.class) + .getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + serializer.serialize(experimenterBandCase, outBuffer); } } } @@ -99,5 +103,4 @@ private static void writeBandCommonFields(final MeterBandCommons meterBand, fina public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { registry = serializerRegistry; } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index fff96d17..2170eaf2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -21,7 +21,10 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; @@ -84,7 +87,6 @@ public class MultipartRequestInputFactory implements OFSerializer serializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestExperimenter.class)); - serializer.serialize(experimenter, outBuffer); + long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + serializer.serialize(expCase, outBuffer); } private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlags flags) { @@ -417,8 +421,10 @@ private void writeOxmRelatedTableProperty(final ByteBuf output, private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) { + long expId = property.getAugmentation(ExperimenterIdTableFeatureProperty.class).getExperimenter().getValue(); OFSerializer serializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, TableFeatureProperties.class)); + ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); serializer.serialize(property, output); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 840b9966..74b79359 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -14,8 +14,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; @@ -130,16 +132,17 @@ private static void serializeQueueBody(final MultipartRequestBody multipartReque } private void serializeExperimenterBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { - MultipartRequestExperimenterCase experimenterCase = (MultipartRequestExperimenterCase) multipartRequestBody; - MultipartRequestExperimenter experimenter = experimenterCase.getMultipartRequestExperimenter(); - OFSerializer expSerializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestExperimenter.class)); - expSerializer.serialize(experimenter, output); + MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) multipartRequestBody; + MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter(); + long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + serializer.serialize(expCase, output); } @Override public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { this.registry = serializerRegistry; } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java new file mode 100644 index 00000000..1cf2adc3 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; + +/** + * Translates Vendor messages + * @author michal.polkorab + */ +public class VendorInputMessageFactory implements OFSerializer, + SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + public void serialize(ExperimenterInput message, ByteBuf outBuffer) { + long expId = message.getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + serializer.serialize(message, outBuffer); + } + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } +} \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java new file mode 100644 index 00000000..a1647668 --- /dev/null +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterSerializerKeyFactory { + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMeterBandSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); + } +} \ No newline at end of file From cf9ceab4e7cdaca3793efbf54acaa6d470459217 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 3 Sep 2014 11:46:40 +0200 Subject: [PATCH 049/285] BUG-1675: bump netty version This patch depends on https://git.opendaylight.org/gerrit/10679. Change-Id: Iafec7084afd6c364f9852b7ff76f7cb2f947a637 Signed-off-by: Robert Varga --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43ae379a..235333c1 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,7 @@ 2013.09.07.4-SNAPSHOT 2.4.0 14.0.1 - 4.0.19.Final + 4.0.23.Final 2.3.2 0.6.2-SNAPSHOT 0.6.2-SNAPSHOT From 7c89a745861f4b54a10906e83788802d3668dad5 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 22 Jul 2014 13:29:30 +0200 Subject: [PATCH 050/285] SwitchConnectionProvider javadoc updated Change-Id: I1a724de6b0abcbf42ee2bdf666aea8a4961d0386 Signed-off-by: Michal Polkorab --- .../extensibility/DeserializerExtensionProvider.java | 11 ++++++++++- .../extensibility/SerializerExtensionProvider.java | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 0d1d9cd6..30da38c6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -20,7 +20,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; /** - * Provides methods for deserialization part of extensibility + * Provides methods for deserialization part of extensibility. + * In case of handling multiple multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of experimenter headers, which + * provide only vendor / experimenter ID. Subtype position may be different + * for different vendors (or not present at all) - that's why vendor has to + * handle it in his own implementations. * @author michal.polkorab */ public interface DeserializerExtensionProvider { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 9ee873bf..422a1500 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -22,7 +22,14 @@ /** - * Provides methods for serialization part of extensibility + * Provides methods for serialization part of extensibility. + * In case of handling multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of unknown augmentations + * - that's why vendor has to handle it in his own implementations. * @author michal.polkorab */ public interface SerializerExtensionProvider { From 81c69dc6783394fb57663efa58e127bacf3bcbf8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 22 Jul 2014 14:25:27 +0200 Subject: [PATCH 051/285] Added warn log on same key registration Change-Id: I7a42f674fa1e2fa4c027a480884ba785b6264646 Signed-off-by: Michal Polkorab --- .../api/extensibility/DeserializerRegistry.java | 8 +++++++- .../protocol/api/extensibility/SerializerRegistry.java | 6 ++++++ .../impl/deserialization/DeserializerRegistryImpl.java | 10 +++++++++- .../impl/serialization/SerializerRegistryImpl.java | 10 +++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 4afa95ae..26ac8c8b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -27,7 +27,13 @@ public interface DeserializerRegistry { SERIALIZER_TYPE getDeserializer(MessageCodeKey key); /** - * Registers deserializer + * Registers deserializer. + * Throws IllegalStateException when there is + * a deserializer already registered under given key. + * + * If the deserializer implements {@link DeserializerRegistryInjector} interface, + * the deserializer is injected with DeserializerRegistry instance. + * * @param key used for deserializer lookup * @param deserializer deserializer instance */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index bf25a609..388338e2 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -31,6 +31,12 @@ public interface SerializerRegistry { /** * Registers serializer + * Throws IllegalStateException when there is + * a serializer already registered under given key. + * + * If the serializer implements {@link SerializerRegistryInjector} interface, + * the serializer is injected with SerializerRegistry instance. + * * @param key used for serializer lookup * @param serializer serializer implementation */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index a1efd1dc..9709d6fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -20,6 +20,8 @@ import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Stores and registers deserializers @@ -27,6 +29,7 @@ */ public class DeserializerRegistryImpl implements DeserializerRegistry { + private static final Logger LOGGER = LoggerFactory.getLogger(DeserializerRegistryImpl.class); private Map registry; /** @@ -70,10 +73,15 @@ public void registerDeserializer(MessageCodeKey key, if ((key == null) || (deserializer == null)) { throw new IllegalArgumentException("MessageCodeKey or Deserializer is null"); } + OFGeneralDeserializer desInRegistry = registry.put(key, deserializer); + if (desInRegistry != null) { + LOGGER.warn("Deserializer for key " + key + " overwritten. Old deserializer: " + + desInRegistry.getClass().getName() + ", new deserializer: " + + deserializer.getClass().getName() ); + } if (deserializer instanceof DeserializerRegistryInjector) { ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this); } - registry.put(key, deserializer); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index e8a02bd7..fe2c4cf6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -20,6 +20,8 @@ import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Stores and handles serializers @@ -28,6 +30,7 @@ */ public class SerializerRegistryImpl implements SerializerRegistry { + private static final Logger LOGGER = LoggerFactory.getLogger(SerializerRegistryImpl.class); private static final short OF10 = EncodeConstants.OF10_VERSION_ID; private static final short OF13 = EncodeConstants.OF13_VERSION_ID; private Map, OFGeneralSerializer> registry; @@ -74,10 +77,15 @@ public void registerSerializer( if ((msgTypeKey == null) || (serializer == null)) { throw new IllegalArgumentException("MessageTypeKey or Serializer is null"); } + OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer); + if (serInRegistry != null) { + LOGGER.warn("Serializer for key " + msgTypeKey + " overwritten. Old serializer: " + + serInRegistry.getClass().getName() + ", new serializer: " + + serializer.getClass().getName() ); + } if (serializer instanceof SerializerRegistryInjector) { ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this); } - registry.put(msgTypeKey, serializer); } @Override From 3b00816357bdfa33c46a6b4d88fd5828307756d7 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 5 Sep 2014 14:05:26 +0200 Subject: [PATCH 052/285] Fixed incorrect exception type on deserializer lookup - removed .toString() call from log - updated test to match functionality - lowered log level on (de)serializer overwriting Change-Id: Ie58dc4e4d9bac76532a4df55170ed52e0a0e5fbc Signed-off-by: Michal Polkorab --- .../impl/deserialization/DeserializerRegistryImpl.java | 4 ++-- .../protocol/impl/serialization/SerializerRegistryImpl.java | 4 ++-- .../protocol/impl/serialization/SerializationFactoryTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 9709d6fa..f36b684f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -61,7 +61,7 @@ public DESERIALIZER_TYPE getDe MessageCodeKey key) { OFGeneralDeserializer deserializer = registry.get(key); if (deserializer == null) { - throw new NullPointerException("Deserializer for key: " + key.toString() + throw new IllegalStateException("Deserializer for key: " + key + " was not found - please verify that all needed deserializers ale loaded correctly"); } return (DESERIALIZER_TYPE) deserializer; @@ -75,7 +75,7 @@ public void registerDeserializer(MessageCodeKey key, } OFGeneralDeserializer desInRegistry = registry.put(key, deserializer); if (desInRegistry != null) { - LOGGER.warn("Deserializer for key " + key + " overwritten. Old deserializer: " + LOGGER.debug("Deserializer for key " + key + " overwritten. Old deserializer: " + desInRegistry.getClass().getName() + ", new deserializer: " + deserializer.getClass().getName() ); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index fe2c4cf6..06019394 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -64,7 +64,7 @@ public SERIALIZER_TYPE g MessageTypeKey msgTypeKey) { OFGeneralSerializer serializer = registry.get(msgTypeKey); if (serializer == null) { - throw new IllegalArgumentException("Serializer for key: {}" + msgTypeKey.toString() + throw new IllegalStateException("Serializer for key: " + msgTypeKey + " was not found - please verify that you are using correct message" + " combination (e.g. OF v1.0 message to OF v1.0 device)"); } @@ -79,7 +79,7 @@ public void registerSerializer( } OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer); if (serInRegistry != null) { - LOGGER.warn("Serializer for key " + msgTypeKey + " overwritten. Old serializer: " + LOGGER.debug("Serializer for key " + msgTypeKey + " overwritten. Old serializer: " + serInRegistry.getClass().getName() + ", new serializer: " + serializer.getClass().getName() ); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java index 9c170f8b..28add5c6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java @@ -44,7 +44,7 @@ public void test() { /** * Test serializer not found scenario */ - @Test(expected=IllegalArgumentException.class) + @Test(expected=IllegalStateException.class) public void testNotExistingSerializer() { SerializerRegistry registry = new SerializerRegistryImpl(); registry.init(); From d6250c36c63faf5f5dc13d06bc5bfec7013cc141 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 9 Sep 2014 15:22:17 +0200 Subject: [PATCH 053/285] Improved test coverage Change-Id: I0846432b14d880b17ccf1dad5759b3a1c1dcf2af Signed-off-by: Michal Polkorab --- .../extensibility/EnhancedMessageCodeKey.java | 10 +- .../ExperimenterActionSerializerKey.java | 1 + .../EnhancedMessageCodeKeyTest.java | 50 ++++++++++ .../EnhancedMessageTypeKeyTest.java | 52 ++++++++++ .../api/extensibility/MessageCodeKeyTest.java | 47 ++++++++++ .../api/extensibility/MessageTypeKeyTest.java | 44 +++++++++ .../api/keys/ActionDeserializerKeyTest.java | 43 +++++++++ .../api/keys/ActionSerializerKeyTest.java | 50 ++++++++++ .../keys/InstructionDeserializerKeyTest.java | 43 +++++++++ .../keys/InstructionSerializerKeyTest.java | 50 ++++++++++ .../keys/{extensibility => }/KeysTest.java | 2 +- .../keys/MatchEntryDeserializerKeyTest.java | 49 ++++++++++ .../api/keys/MatchEntrySerializerKeyTest.java | 57 +++++++++++ ...ExperimenterActionDeserializerKeyTest.java | 42 +++++++++ .../ExperimenterActionSerializerKeyTest.java | 57 +++++++++++ .../ExperimenterIdDeserializerKeyTest.java | 50 ++++++++++ .../ExperimenterIdSerializerKeyTest.java | 50 ++++++++++ ...imenterInstructionDeserializerKeyTest.java | 42 +++++++++ ...erimenterInstructionSerializerKeyTest.java | 43 +++++++++ .../ExperimenterDeserializerKeyFactory.java | 6 +- .../ExperimenterSerializerKeyFactory.java | 2 +- ...xperimenterDeserializerKeyFactoryTest.java | 94 +++++++++++++++++++ .../ExperimenterSerializerKeyFactoryTest.java | 72 ++++++++++++++ 23 files changed, 950 insertions(+), 6 deletions(-) create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java rename openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/{extensibility => }/KeysTest.java (98%) create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java create mode 100644 util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java create mode 100644 util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java index 509c3863..8db03d93 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java @@ -27,6 +27,14 @@ public EnhancedMessageCodeKey(short version, int value, int value2, Class cla this.msgType2 = value2; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + msgType2; + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) @@ -45,4 +53,4 @@ public boolean equals(Object obj) { public String toString() { return super.toString() + " msgType2: " + msgType2; } -} +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index be18643c..f9f3cb11 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -23,6 +23,7 @@ public final class ExperimenterActionSerializerKey extends ActionSerializerKey actionSubType) { super(msgVersion, Experimenter.class, experimenterId); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java new file mode 100644 index 00000000..9d64b21a --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageCodeKeyTest { + + /** + * Test EnhancedMessageCodeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + EnhancedMessageCodeKey key2 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 16, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java new file mode 100644 index 00000000..1d150844 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageTypeKeyTest { + + /** + * Test EnhancedMessageTypeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageTypeKey key1 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + EnhancedMessageTypeKey key2 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java new file mode 100644 index 00000000..0a991f62 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageCodeKeyTest { + + /** + * Test MessageCodeKey equals and hashCode + */ + @Test + public void test() { + MessageCodeKey key1 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + MessageCodeKey key2 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java new file mode 100644 index 00000000..05db7457 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageTypeKeyTest { + + /** + * Test MessageTypeKey equals and hashCode + */ + @Test + public void test() { + MessageTypeKey key1 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key2 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java new file mode 100644 index 00000000..3acddc0f --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKeyTest { + + /** + * Test ActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java new file mode 100644 index 00000000..5dbd02cb --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; + +/** + * @author michal.polkorab + * + */ +public class ActionSerializerKeyTest { + + /** + * Test ActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ActionSerializerKey key1 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key2 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java new file mode 100644 index 00000000..abf859ad --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKeyTest { + + /** + * Test InstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java new file mode 100644 index 00000000..295ba4e3 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; + +/** + * @author michal.polkorab + * + */ +public class InstructionSerializerKeyTest { + + /** + * Test InstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java similarity index 98% rename from openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java rename to openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index 5b464af2..6f2eb513 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/extensibility/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -1,4 +1,4 @@ -package org.opendaylight.openflowjava.protocol.api.keys.extensibility; +package org.opendaylight.openflowjava.protocol.api.keys; import junit.framework.Assert; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java new file mode 100644 index 00000000..1a5613ff --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerKeyTest { + + /** + * Test MatchEntryDeserializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + key1.setExperimenterId(158L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java new file mode 100644 index 00000000..0a6793aa --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; + +/** + * @author michal.polkorab + * + */ +public class MatchEntrySerializerKeyTest { + + /** + * Test MatchEntrySerializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntrySerializerKey key1 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + MatchEntrySerializerKey key2 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Nxm0Class.class, InPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + null, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java new file mode 100644 index 00000000..47c59033 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionDeserializerKeyTest { + + /** + * Test ExperimenterActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionDeserializerKey key1 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterActionDeserializerKey key2 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java new file mode 100644 index 00000000..59141fc4 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionSerializerKeyTest { + + /** + * Test ExperimenterActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionSerializerKey key1 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + ExperimenterActionSerializerKey key2 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + private static class TestSubType extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } + + private static class TestSubType2 extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java new file mode 100644 index 00000000..ec061904 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdDeserializerKeyTest { + + /** + * Test ExperimenterIdDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java new file mode 100644 index 00000000..768af3cc --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdSerializerKeyTest { + + /** + * Test ExperimenterIdSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java new file mode 100644 index 00000000..563cb562 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionDeserializerKeyTest { + + /** + * Test ExperimenterInstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionDeserializerKey key1 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionDeserializerKey key2 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java new file mode 100644 index 00000000..58c535f8 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionSerializerKeyTest { + + /** + * Test ExperimenterInstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionSerializerKey key1 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionSerializerKey key2 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + + } +} \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 1f3b7b25..d24d6d3f 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; @@ -20,7 +20,7 @@ * @author michal.polkorab * */ -public class ExperimenterDeserializerKeyFactory { +public abstract class ExperimenterDeserializerKeyFactory { /** * @param version openflow wire version @@ -49,7 +49,7 @@ public static ExperimenterIdDeserializerKey createExperimenterMessageDeserialize */ public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyMessage.class); + return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); } /** diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index a1647668..5d1fc635 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -18,7 +18,7 @@ * @author michal.polkorab * */ -public class ExperimenterSerializerKeyFactory { +public abstract class ExperimenterSerializerKeyFactory { /** * @param msgVersion openflow wire version diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java new file mode 100644 index 00000000..1c63fc0f --- /dev/null +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterDeserializerKeyFactoryTest { + + /** + * Test ExperimenterDeserializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory + .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdDeserializerKey comparationKey = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 43L, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 44L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 45L, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } +} \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java new file mode 100644 index 00000000..df975ea5 --- /dev/null +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterSerializerKeyFactoryTest { + + /** + * Test ExperimenterSerializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory + .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdSerializerKey comparationKey = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 44L, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 45L, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } +} \ No newline at end of file From 722d98f8e8fdd950a56a6889c4dcea8c5715c35e Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 17 Sep 2014 11:06:40 +0200 Subject: [PATCH 054/285] Bug 1935 - Double fireConnectionReady notification - in case of communication over TCP protocol the fireConnectionReady notification was incorrectly triggered twice Change-Id: I23373a6130ebd30f4f183568e4ddda354976df3f Signed-off-by: Michal Polkorab --- .../protocol/impl/core/OFFrameDecoder.java | 15 +++++++++----- .../impl/core/TcpChannelInitializer.java | 9 ++++++--- .../impl/core/OFFrameDecoderTest.java | 20 ++++++++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 88b11a6a..9aa9863a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -31,14 +31,19 @@ public class OFFrameDecoder extends ByteToMessageDecoder { private static final byte LENGTH_INDEX_IN_HEADER = 2; private static final Logger LOGGER = LoggerFactory.getLogger(OFFrameDecoder.class); private ConnectionFacade connectionFacade; - private boolean started = false; + private boolean firstTlsPass = false; /** * Constructor of class. - * @param connectionFacade + * @param connectionFacade ConnectionFacade that will be notified + * with ConnectionReadyNotification after TLS has been successfully set up. + * @param tlsPresent true is TLS is required, false otherwise */ - public OFFrameDecoder(ConnectionFacade connectionFacade) { + public OFFrameDecoder(ConnectionFacade connectionFacade, boolean tlsPresent) { LOGGER.trace("Creating OFFrameDecoder"); + if (tlsPresent) { + firstTlsPass = true; + } this.connectionFacade = connectionFacade; } @@ -55,9 +60,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E @Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) throws Exception { - if (!started) { + if (firstTlsPass) { connectionFacade.fireConnectionReadyNotification(); - started = true; + firstTlsPass = false; } int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index d84126b8..c1a9c43c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -73,16 +73,19 @@ protected void initChannel(final SocketChannel ch) { getSwitchConnectionHandler().onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); - + boolean tlsPresent = false; + // If this channel is configured to support SSL it will only support SSL if (getTlsConfiguration() != null) { + tlsPresent = true; SslContextFactory sslFactory = new SslContextFactory(getTlsConfiguration()); SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); engine.setNeedClientAuth(true); engine.setUseClientMode(false); ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), new SslHandler(engine)); } - ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade)); + ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), + new OFFrameDecoder(connectionFacade, tlsPresent)); ch.pipeline().addLast(PipelineHandlers.OF_VERSION_DETECTOR.name(), new OFVersionDetector()); OFDecoder ofDecoder = new OFDecoder(); ofDecoder.setDeserializationFactory(getDeserializationFactory()); @@ -91,7 +94,7 @@ protected void initChannel(final SocketChannel ch) { ofEncoder.setSerializationFactory(getSerializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofEncoder); ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); - if (getTlsConfiguration() == null) { + if (!tlsPresent) { connectionFacade.fireConnectionReadyNotification(); } } catch (Exception e) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java index 658b487d..23b29460 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java @@ -47,7 +47,7 @@ public class OFFrameDecoderTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - decoder = new OFFrameDecoder(connectionFacade); + decoder = new OFFrameDecoder(connectionFacade, false); list.clear(); } @@ -146,4 +146,22 @@ public void testDecodeCompleteAndPartialMessage() { public void testExceptionCaught() throws Exception { decoder.exceptionCaught(channelHandlerContext, new Throwable()); } + + /** + * Test of decoding + * {@link OFFrameDecoder#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)} + */ + @Test + public void testDecode8BMessageWithTls() { + decoder = new OFFrameDecoder(connectionFacade, true); + try { + decoder.decode(channelHandlerContext, + ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"), + list); + } catch (Exception e) { + Assert.fail(); + } + + assertEquals(8, ((ByteBuf) list.get(0)).readableBytes()); + } } From 568458e894a3bc5d64b728e3fe2068af10d08dc8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 17 Sep 2014 11:34:40 +0200 Subject: [PATCH 055/285] Removed unused extensibility bundles - functionality of removed bundles is present in openflowplugin Change-Id: I073d2de7e0a3c0dee92511e47c45e44e9be12e16 Signed-off-by: Michal Polkorab --- openflow-extension-nicira/pom.xml | 114 ----------- .../impl/NiciraExtensionProviderModule.java | 26 --- .../NiciraExtensionProviderModuleFactory.java | 13 -- .../openflowjava/nx/NiciraConstants.java | 8 - .../nx/NiciraExtensionsRegistrator.java | 141 -------------- .../openflowjava/nx/NiciraMatchCodecs.java | 56 ------ .../action/AbstractActionSerializer.java | 34 ---- .../nx/codec/action/ActionDeserializer.java | 59 ------ .../nx/codec/action/NiciraActionCodecs.java | 19 -- .../nx/codec/action/RegLoadCodec.java | 42 ---- .../nx/codec/action/RegMoveCodec.java | 44 ----- .../nx/codec/match/AbstractMatchCodec.java | 88 --------- .../nx/codec/match/AbstractRegCodec.java | 49 ----- .../nx/codec/match/ArpOpCodec.java | 69 ------- .../nx/codec/match/ArpShaCodec.java | 74 ------- .../nx/codec/match/ArpSpaCodec.java | 69 ------- .../nx/codec/match/ArpThaCodec.java | 74 ------- .../nx/codec/match/ArpTpaCodec.java | 69 ------- .../nx/codec/match/EthDstCodec.java | 74 ------- .../nx/codec/match/EthSrcCodec.java | 74 ------- .../nx/codec/match/EthTypeCodec.java | 69 ------- .../nx/codec/match/NxmHeader.java | 94 --------- .../nx/codec/match/Reg0Codec.java | 29 --- .../nx/codec/match/Reg1Codec.java | 29 --- .../nx/codec/match/Reg2Codec.java | 29 --- .../nx/codec/match/Reg3Codec.java | 29 --- .../nx/codec/match/Reg4Codec.java | 29 --- .../nx/codec/match/Reg5Codec.java | 29 --- .../nx/codec/match/Reg6Codec.java | 29 --- .../nx/codec/match/Reg7Codec.java | 29 --- .../nx/codec/match/TunIdCodec.java | 72 ------- .../nx/codec/match/TunIpv4DstCodec.java | 69 ------- .../nx/codec/match/TunIpv4SrcCodec.java | 69 ------- .../initial/43-openflow-nx-config.xml | 28 --- .../src/main/yang/nicira-action.yang | 64 ------ .../yang/nicira-extension-provider-impl.yang | 36 ---- .../src/main/yang/nicira-match.yang | 182 ------------------ openflow-nx-resubmit-action/pom.xml | 112 ----------- .../nx/NxResubmitActionRegistrator.java | 79 -------- .../NxActionResubmitDeserializer.java | 61 ------ .../NxActionResubmitSerializer.java | 51 ----- .../NxResubmitActionRegistratorModule.java | 27 --- ...esubmitActionRegistratorModuleFactory.java | 13 -- .../43-openflow-nx-resubmit-config.xml | 35 ---- .../src/main/resources/log4j.xml | 20 -- .../src/main/yang/nx-resubmit-action.yang | 38 ---- .../yang/openflow-nx-resubmit-action.yang | 45 ----- .../NxActionResubmitDeserializerTest.java | 56 ------ .../NxActionResubmitSerializerTest.java | 86 --------- pom.xml | 2 - 50 files changed, 2736 deletions(-) delete mode 100644 openflow-extension-nicira/pom.xml delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java delete mode 100644 openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java delete mode 100644 openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml delete mode 100644 openflow-extension-nicira/src/main/yang/nicira-action.yang delete mode 100644 openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang delete mode 100644 openflow-extension-nicira/src/main/yang/nicira-match.yang delete mode 100644 openflow-nx-resubmit-action/pom.xml delete mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java delete mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java delete mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java delete mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java delete mode 100644 openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java delete mode 100644 openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml delete mode 100644 openflow-nx-resubmit-action/src/main/resources/log4j.xml delete mode 100644 openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang delete mode 100644 openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang delete mode 100644 openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java delete mode 100644 openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java diff --git a/openflow-extension-nicira/pom.xml b/openflow-extension-nicira/pom.xml deleted file mode 100644 index 750b209a..00000000 --- a/openflow-extension-nicira/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - 4.0.0 - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.5-SNAPSHOT - - openflow-extension-nicira - bundle - Openflow Protocol Library - Nicira extensions - http://maven.apache.org - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - - - - org.opendaylight.yangtools - yang-maven-plugin - - - - generate-sources - - - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - - ${jmxGeneratorPath} - - - urn:opendaylight:params:xml:ns:yang:controller:config==org.opendaylight.controller.config.yang - - - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - - ${salGeneratorPath} - - - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl - ${project.build.directory}/site/models - - - true - - - - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${config.version} - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.generator.version} - jar - - - - - - - - - - ${project.groupId} - openflow-protocol-api - ${project.version} - - - ${project.groupId} - openflow-protocol-spi - ${project.version} - - - org.opendaylight.openflowjava - util - ${project.version} - - - org.opendaylight.yangtools.model - yang-ext - - - io.netty - netty-buffer - - - junit - junit - test - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - org.opendaylight.controller - config-api - - - diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java deleted file mode 100644 index d62b4ea7..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModule.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.opendaylight.controller.config.yang.openflow.extension.nicira.impl; - -import org.opendaylight.openflowjava.nx.NiciraExtensionsRegistrator; - -public class NiciraExtensionProviderModule extends org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.AbstractNiciraExtensionProviderModule { - public NiciraExtensionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public NiciraExtensionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.NiciraExtensionProviderModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - NiciraExtensionsRegistrator niciraExtensionsRegistrator = new NiciraExtensionsRegistrator(getOpenflowSwitchConnectionProviderDependency()); - niciraExtensionsRegistrator.registerNiciraExtensions(); - return niciraExtensionsRegistrator; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java b/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java deleted file mode 100644 index 222747b6..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/controller/config/yang/openflow/extension/nicira/impl/NiciraExtensionProviderModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: nicira-extension-provider-impl yang module local name: openflow-extension-nicira -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Fri Jul 11 13:27:17 CEST 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.controller.config.yang.openflow.extension.nicira.impl; -public class NiciraExtensionProviderModuleFactory extends org.opendaylight.controller.config.yang.openflow.extension.nicira.impl.AbstractNiciraExtensionProviderModuleFactory { - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java deleted file mode 100644 index b1ed1596..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.opendaylight.openflowjava.nx; - - -public class NiciraConstants { - - public static final Long NX_VENDOR_ID = 0x00002320L; - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java deleted file mode 100644 index 1ed72236..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraExtensionsRegistrator.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.opendaylight.openflowjava.nx; - -import java.util.List; - -import org.opendaylight.openflowjava.nx.codec.action.ActionDeserializer; -import org.opendaylight.openflowjava.nx.codec.action.NiciraActionCodecs; -import org.opendaylight.openflowjava.nx.codec.action.RegLoadCodec; -import org.opendaylight.openflowjava.nx.codec.action.RegMoveCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec; -import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg3Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec; -import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec; -import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec; -import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; - -import com.google.common.base.Preconditions; - -public class NiciraExtensionsRegistrator implements AutoCloseable { - - private final List providers; - - /** - * @param providers cannot be null - */ - public NiciraExtensionsRegistrator(List providers) { - Preconditions.checkNotNull(providers); - this.providers = providers; - } - - public void registerNiciraExtensions() { - for (SwitchConnectionProvider provider : providers) { - provider.registerActionDeserializer(ActionDeserializer.DESERIALIZER_KEY, NiciraActionCodecs.ACTION_DESERIALIZER); - provider.registerActionSerializer(RegLoadCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_LOAD_CODEC); - provider.registerActionSerializer(RegMoveCodec.SERIALIZER_KEY, NiciraActionCodecs.REG_MOVE_CODEC); - provider.registerMatchEntrySerializer(Reg0Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); - provider.registerMatchEntryDeserializer(Reg0Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG0_CODEC); - provider.registerMatchEntrySerializer(Reg1Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC); - provider.registerMatchEntryDeserializer(Reg1Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG1_CODEC); - provider.registerMatchEntrySerializer(Reg2Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG2_CODEC); - provider.registerMatchEntryDeserializer(Reg2Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG2_CODEC); - provider.registerMatchEntrySerializer(Reg3Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG3_CODEC); - provider.registerMatchEntryDeserializer(Reg3Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG3_CODEC); - provider.registerMatchEntrySerializer(Reg4Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG4_CODEC); - provider.registerMatchEntryDeserializer(Reg4Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG4_CODEC); - provider.registerMatchEntrySerializer(Reg5Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG5_CODEC); - provider.registerMatchEntryDeserializer(Reg5Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG5_CODEC); - provider.registerMatchEntrySerializer(Reg6Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG6_CODEC); - provider.registerMatchEntryDeserializer(Reg6Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG6_CODEC); - provider.registerMatchEntrySerializer(Reg7Codec.SERIALIZER_KEY, NiciraMatchCodecs.REG7_CODEC); - provider.registerMatchEntryDeserializer(Reg7Codec.DESERIALIZER_KEY, NiciraMatchCodecs.REG7_CODEC); - provider.registerMatchEntrySerializer(TunIdCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_ID_CODEC); - provider.registerMatchEntryDeserializer(TunIdCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_ID_CODEC); - provider.registerMatchEntrySerializer(ArpOpCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_OP_CODEC); - provider.registerMatchEntryDeserializer(ArpOpCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_OP_CODEC); - provider.registerMatchEntrySerializer(ArpShaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_SHA_CODEC); - provider.registerMatchEntryDeserializer(ArpShaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_SHA_CODEC); - provider.registerMatchEntrySerializer(ArpSpaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_SPA_CODEC); - provider.registerMatchEntryDeserializer(ArpSpaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_SPA_CODEC); - provider.registerMatchEntrySerializer(ArpThaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_THA_CODEC); - provider.registerMatchEntryDeserializer(ArpThaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_THA_CODEC); - provider.registerMatchEntrySerializer(ArpTpaCodec.SERIALIZER_KEY, NiciraMatchCodecs.ARP_TPA_CODEC); - provider.registerMatchEntryDeserializer(ArpTpaCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ARP_TPA_CODEC); - provider.registerMatchEntrySerializer(EthDstCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC); - provider.registerMatchEntryDeserializer(EthDstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_DST_CODEC); - provider.registerMatchEntrySerializer(EthSrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_SRC_CODEC); - provider.registerMatchEntryDeserializer(EthSrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_SRC_CODEC); - provider.registerMatchEntrySerializer(TunIpv4DstCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC); - provider.registerMatchEntryDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_DST_CODEC); - provider.registerMatchEntrySerializer(TunIpv4SrcCodec.SERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); - provider.registerMatchEntryDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY, NiciraMatchCodecs.TUN_IPV4_SRC_CODEC); - provider.registerMatchEntrySerializer(EthTypeCodec.SERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC); - provider.registerMatchEntryDeserializer(EthTypeCodec.DESERIALIZER_KEY, NiciraMatchCodecs.ETH_TYPE_CODEC); - } - } - - public void unregisterExtensions() { - for (SwitchConnectionProvider provider : providers) { - provider.unregisterDeserializer(ActionDeserializer.DESERIALIZER_KEY); - provider.unregisterSerializer(RegLoadCodec.SERIALIZER_KEY); - provider.unregisterSerializer(RegMoveCodec.SERIALIZER_KEY); - provider.unregisterSerializer(Reg0Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg0Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg1Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg1Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg2Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg2Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg3Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg3Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg4Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg4Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg5Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg5Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg6Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg6Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(Reg7Codec.SERIALIZER_KEY); - provider.unregisterDeserializer(Reg7Codec.DESERIALIZER_KEY); - provider.unregisterSerializer(TunIdCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(TunIdCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(ArpOpCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ArpOpCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(ArpShaCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ArpShaCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(ArpSpaCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ArpSpaCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(ArpThaCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ArpThaCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(ArpTpaCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(ArpTpaCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(EthDstCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(EthDstCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(EthSrcCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(EthSrcCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(TunIpv4DstCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(TunIpv4DstCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(TunIpv4SrcCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(TunIpv4SrcCodec.DESERIALIZER_KEY); - provider.unregisterSerializer(EthTypeCodec.SERIALIZER_KEY); - provider.unregisterDeserializer(EthTypeCodec.DESERIALIZER_KEY); - } - } - - @Override - public void close() throws Exception { - unregisterExtensions(); - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java deleted file mode 100644 index b9422f51..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/NiciraMatchCodecs.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.nx; - -import org.opendaylight.openflowjava.nx.codec.match.ArpOpCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpShaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpSpaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpThaCodec; -import org.opendaylight.openflowjava.nx.codec.match.ArpTpaCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthDstCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthSrcCodec; -import org.opendaylight.openflowjava.nx.codec.match.EthTypeCodec; -import org.opendaylight.openflowjava.nx.codec.match.Reg0Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg1Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg2Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg3Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg4Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg5Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg6Codec; -import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec; -import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec; -import org.opendaylight.openflowjava.nx.codec.match.TunIpv4DstCodec; -import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec; - -/** - * @author msunal - * - */ -public class NiciraMatchCodecs { - - public static final Reg0Codec REG0_CODEC = new Reg0Codec(); - public static final Reg1Codec REG1_CODEC = new Reg1Codec(); - public static final Reg2Codec REG2_CODEC = new Reg2Codec(); - public static final Reg3Codec REG3_CODEC = new Reg3Codec(); - public static final Reg4Codec REG4_CODEC = new Reg4Codec(); - public static final Reg5Codec REG5_CODEC = new Reg5Codec(); - public static final Reg6Codec REG6_CODEC = new Reg6Codec(); - public static final Reg7Codec REG7_CODEC = new Reg7Codec(); - public static final TunIdCodec TUN_ID_CODEC = new TunIdCodec(); - public static final ArpOpCodec ARP_OP_CODEC = new ArpOpCodec(); - public static final ArpShaCodec ARP_SHA_CODEC = new ArpShaCodec(); - public static final ArpSpaCodec ARP_SPA_CODEC = new ArpSpaCodec(); - public static final ArpThaCodec ARP_THA_CODEC = new ArpThaCodec(); - public static final ArpTpaCodec ARP_TPA_CODEC = new ArpTpaCodec(); - public static final EthDstCodec ETH_DST_CODEC = new EthDstCodec(); - public static final EthSrcCodec ETH_SRC_CODEC = new EthSrcCodec(); - public static final TunIpv4DstCodec TUN_IPV4_DST_CODEC = new TunIpv4DstCodec(); - public static final TunIpv4SrcCodec TUN_IPV4_SRC_CODEC = new TunIpv4SrcCodec(); - public static final EthTypeCodec ETH_TYPE_CODEC = new EthTypeCodec(); - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java deleted file mode 100644 index b141d5ca..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/AbstractActionSerializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.nx.codec.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.nx.NiciraConstants; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author msunal - * - */ -public abstract class AbstractActionSerializer implements OFSerializer { - - protected final static void serializeHeader(int msgLength, int subtype, ByteBuf outBuffer) { - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - writeMsgLengthVendorIdSubtypeToBuffer(msgLength, subtype, outBuffer); - } - - private final static void writeMsgLengthVendorIdSubtypeToBuffer(int msgLength, int subtype, ByteBuf outBuffer) { - outBuffer.writeShort(msgLength); - outBuffer.writeInt(NiciraConstants.NX_VENDOR_ID.intValue()); - outBuffer.writeShort(subtype); - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java deleted file mode 100644 index 43e3de09..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ActionDeserializer.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.nx.NiciraConstants; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxActionBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ActionDeserializer implements OFDeserializer { - - private static final Logger LOG = LoggerFactory.getLogger(ActionDeserializer.class); - - public static final ExperimenterActionDeserializerKey DESERIALIZER_KEY = new ExperimenterActionDeserializerKey( - EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID); - - @Override - public Action deserialize(ByteBuf message) { - // size of experimenter type - message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - // size of length - message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(message.readUnsignedInt())); - int subtype = message.readUnsignedShort(); - OfjAugNxActionBuilder augNxActionBuilder = new OfjAugNxActionBuilder(); - switch (subtype) { - case RegMoveCodec.SUBTYPE: - augNxActionBuilder.setActionRegMove(NiciraActionCodecs.REG_MOVE_CODEC.deserialize(message)); - expIdBuilder.setSubType(NxmNxRegMove.class); - break; - case RegLoadCodec.SUBTYPE: - augNxActionBuilder.setActionRegLoad(NiciraActionCodecs.REG_LOAD_CODEC.deserialize(message)); - expIdBuilder.setSubType(NxmNxRegLoad.class); - break; - default: - LOG.info("Action {} does not have any deserializer.", subtype); - return null; - } - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Experimenter.class); - actionBuilder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - actionBuilder.addAugmentation(OfjAugNxAction.class, augNxActionBuilder.build()); - return actionBuilder.build(); - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java deleted file mode 100644 index 877b677f..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/NiciraActionCodecs.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.nx.codec.action; - -/** - * @author msunal - * - */ -public class NiciraActionCodecs { - - public static final RegMoveCodec REG_MOVE_CODEC = new RegMoveCodec(); - public static final RegLoadCodec REG_LOAD_CODEC = new RegLoadCodec(); - public static final ActionDeserializer ACTION_DESERIALIZER = new ActionDeserializer(); -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java deleted file mode 100644 index 0ccfa881..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.action; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.opendaylight.openflowjava.nx.NiciraConstants; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegLoad; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoad; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.load.grouping.ActionRegLoadBuilder; - -public class RegLoadCodec extends AbstractActionSerializer implements OFDeserializer { - - public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegLoad.class); - public static final int LENGTH = 24; - public static final byte SUBTYPE = 7; // NXAST_REG_LOAD - - @Override - public void serialize(Action input, ByteBuf outBuffer) { - ActionRegLoad actionRegLoad = input.getAugmentation(OfjAugNxAction.class).getActionRegLoad(); - serializeHeader(LENGTH, SUBTYPE, outBuffer); - outBuffer.writeShort(actionRegLoad.getOfsNbits()); - outBuffer.writeInt(actionRegLoad.getDst().intValue()); - outBuffer.writeLong(actionRegLoad.getValue().longValue()); - } - - @Override - public ActionRegLoad deserialize(ByteBuf message) { - ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder(); - actionRegLoadBuilder.setOfsNbits(message.readUnsignedShort()); - actionRegLoadBuilder.setDst(message.readUnsignedInt()); - actionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong())); - return actionRegLoadBuilder.build(); - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java deleted file mode 100644 index f9bf8716..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.nx.NiciraConstants; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.NxmNxRegMove; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.OfjAugNxAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMove; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.action.rev140421.ofj.nx.action.reg.move.grouping.ActionRegMoveBuilder; - -public class RegMoveCodec extends AbstractActionSerializer implements OFDeserializer { - - public static final ExperimenterActionSerializerKey SERIALIZER_KEY = new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NiciraConstants.NX_VENDOR_ID, NxmNxRegMove.class); - public static final int LENGTH = 24; - public static final byte SUBTYPE = 6; // NXAST_REG_MOVE - - @Override - public void serialize(Action input, ByteBuf outBuffer) { - ActionRegMove actionRegMove = input.getAugmentation(OfjAugNxAction.class).getActionRegMove(); - serializeHeader(LENGTH, SUBTYPE, outBuffer); - outBuffer.writeShort(actionRegMove.getNBits()); - outBuffer.writeShort(actionRegMove.getSrcOfs()); - outBuffer.writeShort(actionRegMove.getDstOfs()); - outBuffer.writeInt(actionRegMove.getSrc().intValue()); - outBuffer.writeInt(actionRegMove.getDst().intValue()); - } - - @Override - public ActionRegMove deserialize(ByteBuf message) { - ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder(); - actionRegMoveBuilder.setNBits(message.readUnsignedShort()); - actionRegMoveBuilder.setSrcOfs(message.readUnsignedShort()); - actionRegMoveBuilder.setDstOfs(message.readUnsignedShort()); - actionRegMoveBuilder.setSrc(message.readUnsignedInt()); - actionRegMoveBuilder.setDst(message.readUnsignedInt()); - return actionRegMoveBuilder.build(); - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java deleted file mode 100644 index f7d5b53e..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractMatchCodec.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.nx.NiciraConstants; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public abstract class AbstractMatchCodec implements OFSerializer, OFDeserializer { - - private NxmHeader headerWithMask; - private NxmHeader headerWithoutMask; - - protected MatchEntriesBuilder deserializeHeader(ByteBuf message) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(getOxmClass()); - // skip oxm_class - provided - message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setOxmMatchField(getNxmField()); - boolean hasMask = (message.readUnsignedByte() & 1) != 0; - builder.setHasMask(hasMask); - // skip match entry length - not needed - message.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - ExperimenterIdMatchEntryBuilder experimenterIdMatchEntryBuilder = new ExperimenterIdMatchEntryBuilder(); - experimenterIdMatchEntryBuilder.setExperimenter(new ExperimenterId(NiciraConstants.NX_VENDOR_ID)); - builder.addAugmentation(ExperimenterIdMatchEntry.class, experimenterIdMatchEntryBuilder.build()); - return builder; - } - - protected void serializeHeader(MatchEntries input, ByteBuf outBuffer) { - outBuffer.writeInt(serializeHeaderToLong(input.isHasMask()).intValue()); - } - - private Long serializeHeaderToLong(boolean hasMask) { - if (hasMask) { - return getHeaderWithHasMask().toLong(); - } - return getHeaderWithoutHasMask().toLong(); - } - - public NxmHeader getHeaderWithoutHasMask() { - if (headerWithoutMask == null) { - headerWithoutMask = new NxmHeader(getOxmClassCode(), getNxmFieldCode(), false, getValueLength()); - } - return headerWithoutMask; - } - - public NxmHeader getHeaderWithHasMask() { - if (headerWithMask == null) { - headerWithMask = new NxmHeader(getOxmClassCode(), getNxmFieldCode(), true, getValueLength()); - } - return headerWithMask; - } - - /** - * @return numeric representation of nxm_field - */ - public abstract int getNxmFieldCode(); - - /** - * @return numeric representation of oxm_class - */ - public abstract int getOxmClassCode(); - - /** - * @return match entry value length - */ - public abstract int getValueLength(); - - /** - * @return nxm_field class - */ - public abstract Class getNxmField(); - - /** - * @return oxm_class class - */ - public abstract Class getOxmClass(); - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java deleted file mode 100644 index abafe097..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.reg.grouping.RegValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public abstract class AbstractRegCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 4; - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setRegValues(new RegValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Long value = input.getAugmentation(OfjAugNxMatch.class).getRegValues().getValue(); - outBuffer.writeInt(value.intValue()); - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java deleted file mode 100644 index 9e410042..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.op.grouping.ArpOpValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class ArpOpCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 2; - private static final int NXM_FIELD_CODE = 15; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpOp.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Integer value = input.getAugmentation(OfjAugNxMatch.class).getArpOpValues().getValue(); - outBuffer.writeShort(value); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setArpOpValues(new ArpOpValuesBuilder().setValue(message.readUnsignedShort()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfArpOp.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java deleted file mode 100644 index de8ca0c8..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpShaCodec.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.arp.sha.grouping.ArpShaValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class ArpShaCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 6; - private static final int NXM_FIELD_CODE = 17; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpSha.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - String value = input.getAugmentation(OfjAugNxMatch.class).getArpShaValues().getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - byte[] address = new byte[VALUE_LENGTH]; - message.readBytes(address); - augNxMatchBuilder.setArpShaValues(new ArpShaValuesBuilder().setMacAddress( - new MacAddress(ByteBufUtils.macAddressToString(address))).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmNxArpSha.class; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java deleted file mode 100644 index 487c64c9..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.spa.grouping.ArpSpaValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class ArpSpaCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 4; - private static final int NXM_FIELD_CODE = 16; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpSpa.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Long value = input.getAugmentation(OfjAugNxMatch.class).getArpSpaValues().getValue(); - outBuffer.writeInt(value.intValue()); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setArpSpaValues(new ArpSpaValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfArpSpa.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java deleted file mode 100644 index 07cf46d8..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpThaCodec.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.arp.tha.grouping.ArpThaValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class ArpThaCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 6; - private static final int NXM_FIELD_CODE = 18; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxArpTha.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - String value = input.getAugmentation(OfjAugNxMatch.class).getArpThaValues().getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - byte[] address = new byte[VALUE_LENGTH]; - message.readBytes(address); - augNxMatchBuilder.setArpThaValues(new ArpThaValuesBuilder().setMacAddress( - new MacAddress(ByteBufUtils.macAddressToString(address))).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmNxArpTha.class; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java deleted file mode 100644 index 6962a529..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.arp.tpa.grouping.ArpTpaValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class ArpTpaCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 4; - private static final int NXM_FIELD_CODE = 17; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfArpTpa.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Long value = input.getAugmentation(OfjAugNxMatch.class).getArpTpaValues().getValue(); - outBuffer.writeInt(value.intValue()); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setArpTpaValues(new ArpTpaValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfArpTpa.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java deleted file mode 100644 index 9c25f936..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthDstCodec.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.dst.grouping.EthDstValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class EthDstCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 6; - private static final int NXM_FIELD_CODE = 1; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthDst.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - String value = input.getAugmentation(OfjAugNxMatch.class).getEthDstValues().getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - byte[] address = new byte[VALUE_LENGTH]; - message.readBytes(address); - augNxMatchBuilder.setEthDstValues(new EthDstValuesBuilder().setMacAddress( - new MacAddress(ByteBufUtils.macAddressToString(address))).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfEthDst.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java deleted file mode 100644 index 38c27421..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthSrcCodec.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.src.grouping.EthSrcValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class EthSrcCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 6; - private static final int NXM_FIELD_CODE = 2; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthSrc.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - String value = input.getAugmentation(OfjAugNxMatch.class).getEthSrcValues().getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(value)); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - byte[] address = new byte[VALUE_LENGTH]; - message.readBytes(address); - augNxMatchBuilder.setEthSrcValues(new EthSrcValuesBuilder().setMacAddress( - new MacAddress(ByteBufUtils.macAddressToString(address))).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfEthSrc.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java deleted file mode 100644 index 4eccd373..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmOfEthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class EthTypeCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 2; - private static final int NXM_FIELD_CODE = 3; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm0Class.class, NxmOfEthType.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Integer value = input.getAugmentation(OfjAugNxMatch.class).getEthTypeValues().getValue(); - outBuffer.writeShort(value); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setEthTypeValues(new EthTypeValuesBuilder().setValue(message.readUnsignedShort()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_0_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmOfEthType.class; - } - - @Override - public Class getOxmClass() { - return Nxm0Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java deleted file mode 100644 index ebcf669b..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NxmHeader.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.nx.codec.match; - -import com.google.common.primitives.Ints; - -/** - * @author msunal - * - */ -public class NxmHeader { - - private final long headerAsLong; - private final int oxmClass; - private final int nxmField; - private final boolean hasMask; - private final int length; - - public NxmHeader(long header) { - this.headerAsLong = header; - this.oxmClass = Ints.checkedCast(extractSub(header, 16, 16)); - this.nxmField = Ints.checkedCast(extractSub(header, 7, 9)); - this.hasMask = extractSub(header, 1, 8) == 1 ? true : false; - this.length = Ints.checkedCast(extractSub(header, 8, 0)); - } - - public NxmHeader(int oxmClass, int nxmField, boolean hasMask, int length) { - this.oxmClass = oxmClass; - this.nxmField = nxmField; - this.hasMask = hasMask; - this.length = length; - this.headerAsLong = ((((long) oxmClass) << 16) | (nxmField << 9) | ((hasMask ? 1 : 0) << 8) | (length)); - } - - private static long extractSub(final long l, final int nrBits, final int offset) { - final long rightShifted = l >>> offset; - final long mask = (1L << nrBits) - 1L; - return rightShifted & mask; - } - - public long toLong() { - return headerAsLong; - } - - public int getOxmClass() { - return oxmClass; - } - - public int getNxmField() { - return nxmField; - } - - public boolean isHasMask() { - return hasMask; - } - - public int getLength() { - return length; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (headerAsLong ^ (headerAsLong >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NxmHeader other = (NxmHeader) obj; - if (headerAsLong != other.headerAsLong) - return false; - return true; - } - - @Override - public String toString() { - return "NxmHeader [headerAsLong=" + headerAsLong + ", oxmClass=" + oxmClass + ", nxmField=" + nxmField - + ", hasMask=" + hasMask + ", length=" + length + "]"; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java deleted file mode 100644 index a8f83343..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg0Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg0; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg0Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 0; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg0.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg0.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java deleted file mode 100644 index 3a95c1d3..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg1Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg1; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg1Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 1; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg1.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg1.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java deleted file mode 100644 index 02a14cd5..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg2Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg2; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg2Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 2; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg2.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg2.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java deleted file mode 100644 index 7ab139e7..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg3Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg3; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg3Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 3; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg3.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg3.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java deleted file mode 100644 index 67e1b477..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg4Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg4; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg4Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 4; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg4.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg4.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java deleted file mode 100644 index d148e265..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg5Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg5; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg5Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 5; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg5.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg5.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java deleted file mode 100644 index b6a2a404..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg6Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg6; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg6Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 6; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg6.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg6.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java deleted file mode 100644 index 9f925c1a..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Reg7Codec.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxReg7; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; - -public class Reg7Codec extends AbstractRegCodec { - - private static final int NXM_FIELD_CODE = 7; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxReg7.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public Class getNxmField() { - return NxmNxReg7.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java deleted file mode 100644 index 8ee984db..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIdCodec.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.id.grouping.TunIdValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class TunIdCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 8; - private static final int NXM_FIELD_CODE = 16; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunId.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - BigInteger value = input.getAugmentation(OfjAugNxMatch.class).getTunIdValues().getValue(); - outBuffer.writeLong(value.longValue()); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setTunIdValues(new TunIdValuesBuilder().setValue(BigInteger.valueOf(message.readLong())) - .build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmNxTunId.class; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java deleted file mode 100644 index 4c2cb3ea..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunIpv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.ipv4.dst.grouping.TunIpv4DstValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class TunIpv4DstCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 4; - private static final int NXM_FIELD_CODE = 32; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Dst.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Long value = input.getAugmentation(OfjAugNxMatch.class).getTunIpv4DstValues().getValue(); - outBuffer.writeInt(value.intValue()); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setTunIpv4DstValues(new TunIpv4DstValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmNxTunIpv4Dst.class; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java b/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java deleted file mode 100644 index 8e0cc0ed..00000000 --- a/openflow-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.opendaylight.openflowjava.nx.codec.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.NxmNxTunIpv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.OfjAugNxMatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.extension.nicira.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -public class TunIpv4SrcCodec extends AbstractMatchCodec { - - private static final int VALUE_LENGTH = 4; - private static final int NXM_FIELD_CODE = 31; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Nxm1Class.class, NxmNxTunIpv4Src.class); - public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( - EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_1_CLASS, NXM_FIELD_CODE); - - @Override - public void serialize(MatchEntries input, ByteBuf outBuffer) { - serializeHeader(input, outBuffer); - Long value = input.getAugmentation(OfjAugNxMatch.class).getTunIpv4SrcValues().getValue(); - outBuffer.writeInt(value.intValue()); - } - - @Override - public MatchEntries deserialize(ByteBuf message) { - MatchEntriesBuilder matchEntriesBuilder = deserializeHeader(message); - OfjAugNxMatchBuilder augNxMatchBuilder = new OfjAugNxMatchBuilder(); - augNxMatchBuilder.setTunIpv4SrcValues(new TunIpv4SrcValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.addAugmentation(OfjAugNxMatch.class, augNxMatchBuilder.build()); - return matchEntriesBuilder.build(); - } - - @Override - public int getNxmFieldCode() { - return NXM_FIELD_CODE; - } - - @Override - public int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - public int getValueLength() { - return VALUE_LENGTH; - } - - @Override - public Class getNxmField() { - return NxmNxTunIpv4Src.class; - } - - @Override - public Class getOxmClass() { - return Nxm1Class.class; - } - -} diff --git a/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml b/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml deleted file mode 100644 index 2fbad0d2..00000000 --- a/openflow-extension-nicira/src/main/resources/initial/43-openflow-nx-config.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - urn:opendaylight:params:xml:ns:yang:controller:config:openflow:extension:nicira:impl?module=nicira-extension-provider-impl&revision=2014-07-11 - - - - - - - - prefix:openflow-extension-nicira - openflow-nx-bundle - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-legacy - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-default - - - - - - - diff --git a/openflow-extension-nicira/src/main/yang/nicira-action.yang b/openflow-extension-nicira/src/main/yang/nicira-action.yang deleted file mode 100644 index c43b1520..00000000 --- a/openflow-extension-nicira/src/main/yang/nicira-action.yang +++ /dev/null @@ -1,64 +0,0 @@ -module nicira-action { - yang-version 1; - - namespace "urn:opendaylight:openflow:extension:nicira:action"; - prefix "nicira-action"; - - import openflow-action {prefix ofaction;} - import openflow-types {prefix oft;} - import yang-ext {prefix ext; revision-date "2013-07-09";} - - description - "Nicira openflow extensions of action."; - - revision "2014-04-21" { - description "Initial revision"; - } - - identity nxm-nx-reg-load { - base ofaction:experimenter-action-sub-type; - } - identity nxm-nx-reg-move { - base ofaction:experimenter-action-sub-type; - } - - grouping ofj-nx-action-reg-load-grouping { - container action-reg-load { - leaf ofs_nbits { - type uint16; - } - leaf dst { - type uint32; - } - leaf value { - type uint64; - } - } - } - grouping ofj-nx-action-reg-move-grouping { - container action-reg-move { - leaf n_bits { - type uint16; - } - leaf src_ofs { - type uint16; - } - leaf dst_ofs { - type uint16; - } - leaf src { - type uint32; - } - leaf dst { - type uint32; - } - } - } - - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ofj-aug-nx-action"; - uses ofj-nx-action-reg-load-grouping; - uses ofj-nx-action-reg-move-grouping; - } - -} \ No newline at end of file diff --git a/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang b/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang deleted file mode 100644 index 81d97565..00000000 --- a/openflow-extension-nicira/src/main/yang/nicira-extension-provider-impl.yang +++ /dev/null @@ -1,36 +0,0 @@ -module nicira-extension-provider-impl { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:controller:config:openflow:extension:nicira:impl"; - prefix "openflow-nx"; - - import config {prefix config; revision-date 2013-04-05;} - import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} - - description - "Nicira extensions in openflow library."; - - revision "2014-07-11" { - description - "Initial revision"; - } - - identity openflow-extension-nicira { - base config:module-type; - config:java-name-prefix NiciraExtensionProvider; - } - - augment "/config:modules/config:module/config:configuration" { - case openflow-extension-nicira { - when "/config:modules/config:module/config:type = 'openflow-extension-nicira'"; - - list openflow-switch-connection-provider { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; - } - } - } - } - } -} \ No newline at end of file diff --git a/openflow-extension-nicira/src/main/yang/nicira-match.yang b/openflow-extension-nicira/src/main/yang/nicira-match.yang deleted file mode 100644 index 3bff0351..00000000 --- a/openflow-extension-nicira/src/main/yang/nicira-match.yang +++ /dev/null @@ -1,182 +0,0 @@ -module nicira-match { - yang-version 1; - - namespace "urn:opendaylight:openflow:extension:nicira:match"; - prefix "nicira-match"; - - import openflow-extensible-match {prefix ofoxm;} - import openflow-types {prefix oft;} - import ietf-yang-types {prefix yang; revision-date "2010-09-24";} - import yang-ext {prefix ext; revision-date "2013-07-09";} - - description - "Nicira openflow extensions of match."; - - revision "2014-04-21" { - description "Initial revision"; - } - - identity nxm-nx-reg { - base ofoxm:match-field; - } - - identity nxm-nx-reg0 { - base nxm-nx-reg; - } - identity nxm-nx-reg1 { - base nxm-nx-reg; - } - identity nxm-nx-reg2 { - base nxm-nx-reg; - } - identity nxm-nx-reg3 { - base nxm-nx-reg; - } - identity nxm-nx-reg4 { - base nxm-nx-reg; - } - identity nxm-nx-reg5 { - base nxm-nx-reg; - } - identity nxm-nx-reg6 { - base nxm-nx-reg; - } - identity nxm-nx-reg7 { - base nxm-nx-reg; - } - identity nxm-nx-tun-id { - base ofoxm:match-field; - } - identity nxm-nx-arp-sha { - base ofoxm:match-field; - } - identity nxm-nx-arp-tha { - base ofoxm:match-field; - } - identity nxm-of-arp-op { - base ofoxm:match-field; - } - identity nxm-of-arp-spa { - base ofoxm:match-field; - } - identity nxm-of-arp-tpa { - base ofoxm:match-field; - } - identity nxm-nx-tun-ipv4-dst { - base ofoxm:match-field; - } - identity nxm-nx-tun-ipv4-src { - base ofoxm:match-field; - } - identity nxm-of-eth-src { - base ofoxm:match-field; - } - identity nxm-of-eth-dst { - base ofoxm:match-field; - } - identity nxm-of-eth-type { - base ofoxm:match-field; - } - - grouping ofj-nxm-nx-match-reg-grouping { - container reg-values { - leaf value { - type uint32; - } - } - } - grouping ofj-nxm-nx-match-tun-id-grouping { - container tun-id-values { - leaf value { - type uint64; - } - } - } - grouping ofj-nxm-nx-match-arp-sha-grouping { - container arp-sha-values { - leaf mac-address { - type yang:mac-address; - } - } - } - grouping ofj-nxm-nx-match-arp-tha-grouping { - container arp-tha-values { - leaf mac-address { - type yang:mac-address; - } - } - } - grouping ofj-nxm-of-match-arp-op-grouping { - container arp-op-values { - leaf value { - type uint16; - } - } - } - grouping ofj-nxm-of-match-arp-spa-grouping { - container arp-spa-values { - leaf value { - type uint32; - } - } - } - grouping ofj-nxm-of-match-arp-tpa-grouping { - container arp-tpa-values { - leaf value { - type uint32; - } - } - } - grouping ofj-nxm-nx-match-tun-ipv4-dst-grouping { - container tun-ipv4-dst-values { - leaf value { - type uint32; - } - } - } - grouping ofj-nxm-nx-match-tun-ipv4-src-grouping { - container tun-ipv4-src-values { - leaf value { - type uint32; - } - } - } - grouping ofj-nxm-of-match-eth-src-grouping { - container eth-src-values { - leaf mac-address { - type yang:mac-address; - } - } - } - grouping ofj-nxm-of-match-eth-dst-grouping { - container eth-dst-values { - leaf mac-address { - type yang:mac-address; - } - } - } - grouping ofj-nxm-of-match-eth-type-grouping { - container eth-type-values { - leaf value { - type uint16; - } - } - } - - augment "/ofoxm:oxm-container/ofoxm:match-entries" { - ext:augment-identifier "ofj-aug_nx_match"; - uses ofj-nxm-nx-match-reg-grouping; - uses ofj-nxm-nx-match-tun-id-grouping; - uses ofj-nxm-nx-match-arp-sha-grouping; - uses ofj-nxm-nx-match-arp-tha-grouping; - uses ofj-nxm-of-match-arp-op-grouping; - uses ofj-nxm-of-match-arp-spa-grouping; - uses ofj-nxm-of-match-arp-tpa-grouping; - uses ofj-nxm-nx-match-tun-ipv4-dst-grouping; - uses ofj-nxm-nx-match-tun-ipv4-src-grouping; - uses ofj-nxm-of-match-eth-src-grouping; - uses ofj-nxm-of-match-eth-dst-grouping; - uses ofj-nxm-of-match-eth-type-grouping; - } - -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/pom.xml b/openflow-nx-resubmit-action/pom.xml deleted file mode 100644 index 1468d019..00000000 --- a/openflow-nx-resubmit-action/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - 4.0.0 - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.5-SNAPSHOT - - org.opendaylight.openflowjava - openflow-nx-resubmit-action - 0.5-SNAPSHOT - bundle - Openflow Protocol Library - Nx Resubmit Action - http://maven.apache.org - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - - - - org.opendaylight.yangtools - yang-maven-plugin - - - - generate-sources - - - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - - ${jmxGeneratorPath} - - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - - ${salGeneratorPath} - - - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl - ${project.build.directory}/site/models - - - true - - - - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${config.version} - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.generator.version} - jar - - - - - - - - - - ${project.groupId} - openflow-protocol-api - ${project.version} - - - ${project.groupId} - openflow-protocol-spi - ${project.version} - - - org.opendaylight.yangtools.model - yang-ext - - - io.netty - netty-buffer - - - junit - junit - test - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - org.opendaylight.controller - config-api - ${config.version} - - - diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java deleted file mode 100644 index a9a04a53..00000000 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/NxResubmitActionRegistrator.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.nx; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.nx.deserialization.NxActionResubmitDeserializer; -import org.opendaylight.openflowjava.protocol.nx.serialization.NxActionResubmitSerializer; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxResubmitAction; - -/** - * @author michal.polkorab - * - */ -public class NxResubmitActionRegistrator implements AutoCloseable { - - /** Nicira experimenter ID */ - public static final Long NICIRA_EXPERIMENTER_ID = 0x00002320L; - private List providers; - - /** - * @param providers providers that shall be filled with serializers - */ - public void registerNxResubmitSerializer(List providers) { - if (providers != null) { - this.providers = providers; - for (SwitchConnectionProvider provider : providers) { - provider.registerActionSerializer(new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class), - new NxActionResubmitSerializer()); - } - } - } - - /** - * @param providers providers that shall be filled with deserializers - */ - public void registerNxResubmitDeserializer(List providers) { - if (providers != null) { - this.providers = providers; - for (SwitchConnectionProvider provider : providers) { - /* In case of handling multiple actions, instructions and other structures which - * are differentiated by vendor / experimenter subtype, vendor has to - * switch / choose between these subtypes. - * - * This has to be done in this way because of experimenter headers, which - * provide only vendor / experimenter ID. Subtype position may be different - * for different vendors (or not present at all) - that's why vendor has to - * handle it in his own implementations. - */ - provider.registerActionDeserializer(new ExperimenterActionDeserializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID), - new NxActionResubmitDeserializer()); - } - } - } - - @Override - public void close() throws Exception { - for (SwitchConnectionProvider provider : providers) { - // unregister serializer - provider.unregisterSerializer(new ExperimenterActionSerializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID, NxResubmitAction.class)); - // unregister deserializer - provider.unregisterDeserializer(new ExperimenterActionDeserializerKey( - EncodeConstants.OF13_VERSION_ID, NICIRA_EXPERIMENTER_ID)); - } - } -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java deleted file mode 100644 index f5d50f50..00000000 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializer.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.nx.deserialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugmentBuilder; - -/** - * @author michal.polkorab - * - */ -public class NxActionResubmitDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Action deserializeHeader(ByteBuf input) { - ActionBuilder builder = processHeader(input); - return builder.build(); - } - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = processHeader(input); - NxActionResubmitAugmentBuilder nxBuilder = new NxActionResubmitAugmentBuilder(); - nxBuilder.setSubtype(input.readUnsignedShort()); - nxBuilder.setInPort(input.readUnsignedShort()); - nxBuilder.setTable(input.readUnsignedByte()); - input.skipBytes(3); - builder.addAugmentation(NxActionResubmitAugment.class, nxBuilder.build()); - return builder.build(); - } - - private static ActionBuilder processHeader(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Experimenter.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - // ExperimenterIdAction augmentation is used for vendor / experimenter differentiation - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(input.readUnsignedInt())); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - return builder; - } -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java deleted file mode 100644 index a6a38c8a..00000000 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.nx.serialization; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class NxActionResubmitSerializer implements OFSerializer, - HeaderSerializer { - private static final Logger LOGGER = LoggerFactory - .getLogger(NxActionResubmitSerializer.class); - private static final byte NX_ACTION_RESUBMIT_LENGTH = 16; - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - LOGGER.error("SERIALIZING NX ACTION"); - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - outBuffer.writeShort(NX_ACTION_RESUBMIT_LENGTH); - NxActionResubmitAugment expAction = action.getAugmentation(NxActionResubmitAugment.class); - outBuffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); - outBuffer.writeShort(expAction.getSubtype()); - outBuffer.writeShort(expAction.getInPort()); - outBuffer.writeByte(expAction.getTable()); - outBuffer.writeZero(3); - } - - @Override - public void serializeHeader(Action action, ByteBuf outBuffer) { - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - outBuffer.writeShort(EncodeConstants.EXPERIMENTER_IDS_LENGTH); - outBuffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); - } -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java deleted file mode 100644 index b2c8cd69..00000000 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModule.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709; - -import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; - -public class NxResubmitActionRegistratorModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.AbstractNxResubmitActionRegistratorModule { - public NxResubmitActionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public NxResubmitActionRegistratorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.NxResubmitActionRegistratorModule oldModule, java.lang.AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - NxResubmitActionRegistrator registrator = new NxResubmitActionRegistrator(); - registrator.registerNxResubmitSerializer(getOpenflowSwitchConnectionProviderDependency()); - registrator.registerNxResubmitDeserializer(getOpenflowSwitchConnectionProviderDependency()); - return registrator; - } - -} diff --git a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java b/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java deleted file mode 100644 index 38852232..00000000 --- a/openflow-nx-resubmit-action/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/nx/resubmit/action/rev140709/NxResubmitActionRegistratorModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: openflow-nx-resubmit-action yang module local name: openflow-nx-resubmit-action -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Wed Jul 09 18:42:22 CEST 2014 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709; -public class NxResubmitActionRegistratorModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.nx.resubmit.action.rev140709.AbstractNxResubmitActionRegistratorModuleFactory { - -} diff --git a/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml b/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml deleted file mode 100644 index df43aa09..00000000 --- a/openflow-nx-resubmit-action/src/main/resources/43-openflow-nx-resubmit-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - urn:opendaylight:params:xml:ns:yang:openflow:nx:resubmit:action?module=openflow-nx-resubmit-action&revision=2014-07-09 - - - - - - - - prefix:openflow-nx-resubmit-action - openflow-nx-resubmit-action-bundle - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-legacy - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-default - - - - - - - diff --git a/openflow-nx-resubmit-action/src/main/resources/log4j.xml b/openflow-nx-resubmit-action/src/main/resources/log4j.xml deleted file mode 100644 index 5077ef8f..00000000 --- a/openflow-nx-resubmit-action/src/main/resources/log4j.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang b/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang deleted file mode 100644 index 418611b5..00000000 --- a/openflow-nx-resubmit-action/src/main/yang/nx-resubmit-action.yang +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - - module nx-resubmit-action { - namespace "urn:opendaylight:openflow:nx:resubmit:action"; - prefix "nx-resubmit"; - - import openflow-types {prefix oft;} - import openflow-action {prefix ofaction;} - import yang-ext {prefix ext;} - - revision "2013-07-31" { - description "OpenFlow 1.3 - action model"; - } - - identity nx-resubmit-action { - base ofaction:experimenter-action-sub-type; - } - - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nx-action-resubmit-augment"; - leaf subtype { - type uint16; - } - leaf in-port { - type uint16; - } - leaf table { - type uint8; - } - } - -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang b/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang deleted file mode 100644 index 45caf93a..00000000 --- a/openflow-nx-resubmit-action/src/main/yang/openflow-nx-resubmit-action.yang +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -module openflow-nx-resubmit-action { - yang-version 1; - namespace "urn:opendaylight:params:xml:ns:yang:openflow:nx:resubmit:action"; - prefix "openflow-nx-resubmit-action"; - - import config {prefix config; revision-date 2013-04-05;} - import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;} - - - description - "openflow library default exemplary package"; - - revision "2014-07-09" { - description - "Initial revision"; - } - - identity openflow-nx-resubmit-action { - base config:module-type; - config:java-name-prefix NxResubmitActionRegistrator; - } - - augment "/config:modules/config:module/config:configuration" { - case openflow-nx-resubmit-action { - when "/config:modules/config:module/config:type = 'openflow-nx-resubmit-action'"; - - list openflow-switch-connection-provider { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; - } - } - } - } - } -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java deleted file mode 100644 index 5fca9ce2..00000000 --- a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/deserialization/NxActionResubmitDeserializerTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.nx.deserialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; - -/** - * @author michal.polkorab - * - */ -public class NxActionResubmitDeserializerTest { - - /** - * Test deserialization of NX_ACTION_RESUBMIT action - */ - @Test - public void test() { - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeShort(EncodeConstants.EXPERIMENTER_VALUE); - buffer.writeShort(16); - buffer.writeInt(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue()); - buffer.writeShort(1); - buffer.writeShort(42); - buffer.writeByte(5); - buffer.writeZero(3); - - NxActionResubmitDeserializer deserializer = new NxActionResubmitDeserializer(); - Action action = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Experimenter", action.getType().getName()); - ExperimenterIdAction expAction = action.getAugmentation(ExperimenterIdAction.class); - Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), - expAction.getExperimenter().getValue().intValue()); - NxActionResubmitAugment nxResubmit = action.getAugmentation(NxActionResubmitAugment.class); - Assert.assertEquals("Wrong subtype", 1, nxResubmit.getSubtype().intValue()); - Assert.assertEquals("Wrong in-port", 42, nxResubmit.getInPort().intValue()); - Assert.assertEquals("Wrong table", 5, nxResubmit.getTable().intValue()); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } -} \ No newline at end of file diff --git a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java b/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java deleted file mode 100644 index 59a01389..00000000 --- a/openflow-nx-resubmit-action/src/test/java/org/opendaylight/openflowjava/protocol/nx/serialization/NxActionResubmitSerializerTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.nx.serialization; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.nx.NxResubmitActionRegistrator; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugment; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.nx.resubmit.action.rev130731.NxActionResubmitAugmentBuilder; - -/** - * @author michal.polkorab - * - */ -public class NxActionResubmitSerializerTest { - - /** - * Test serialization of NX_ACTION_RESUBMIT action - */ - @Test - public void test() { - ActionBuilder builder = new ActionBuilder(); - builder.setType(Experimenter.class); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID)); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - NxActionResubmitAugmentBuilder nxBuilder = new NxActionResubmitAugmentBuilder(); - nxBuilder.setSubtype(1); - nxBuilder.setInPort(42); - nxBuilder.setTable((short) 5); - builder.addAugmentation(NxActionResubmitAugment.class, nxBuilder.build()); - Action action = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - NxActionResubmitSerializer serializer = new NxActionResubmitSerializer(); - serializer.serialize(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 16, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), - buffer.readUnsignedInt()); - Assert.assertEquals("Wrong subtype", 1, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong in-port", 42, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong table", 5, buffer.readUnsignedByte()); - buffer.skipBytes(3); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } - - /** - * Test serialization of NX_ACTION_RESUBMIT action - */ - @Test - public void testHeaderSerialization() { - ActionBuilder builder = new ActionBuilder(); - builder.setType(Experimenter.class); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID)); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - Action action = builder.build(); - - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); - NxActionResubmitSerializer serializer = new NxActionResubmitSerializer(); - serializer.serializeHeader(action, buffer); - - Assert.assertEquals("Wrong action type", 65535, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong length", 8, buffer.readUnsignedShort()); - Assert.assertEquals("Wrong vendor id", NxResubmitActionRegistrator.NICIRA_EXPERIMENTER_ID.intValue(), - buffer.readUnsignedInt()); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 235333c1..bdd2872f 100644 --- a/pom.xml +++ b/pom.xml @@ -13,8 +13,6 @@ openflow-protocol-it features simple-client - openflow-nx-resubmit-action - openflow-extension-nicira scm:git:ssh://git.opendaylight.org:29418/openflowjava.git From 4651d58c1d0e2f5d51b0f224f6af507b18e557b6 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 6 Oct 2014 17:14:52 +0200 Subject: [PATCH 056/285] Incrementing versions by 0.1.0 for post-helium master branch Change-Id: If5011d280b4053c5db9ed3b3d7df671e4f5a6a11 Signed-off-by: Michal Polkorab --- features/pom.xml | 6 +++--- openflow-protocol-api/pom.xml | 4 ++-- openflow-protocol-impl/pom.xml | 8 ++++---- openflow-protocol-it/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- pom.xml | 18 +++++++++--------- simple-client/pom.xml | 2 +- util/pom.xml | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 1ec17d83..095f12b9 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT ../ features-openflowjava @@ -13,8 +13,8 @@ features.xml - 1.4.2-SNAPSHOT - 0.6.2-SNAPSHOT + 1.5.0-SNAPSHOT + 0.7.0-SNAPSHOT diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index d7cdea82..5d5bfb1e 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT openflow-protocol-api bundle @@ -14,7 +14,7 @@ - 0.6.2-SNAPSHOT + 0.7.0-SNAPSHOT diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index ca5eb1e9..38c414b6 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT openflow-protocol-impl bundle @@ -14,9 +14,9 @@ - 0.6.2-SNAPSHOT - 0.6.2-SNAPSHOT - 0.6.2-SNAPSHOT + 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 194f12d3..91b2a845 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT openflow-protocol-it bundle diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 21b2fbda..f6ea1ffd 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT openflow-protocol-spi bundle diff --git a/pom.xml b/pom.xml index bdd2872f..d2d90009 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT pom openflow-protocol-api @@ -34,22 +34,22 @@ 1.5.0 1.26.2 ${project.build.directory}/yang-gen-config - 1.4.2-SNAPSHOT + 1.5.0-SNAPSHOT ${project.build.directory}/yang-gen-sal ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 1.0.9 1.7.2 - 1.1-SNAPSHOT - 2010.09.24.4-SNAPSHOT - 2013.09.07.4-SNAPSHOT + 1.2.0-SNAPSHOT + 2010.09.24.7-SNAPSHOT + 2013.09.07.7-SNAPSHOT 2.4.0 14.0.1 4.0.23.Final 2.3.2 - 0.6.2-SNAPSHOT - 0.6.2-SNAPSHOT - 0.2.5-SNAPSHOT + 0.7.0-SNAPSHOT + 0.7.0-SNAPSHOT + 0.3.0-SNAPSHOT 2.4 @@ -206,7 +206,7 @@ org.opendaylight.controller config-api - 0.2.5-SNAPSHOT + 0.3.0-SNAPSHOT junit diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 1e649d73..e73c7624 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT simple-client bundle diff --git a/util/pom.xml b/util/pom.xml index 98c4038f..e029f3c5 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.5-SNAPSHOT + 0.6.0-SNAPSHOT bundle util From 4b0d144b54f1acea8b9ff1b7b0296828c836d362 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 16 Sep 2014 14:28:54 +0200 Subject: [PATCH 057/285] Bug 2177 - Updated SwitchConnectionProviderImpl - added test packaging - to be able to use ConnectionConfigurationImpl in both spi and impl SwitchConnectionProviderImpl: - skipped checks for null and already running serverFacade as those are no longer needed when using ConfigSubsystem (startup()) - added check for unknown transport protocol received (createAndConfigureServer()) ExperimenterMessageFactory: - fixed EXPERIMENTER_ID_INDEX constant MessageFactoryInitializer: - added Experimenter message deserializers registration Change-Id: I382d7fed0b626050847dafd47e691b7c9c902285 Signed-off-by: Michal Polkorab --- openflow-protocol-impl/pom.xml | 12 ++++++++++++ .../connection/SwitchConnectionProviderImpl.java | 16 +++++----------- .../factories/ExperimenterMessageFactory.java | 3 ++- .../serialization/MessageFactoryInitializer.java | 6 +++++- .../connection}/ConnectionConfigurationImpl.java | 2 +- openflow-protocol-it/pom.xml | 7 +++++++ .../protocol/it/integration/IntegrationTest.java | 1 + 7 files changed, 33 insertions(+), 14 deletions(-) rename {openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration => openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection}/ConnectionConfigurationImpl.java (97%) diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 38c414b6..0fd8d42e 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -84,6 +84,18 @@ + + org.apache.maven.plugins + maven-jar-plugin + 2.5 + + + + test-jar + + + + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index c2072ba5..75f698c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -105,19 +105,11 @@ public ListenableFuture shutdown() { @Override public ListenableFuture startup() { LOGGER.debug("Startup summoned"); - serverFacade = createAndConfigureServer(); - - LOGGER.debug("Starting .."); ListenableFuture result = null; try { - if (serverFacade == null) { - throw new IllegalStateException("No server configured"); - } - if (serverFacade.getIsOnlineFuture().isDone()) { - throw new IllegalStateException("Server already running"); - } + serverFacade = createAndConfigureServer(); if (switchConnectionHandler == null) { - throw new IllegalStateException("switchConnectionHandler is not set"); + throw new IllegalStateException("SwitchConnectionHandler is not set"); } new Thread(serverFacade).start(); result = serverFacade.getIsOnlineFuture(); @@ -145,9 +137,11 @@ private ServerFacade createAndConfigureServer() { if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); ((TcpHandler) server).setChannelInitializer(factory.createPublishingChannelInitializer()); - } else { + } else if (transportProtocol.equals(TransportProtocol.UDP)){ server = new UdpHandler(connConfig.getAddress(), connConfig.getPort()); ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer()); + } else { + throw new IllegalStateException("Unknown transport protocol received: " + transportProtocol); } server.setThreadConfig(connConfig.getThreadConfiguration()); return server; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java index effe6923..97db922a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -24,7 +24,8 @@ public class ExperimenterMessageFactory implements OFDeserializer, DeserializerRegistryInjector { - private static final byte EXPERIMENTER_ID_INDEX = 8; + /** Experimenter ID index after version, message type and length were read */ + private static final byte EXPERIMENTER_ID_INDEX = 4; private DeserializerRegistry deserializerRegistry; @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 452a8c16..094b4fde 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -8,9 +8,11 @@ package org.opendaylight.openflowjava.protocol.impl.serialization; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory; @@ -34,10 +36,10 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; @@ -71,6 +73,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); @@ -86,6 +89,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory()); registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory()); registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java similarity index 97% rename from openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java index 47c1889b..21aa55ab 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.it.integration; +package org.opendaylight.openflowjava.protocol.impl.connection; import java.net.InetAddress; diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 91b2a845..9aaa1c7e 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -20,6 +20,13 @@ ${project.version} test + + ${project.groupId} + openflow-protocol-impl + test-jar + ${project.version} + test + ${project.groupId} simple-client diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 8a94cd05..89d5677a 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -28,6 +28,7 @@ import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent; import org.opendaylight.openflowjava.protocol.impl.clients.UdpSimpleClient; import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; +import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionConfigurationImpl; import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; From 42517b13c7b53f7b4cb27f7fce43c8addcbb794d Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 16 Sep 2014 14:28:54 +0200 Subject: [PATCH 058/285] Added unit tests Change-Id: I1b6b771d5748d348e8420d33ee05676dbac4fed3 Signed-off-by: Michal Polkorab --- .../MessageListenerWrapperTest.java | 34 ++++ .../SwitchConnectionProviderImplTest.java | 180 ++++++++++++++++++ .../core/OFDatagramPacketEncoderTest.java | 88 +++++++++ .../ExperimenterMessageFactoryTest.java | 59 ++++++ .../ExperimenterInputMessageFactoryTest.java | 129 +++++++++++++ 5 files changed, 490 insertions(+) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java new file mode 100644 index 00000000..e34a48a9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class MessageListenerWrapperTest { + + /** + * Test MessageListenerWrapper creation + */ + @Test + public void test() { + HelloInputBuilder builder = new HelloInputBuilder(); + HelloInput hello = builder.build(); + SimpleRpcListener listener = new SimpleRpcListener(hello, "Error"); + MessageListenerWrapper wrapper = new MessageListenerWrapper(hello, listener); + Assert.assertEquals("Wrong message", hello, wrapper.getMsg()); + Assert.assertEquals("Wrong listener", listener, wrapper.getListener()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java new file mode 100644 index 00000000..5c33b8d2 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @author michal.polkorab + * + */ +public class SwitchConnectionProviderImplTest { + + @Mock SwitchConnectionHandler handler; + + private static final int SWITCH_IDLE_TIMEOUT = 2000; + private static final int WAIT_TIMEOUT = 2000; + private InetAddress startupAddress; + private TlsConfiguration tlsConfiguration; + private SwitchConnectionProviderImpl provider; + private ConnectionConfigurationImpl config; + + /** + * Creates new {@link SwitchConnectionProvider} instance for each test + * @param protocol communication protocol + */ + public void startUp(TransportProtocol protocol) { + MockitoAnnotations.initMocks(this); + config = null; + if (protocol != null) { + createConfig(protocol); + } + provider = new SwitchConnectionProviderImpl(); + } + + private void createConfig(TransportProtocol protocol) { + try { + startupAddress = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + tlsConfiguration = null; + if (protocol.equals(TransportProtocol.TLS)) { + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; + } + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config.setTransferProtocol(protocol); + } + + /** + * Tests provider startup - without configuration and {@link SwitchConnectionHandler} + */ + @Test + public void testStartup1() { + provider = new SwitchConnectionProviderImpl(); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without configuration + */ + @Test + public void testStartup2() { + startUp(null); + provider.setSwitchConnectionHandler(handler); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without {@link SwitchConnectionHandler} + */ + @Test + public void testStartup3() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.IllegalStateException:" + + " SwitchConnectionHandler is not set", e.getMessage()); + } + } + + /** + * Tests correct provider startup - over TCP + */ + @Test + public void testStartup4() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over TLS + */ + @Test + public void testStartup5() { + startUp(TransportProtocol.TLS); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over UDP + */ + @Test + public void testStartup6() { + startUp(TransportProtocol.UDP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider shutdown + */ + @Test + public void testShutdown() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + Assert.assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java new file mode 100644 index 00000000..ac063686 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketEncoderTest { + + @Mock ChannelHandlerContext ctx; + @Mock GenericFutureListener> listener; + @Mock SerializationFactory factory; + + private UdpMessageListenerWrapper wrapper; + private InetSocketAddress address = new InetSocketAddress("10.0.0.1", 6653); + private List out; + + /** + * Initializes mocks and other objects + * @param version openflow protocol wire version + */ + public void startUp(Short version) { + MockitoAnnotations.initMocks(this); + out = new ArrayList<>(); + HelloInputBuilder builder = new HelloInputBuilder(); + builder.setVersion(version); + HelloInput hello = builder.build(); + wrapper = new UdpMessageListenerWrapper(hello, listener, address); + } + + /** + * Tests encoding + */ + @Test + public void testCorrectEncode() { + startUp((short) EncodeConstants.OF13_VERSION_ID); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + Assert.fail(); + } + } + + /** + * Tests encoding + */ + @Test + public void testIncorrectEncode() { + startUp(null); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + verify(wrapper, times(1)).getListener(); + Assert.assertEquals("List should be empty", 0, out.size()); + } + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java new file mode 100644 index 00000000..ac167642 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock OFDeserializer deserializer; + @Mock ExperimenterMessage message; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test deserializer lookup correctness + */ + @Test + public void test() { + when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); + when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); + + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); + ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); + factory.injectDeserializerRegistry(registry); + ExperimenterMessage deserializedMessage = factory.deserialize(buffer); + Assert.assertEquals("Wrong return value", message, deserializedMessage); + Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java new file mode 100644 index 00000000..17b3f7ad --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock OFSerializer serializer; + private OFSerializer expFactory; + + /** + * Sets up ExperimenterInputMessageFactory + * @param real true if setup should use real registry, false when mock is desired + */ + public void startUp(boolean real) { + MockitoAnnotations.initMocks(this); + expFactory = new ExperimenterInputMessageFactory(); + if (real) { + SerializerRegistry realRegistry = new SerializerRegistryImpl(); + realRegistry.init(); + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry); + } else { + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry); + } + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV10Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV13Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV10() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV13() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } +} \ No newline at end of file From 056a2ad499879ced18909c24b3a22581715a961a Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 13 Oct 2014 15:42:57 +0200 Subject: [PATCH 059/285] Added key unit tests Change-Id: Icc1c59f32eb5004860273512bbf1588d388ff4e3 Signed-off-by: Marian Adamjak --- .../EnhancedMessageCodeKeyTest.java | 14 ++++++++ .../EnhancedMessageTypeKeyTest.java | 25 ++++++++++++++ .../api/extensibility/MessageCodeKeyTest.java | 24 +++++++++++++ .../api/extensibility/MessageTypeKeyTest.java | 20 +++++++++++ .../api/keys/ActionDeserializerKeyTest.java | 17 ++++++++++ .../api/keys/ActionSerializerKeyTest.java | 16 +++++++++ .../keys/InstructionDeserializerKeyTest.java | 17 ++++++++++ .../keys/InstructionSerializerKeyTest.java | 22 ++++++++++++ .../keys/MatchEntryDeserializerKeyTest.java | 26 ++++++++++++++ .../api/keys/MatchEntrySerializerKeyTest.java | 34 +++++++++++++++++++ .../ExperimenterActionSerializerKeyTest.java | 20 +++++++++++ .../ExperimenterIdDeserializerKeyTest.java | 19 +++++++++++ .../ExperimenterIdSerializerKeyTest.java | 18 ++++++++++ 13 files changed, 272 insertions(+) diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index 9d64b21a..a99b8901 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -47,4 +47,18 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index 1d150844..ec48d7ea 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -49,4 +49,29 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + EnhancedMessageTypeKey key1; + EnhancedMessageTypeKey key2; + + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); + + } + + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java index 0a991f62..7b3f36a0 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -44,4 +44,28 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + + MessageCodeKey key1; + MessageCodeKey key2; + + key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); + + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 05db7457..73dee304 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -41,4 +41,24 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + MessageTypeKey key1; + MessageTypeKey key2; + + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 3acddc0f..3ffe358f 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -40,4 +40,21 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test ActionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index 5dbd02cb..e145e8a2 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -47,4 +47,20 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } + + /** + * Test ActionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java index abf859ad..ccd33111 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -40,4 +40,21 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test InstructionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index 295ba4e3..f6b65a90 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -47,4 +47,26 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } + + /** + * Test InstructionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertFalse("Wrong equal by instructionType.", key1.equals(key2)); + + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index 1a5613ff..0f8e254e 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -46,4 +46,30 @@ public void test() { Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test MatchEntryDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + + Long expId1=123456L; + Long expId2=654321L; + + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 0a6793aa..fa88fd7b 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -54,4 +54,38 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } + + /** + * Test MatchEntrySerializerKey equals - additional test + */ + @Test + public void testEquals(){ + + MatchEntrySerializerKey key1; + MatchEntrySerializerKey key2; + + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1 = 987654331L; + Long expId2 = 123456789L; + + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); + + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index 59141fc4..657a34c3 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -47,6 +47,26 @@ public void test() { Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + @Test + public void testEquals() { + + ExperimenterActionSerializerKey key1; + ExperimenterActionSerializerKey key2; + + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + + } + + private static class TestSubType extends ExperimenterActionSubType { // empty class - only used in test for comparation } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index ec061904..8526f54a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -47,4 +47,23 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test ExperimenterIdDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index 768af3cc..27f243b0 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -47,4 +47,22 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + + /** + * Test ExperimenterIdSerializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + } + } \ No newline at end of file From 112fcc41ad8c408faa26cbccf3b75aaf82496bf8 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 26 Aug 2014 10:55:25 +0200 Subject: [PATCH 060/285] Improved unit test coverage (covered some untested branches) - Fixed a typo in EncodeConstants javadoc - added access to Cache in ConnectionAdapterImpl (only for testing purposes) - removed check from SerializationFactory#messageToBuffer as it is done in SerializerRegistryImpl Change-Id: I2e752a883a296f6e097084243aca0b109dd62c27 Signed-off-by: Michal Polkorab --- .../protocol/api/util/EncodeConstants.java | 2 +- .../connection/ConnectionAdapterImpl.java | 13 +- .../serialization/SerializationFactory.java | 4 +- .../connection/ConnectionAdapterImplTest.java | 177 ++++++++++++++++++ .../connection/SimpleRpcListenerTest.java | 50 +++++ .../match/OxmIpv6ExtHdrDeserializerTest.java | 49 +++++ .../match/OxmIpv6FlabelDeserializerTest.java | 44 +++++ .../match/OxmMetadataDeserializerTest.java | 45 +++++ .../match/OxmMplsBosDeserializerTest.java | 43 +++++ .../match/OxmPbbIsidDeserializerTest.java | 43 +++++ .../match/OxmVlanVidDeserializerTest.java | 46 +++++ .../impl/util/ActionsDeserializerTest.java | 21 +++ .../impl/util/MatchDeserializerTest.java | 24 ++- .../impl/util/OF13ActionsSerializerTest.java | 43 ++++- .../impl/util/OF13MatchSerializerTest.java | 11 +- 15 files changed, 603 insertions(+), 12 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index b3f6dff5..bbd881e2 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -18,7 +18,7 @@ public abstract class EncodeConstants { public static final byte PADDING = 8; /** OpenFlow v1.0 wire protocol number */ public static final byte OF10_VERSION_ID = 0x01; - /** OpenFlow v1.0 wire protocol number */ + /** OpenFlow v1.3 wire protocol number */ public static final byte OF13_VERSION_ID = 0x04; /** Index of length in Openflow header */ public static final int OFHEADER_LENGTH_INDEX = 2; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 9fe040fc..19baa930 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -108,7 +108,7 @@ public void onRemoval( }; /** expiring cache for future rpcResponses */ - private final Cache> responseCache; + private Cache> responseCache; private final ChannelOutboundQueue output; private final Channel channel; @@ -465,7 +465,6 @@ public void run() { }).start(); } - @Override public void setConnectionReadyListener( final ConnectionReadyListener connectionReadyListener) { @@ -476,4 +475,12 @@ public void setConnectionReadyListener( public InetSocketAddress getRemoteAddress() { return (InetSocketAddress) channel.remoteAddress(); } -} + + /** + * Used only for testing purposes + * @param cache + */ + public void setResponseCache(Cache> cache) { + this.responseCache = cache; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java index 34f4fb19..e318c683 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java @@ -32,9 +32,7 @@ public class SerializationFactory { public void messageToBuffer(short version, ByteBuf out, DataObject message) { OFSerializer serializer = registry.getSerializer( new MessageTypeKey<>(version, message.getImplementedInterface())); - if (serializer != null) { - serializer.serialize(message, out); - } + serializer.serialize(message, out); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java new file mode 100644 index 00000000..0435b3b9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; +import org.opendaylight.yangtools.yang.binding.DataObject; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author michal.polkorab + * + */ +public class ConnectionAdapterImplTest { + + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock SocketChannel channel; + @Mock ChannelPipeline pipeline; + @Mock OpenflowProtocolListener messageListener; + @Mock SystemNotificationsListener systemListener; + @Mock ConnectionReadyListener readyListener; + @Mock Cache> mockCache; + + private ConnectionAdapterImpl adapter; + private Cache> cache; + + /** + * Initializes ConnectionAdapter + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(channel.pipeline()).thenReturn(pipeline); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter.setMessageListener(messageListener); + adapter.setSystemListener(systemListener); + adapter.setConnectionReadyListener(readyListener); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications + */ + @Test + public void testConsume() { + DataObject message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + message = new ErrorMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message); + message = new ExperimenterMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message); + message = new FlowRemovedMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message); + message = new HelloMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onHelloMessage((HelloMessage) message); + message = new MultipartReplyMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message); + message = new PacketInMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message); + message = new PortStatusMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message); + message = new SwitchIdleEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message); + message = new DisconnectEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message); + message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc + */ + @Test + public void testConsume2() { + adapter.setResponseCache(mockCache); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrier = barrierBuilder.build(); + adapter.consume(barrier); + verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc + */ + @Test + public void testConsume3() { + BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); + inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + inputBuilder.setXid(42L); + BarrierInput barrierInput = inputBuilder.build(); + RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); + ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, + "failure", mockCache, key); + cache.put(key, listener); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrierOutput = barrierBuilder.build(); + adapter.consume(barrierOutput); + ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); + Assert.assertNull("Listener was not discarded", ifPresent); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java index db9d689e..3f49196e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java @@ -9,12 +9,19 @@ package org.opendaylight.openflowjava.protocol.impl.connection; import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.util.concurrent.Future; import java.util.Collections; import java.util.concurrent.ExecutionException; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -27,6 +34,16 @@ */ public class SimpleRpcListenerTest { + @Mock Future future; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + /** * Test SimpleRpcListener creation */ @@ -54,4 +71,37 @@ public void testSuccessfulRpc() { fail("Problem accessing result"); } } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete() { + when(future.isSuccess()).thenReturn(false); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(1)).cause(); + try { + Assert.assertEquals("Wrong result", 1, listener.getResult().get().getErrors().size()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete2() { + when(future.isSuccess()).thenReturn(true); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(0)).cause(); + try { + Assert.assertEquals("Wrong result", 0, listener.getResult().get().getErrors().size()); + Assert.assertEquals("Wrong result", true, listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java new file mode 100644 index 00000000..49b11872 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrDeserializerTest { + + /** + * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); + + buffer.skipBytes(4); // skip XID + OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", + new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), + entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java new file mode 100644 index 00000000..9b0d1a4d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelDeserializerTest { + + /** + * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 38 04 00 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java new file mode 100644 index 00000000..0cf62839 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataDeserializerTest { + + /** + * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 04 08 00 00 00 00 00 00 00 03"); + + buffer.skipBytes(4); // skip XID + OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java new file mode 100644 index 00000000..e8a379c7 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosDeserializerTest { + + /** + * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 48 01 00"); + + buffer.skipBytes(4); // skip XID + OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java new file mode 100644 index 00000000..b33c8a26 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidDeserializerTest { + + /** + * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4A 03 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java new file mode 100644 index 00000000..a51cc122 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidDeserializerTest { + + /** + * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A"); + + buffer.skipBytes(4); // skip XID + OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 10, + entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + Assert.assertEquals("Wrong entry value", false, + entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index 06fbe466..e0dfb8f7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; @@ -142,4 +143,24 @@ public void test() { Assert.assertTrue("Unread data in message", message.readableBytes() == 0); } + /** + * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)} + */ + @Test + public void testDeserializeHeader() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04"); + + message.skipBytes(4); // skip XID + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); + Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); + Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); + } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index b0db8353..c9021b28 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -15,6 +15,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -194,7 +195,7 @@ public void testMatch() { + "80 00 48 01 01 " + "80 00 4B 06 00 00 02 00 00 01 " + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " - + "80 00 4F 04 01 66 03 04 " + + "80 00 4F 04 00 00 03 04 " + "00 00 00 00"); Match match = matchDeserializer.deserialize(buffer); @@ -474,11 +475,28 @@ public void testMatch() { Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); Assert.assertEquals("Wrong entry value", - new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true), + new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), entry39.getAugmentation(MaskMatchEntry.class).getMask()); Assert.assertTrue("Unread data", buffer.readableBytes() == 0); } -} + /** + * Testing header deserialization + */ + @Test + public void testHeaders() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + HeaderDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index bcc335c3..f801dee3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -243,4 +243,45 @@ public void test() { Assert.assertTrue("Unread data", out.readableBytes() == 0); } -} + /** + * Testing correct serialization of actions + */ + @Test + public void testHeaders() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(52); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetField.class); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + matchBuilder.setOxmClass(OpenflowBasicClass.class); + matchBuilder.setOxmMatchField(InPort.class); + matchBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); + portBuilder.setPortNumber(new PortNumber(1L)); + matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + entries.add(matchBuilder.build()); + matchEntries.setMatchEntries(entries); + actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 17bc3267..453662e5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -106,7 +106,7 @@ public void testIpv4Src() { /** * Test for correct serialization of Ipv6Address match entry */ - @Test + @Test(expected=IllegalStateException.class) public void testIpv6Various() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); @@ -165,6 +165,15 @@ public void testIpv6Various() { addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8:9")); entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); entries.add(entriesBuilder.build()); + // ipv6 match entry with too abbreviated Ipv6 address + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(Ipv6NdTarget.class); + entriesBuilder.setHasMask(false); + addressBuilder = new Ipv6AddressMatchEntryBuilder(); + addressBuilder.setIpv6Address(new Ipv6Address("1:2::::8")); + entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + entries.add(entriesBuilder.build()); builder.setMatchEntries(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); From 3c8a9aff10032d0b647f42ca0b4a136f9975c88d Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Tue, 14 Oct 2014 16:03:58 +0200 Subject: [PATCH 061/285] Added test Change-Id: I2d70d80894a7b7c3f87cf778588a3ce4cf89c119 Signed-off-by: Marian Adamjak --- .../ConnectionAdapterFactoryImplTest.java | 37 +++++++++++ .../connection/ConnectionAdapterImplTest.java | 41 ++++++++++-- .../impl/connection/RpcResponseKeyTest.java | 58 +++++++++++++++++ .../UdpMessageListenerWrapperTest.java | 50 +++++++++++++++ .../core/VersionMessageUdpWrapperTest.java | 45 ++++++++++++++ .../MessageTypeCodeKeyTest.java | 55 ++++++++++++++++ .../SerializerRegistryImplTest.java | 62 +++++++++++++++++++ 7 files changed, 344 insertions(+), 4 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java new file mode 100644 index 00000000..ae6d0ac9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java @@ -0,0 +1,37 @@ +package org.opendaylight.openflowjava.protocol.impl.connection; + +import static org.mockito.Mockito.when; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelPipeline; + +import java.net.InetSocketAddress; + +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class ConnectionAdapterFactoryImplTest { + + @Mock ChannelPipeline channnelPipe; + @Mock Channel channel; + @Mock ChannelFuture channelFuture; + @Mock InetSocketAddress address; + + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + when(channel.pipeline()).thenReturn(channnelPipe); + when(channel.disconnect()).thenReturn(channelFuture); + } + + @Test + public void test(){ + ConnectionAdapterFactoryImpl caf = new ConnectionAdapterFactoryImpl(); + ConnectionFacade conn = caf.createConnectionFacade(channel, address); + + // otestovat isAlive + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java index 0435b3b9..65cbd6a8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java @@ -12,6 +12,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; @@ -61,6 +62,7 @@ /** * @author michal.polkorab + * @author madamjak * */ public class ConnectionAdapterImplTest { @@ -81,7 +83,7 @@ public void onRemoval( @Mock SystemNotificationsListener systemListener; @Mock ConnectionReadyListener readyListener; @Mock Cache> mockCache; - + @Mock ChannelFuture channelFuture; private ConnectionAdapterImpl adapter; private Cache> cache; @@ -98,7 +100,8 @@ public void setUp() { adapter.setConnectionReadyListener(readyListener); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); - adapter.setResponseCache(cache); + adapter.setResponseCache(cache); + when(channel.disconnect()).thenReturn(channelFuture); } /** @@ -173,5 +176,35 @@ public void testConsume3() { adapter.consume(barrierOutput); ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); Assert.assertNull("Listener was not discarded", ifPresent); - } -} \ No newline at end of file + } + /** + * Test IsAlive method + */ + @Test + public void testIsAlive(){ + int port = 9876; + String host ="localhost"; + InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel,inetSockAddr); + Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionAdapterImpl.isAlive()", channel.isOpen(), connAddapter.isAlive()); + + connAddapter.disconnect(); + Assert.assertFalse("Wrong - ConnectionAdapterImpl can not be aliva after disconnet.", connAddapter.isAlive()); + } + + /** + * Test throw exception if no listener are present + */ + @Test(expected = java.lang.IllegalStateException.class) + public void testMissingListeners(){ + int port = 9876; + String host ="localhost"; + InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel,inetSockAddr); + connAddapter.setSystemListener(null); + connAddapter.setMessageListener(null); + connAddapter.setConnectionReadyListener(null); + connAddapter.checkListeners(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java new file mode 100644 index 00000000..6125db89 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import org.junit.Test; +import org.junit.Assert; + +/** + * + * @author madamjak + * + */ +public class RpcResponseKeyTest { + + /** + * Test equals (xid is not tested) + */ + @Test + public void testEquals(){ + + long xid1 = 12L; + long xid2 = 66L; + String outputClazz1 = "Clazz01"; + String outputClazz2 = "Clazz02"; + RpcResponseKey key1 = new RpcResponseKey(xid1, null); + RpcResponseKey key2 = new RpcResponseKey(xid2, outputClazz2); + + Assert.assertTrue("Wrong equal to same obejct.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different type.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by outputClazz.", key1.equals(key2)); + + key1 = new RpcResponseKey(xid1, outputClazz1); + Assert.assertFalse("Wrong equal by outputClazz.", key1.equals(key2)); + key2 = new RpcResponseKey(xid2, outputClazz1); + Assert.assertTrue("Wrong equal.", key1.equals(key2)); + } + + /** + * Test getters + */ + @Test + public void testGetters(){ + + long xid1 = 12L; + String outputClazz1 = "Clazz01"; + RpcResponseKey key1 = new RpcResponseKey(xid1, outputClazz1); + + Assert.assertTrue("Wrong getXid",key1.getXid() == xid1); + Assert.assertTrue("Wrong getOutputClazz",key1.getOutputClazz() == outputClazz1); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java new file mode 100644 index 00000000..ae8a1035 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +/** + * + * @author madamjak + * + */ +public class UdpMessageListenerWrapperTest { + + @Mock GenericFutureListener> listener; + @Mock OfHeader msg; + + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + } + /** + * Getters test + */ + @Test + public void test(){ + int port = 9876; + String host ="localhost"; + InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + UdpMessageListenerWrapper wrapper = new UdpMessageListenerWrapper(msg,listener,inetSockAddr); + + Assert.assertEquals("Wrong getAddress", inetSockAddr, wrapper.getAddress()); + Assert.assertEquals("Wrong getListener", listener, wrapper.getListener()); + Assert.assertEquals("Wrong getMsg", msg, wrapper.getMsg()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java new file mode 100644 index 00000000..8cdca399 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; +import java.net.InetSocketAddress; +import org.junit.Before; +import org.junit.Test; +import org.junit.Assert; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +/** + * + * @author madamjak + * + */ + +public class VersionMessageUdpWrapperTest { + + @Mock ByteBuf byteBuff; + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + } + + @Test + public void test(){ + short version = 35; + int port = 9876; + String host ="localhost"; + InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + VersionMessageUdpWrapper wrapper = new VersionMessageUdpWrapper(version,byteBuff,inetSockAddr); + + Assert.assertEquals("Wrong getAddress", inetSockAddr, wrapper.getAddress()); + Assert.assertEquals("Wrong getVersion", version, wrapper.getVersion()); + Assert.assertEquals("Wrong getVersion", byteBuff, wrapper.getMessageBuffer()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java new file mode 100644 index 00000000..d63a792f --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.junit.Test; + +import junit.framework.Assert; + +/** + * + * @author madamjak + * + */ +public class MessageTypeCodeKeyTest { + + @Test + public void testEquals(){ + short msgType1 = 12; + short msgVersion1 = 34; + short msgType2 = 21; + short msgVersion2 = 43; + + MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion1, msgType1); + + Assert.assertTrue("Wrong - equals to same obejct",key1.equals(key1)); + Assert.assertFalse("Wrong - equals to null",key1.equals(null)); + Assert.assertFalse("Wrong - equals to different class",key1.equals(new Object())); + + MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion2, msgType2); + Assert.assertFalse("Wrong - equals by msgType",key1.equals(key2)); + + key2 = new MessageTypeCodeKey(msgVersion2, msgType1); + Assert.assertFalse("Wrong - equals by msgVersion",key1.equals(key2)); + } + + @Test + public void testGetter(){ + + short msgType = 12; + short msgVersion = 34; + + MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion, msgType); + + Assert.assertEquals(msgType, key1.getMsgType()); + Assert.assertEquals(msgVersion, key1.getMsgVersion()); + + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java new file mode 100644 index 00000000..c5230018 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java @@ -0,0 +1,62 @@ + +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; + +/** + * + * @author madamjak + * + */ +public class SerializerRegistryImplTest { + + private static final short OF13 = EncodeConstants.OF13_VERSION_ID; + private static final short OF10 = EncodeConstants.OF10_VERSION_ID; + + /** + * Test - register serializer without arguments + */ + @Test(expected = IllegalArgumentException.class) + public void testRegisterSerializerNoArgs(){ + + SerializerRegistryImpl serReg = new SerializerRegistryImpl(); + serReg.registerSerializer(null, null); + } + + /** + * Test - unregister serializer without MessageTypeKye + */ + @Test(expected = IllegalArgumentException.class) + public void testUnRegisterSerializerNoMessageTypeKey(){ + SerializerRegistryImpl serReg = new SerializerRegistryImpl(); + serReg.init(); + serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer()); + serReg.unregisterSerializer(null); + } + + /** + * Test - unregister serializer + */ + @Test + public void testUnRegisterSerialize(){ + SerializerRegistryImpl serReg = new SerializerRegistryImpl(); + serReg.init(); + serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer()); + Assert.assertTrue("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF13, Match.class))); + + serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer()); + Assert.assertFalse("Wrong - unregister serializer",serReg.unregisterSerializer(new MessageTypeKey<>(OF10, Match.class))); + } +} From c5349a10e27b85756a2fea7898cc2296d43d37fd Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 15 Oct 2014 13:58:53 +0200 Subject: [PATCH 062/285] Add new tests, fix several mistakes, add and edit copyright comments Change-Id: Ied68bd5c0f1c713ee7a1d819756101ccf4026181 Signed-off-by: Marian Adamjak --- .../api/keys/MatchEntrySerializerKeyTest.java | 10 +--- .../ConnectionAdapterFactoryImplTest.java | 28 +++++---- .../DeserializerRegistryImplTest.java | 59 +++++++++++++++++++ .../deserialization/TypeToClassKeyTest.java | 36 +++++++++++ .../SerializerRegistryImplTest.java | 3 +- 5 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index fa88fd7b..5e79712d 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -60,15 +60,11 @@ public void test() { */ @Test public void testEquals(){ - MatchEntrySerializerKey key1; MatchEntrySerializerKey key2; - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); Long expId1 = 987654331L; @@ -76,16 +72,14 @@ public void testEquals(){ key1.setExperimenterId(null); key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1.setExperimenterId(expId1); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key1.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key1.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java index ae6d0ac9..010953b3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java @@ -1,8 +1,14 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.openflowjava.protocol.impl.connection; import static org.mockito.Mockito.when; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPipeline; import java.net.InetSocketAddress; @@ -12,26 +18,28 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; - +/** + * + * @author madamjak + * + */ public class ConnectionAdapterFactoryImplTest { @Mock ChannelPipeline channnelPipe; @Mock Channel channel; - @Mock ChannelFuture channelFuture; @Mock InetSocketAddress address; - + @Before public void startUp(){ MockitoAnnotations.initMocks(this); when(channel.pipeline()).thenReturn(channnelPipe); - when(channel.disconnect()).thenReturn(channelFuture); } - + @Test public void test(){ - ConnectionAdapterFactoryImpl caf = new ConnectionAdapterFactoryImpl(); - ConnectionFacade conn = caf.createConnectionFacade(channel, address); - - // otestovat isAlive + ConnectionAdapterFactoryImpl connAdapterFactory = new ConnectionAdapterFactoryImpl(); + ConnectionFacade connFacade = connAdapterFactory.createConnectionFacade(channel, address); + Assert.assertNotNull("Wrong - ConnectionFacade has not created.", connFacade); + Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionFacade.isAlive()", channel.isOpen(), connFacade.isAlive()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java new file mode 100644 index 00000000..655702b9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +/** + * + * @author madamjak + * + */ +public class DeserializerRegistryImplTest { + + private static final short OF13 = EncodeConstants.OF13_VERSION_ID; + private static final short OF10 = EncodeConstants.OF10_VERSION_ID; + public static final int EMPTY_VALUE = EncodeConstants.EMPTY_VALUE; + + /** + * Test - register deserializer without arguments + */ + @Test(expected = IllegalArgumentException.class) + public void testRegisterDeserializerNoArgs(){ + DeserializerRegistryImpl serReg = new DeserializerRegistryImpl(); + serReg.registerDeserializer(null, null); + } + + /** + * Test - unregister deserializer without MessageTypeKye + */ + @Test(expected = IllegalArgumentException.class) + public void testUnRegisterDeserializerNoMessageTypeKey(){ + DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl(); + derserReg.init(); + derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer()); + derserReg.unregisterDeserializer(null); + } + + /** + * Test - unregister deserializer + */ + @Test + public void testUnRegisterDeserializer(){ + DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl(); + derserReg.init(); + derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer()); + Assert.assertTrue("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class))); + derserReg.registerDeserializer(new MessageCodeKey(OF13, EMPTY_VALUE, Match.class), new MatchDeserializer()); + Assert.assertFalse("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF10,EMPTY_VALUE, Match.class))); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java new file mode 100644 index 00000000..6756ac3a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import junit.framework.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +/** + * + * @author madamjak + * + */ +public class TypeToClassKeyTest { + + /** + * Test equals + */ + @Test + public void test(){ + final short ver10 = EncodeConstants.OF10_VERSION_ID; + final short ver13 = EncodeConstants.OF13_VERSION_ID; + final int type1 = 1; + TypeToClassKey typeToClsKey10 = new TypeToClassKey(ver10,type1); + Assert.assertTrue("Wrong - equals to same object", typeToClsKey10.equals(typeToClsKey10)); + Assert.assertFalse("Wrong - equals to null", typeToClsKey10.equals(null)); + Assert.assertFalse("Wrong - equals to different class", typeToClsKey10.equals(new Object())); + TypeToClassKey typeToClsKey13 = new TypeToClassKey(ver13,type1); + Assert.assertFalse("Wrong - equals by different version", typeToClsKey13.equals(new Object())); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java index c5230018..c398e47d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. * @@ -50,7 +49,7 @@ public void testUnRegisterSerializerNoMessageTypeKey(){ * Test - unregister serializer */ @Test - public void testUnRegisterSerialize(){ + public void testUnRegisterSerializer(){ SerializerRegistryImpl serReg = new SerializerRegistryImpl(); serReg.init(); serReg.registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer()); From 7a606fd03c9ea9dc7500b88cddb8ce6e6c6e831c Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 15 Oct 2014 15:29:38 +0200 Subject: [PATCH 063/285] Improved unit test coverage for openflowjava/protocol/impl/util/* classes Change-Id: Ic1d68de6e59e61eb245acdce9499202b07647840 Signed-off-by: Michal Polkorab --- .../impl/util/CodeKeyMakerFactoryTest.java | 135 +++++++++++++ .../impl/util/ListDeserializerTest.java | 58 ++++++ .../impl/util/ListSerializerTest.java | 45 +++++ .../impl/util/MatchDeserializerTest.java | 14 ++ .../impl/util/OF13MatchSerializerTest.java | 51 ++++- .../impl/util/TypeKeyMakerFactoryTest.java | 181 ++++++++++++++++++ 6 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java new file mode 100644 index 00000000..06bbf1e4 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class CodeKeyMakerFactoryTest { + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 32768, 0), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); + comparationKey.setExperimenterId(1L); + Assert.assertEquals("Wrong key", comparationKey, codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java new file mode 100644 index 00000000..446533a9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import java.util.List; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListDeserializerTest { + + @Mock CodeKeyMaker keyMaker; + @Mock DeserializerRegistry registry; + + /** + * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } + + /** + * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test2() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java new file mode 100644 index 00000000..f314a3ae --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListSerializerTest { + + @Mock TypeKeyMaker keyMaker; + @Mock SerializerRegistry registry; + + /** + * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)} + * with null List + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer); + + Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index c9021b28..36d9a9ce 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -50,6 +50,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; @@ -499,4 +500,17 @@ public void testHeaders() { Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); } + + /** + * Testing standard match type + */ + @Test + public void testStandardMatch() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01"); + + Match match = matchDeserializer.deserialize(buffer); + + Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); + Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 453662e5..f9a0224f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -26,6 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; @@ -34,11 +36,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; @@ -335,7 +341,46 @@ private static Match buildIpv6FLabelMatch(long labelValue, boolean hasMask, byte Match match = builder.build(); return match; } - - -} + /** + * Test Standard match type + */ + @Test + public void testStandardMatchType() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(StandardMatchType.class); + Match match = builder.build(); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + + matchSerializer.serialize(match, out); + + Assert.assertEquals("Wrong match type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong padding", 0, out.readUnsignedInt()); + Assert.assertEquals("Unexpected data", 0, out.readableBytes()); + } + + /** + * Test serialize experimenter match entry - with no experimenter + * match entry serializer registered + */ + @Test(expected=IllegalStateException.class) + public void testSerializeExperimenterMatchEntry() { + List entries = new ArrayList<>(); + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(ExperimenterClass.class); + builder.setOxmMatchField(OxmMatchFieldClass.class); + builder.setHasMask(true); + ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); + entries.add(builder.build()); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + + ((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out); + } + + private class OxmMatchFieldClass extends MatchField { + // only for testing purposes + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java new file mode 100644 index 00000000..c58a119a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class TypeKeyMakerFactoryTest { + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Output.class); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Output.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Experimenter.class); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expIdBuilder.setSubType(ActionSubtypeClass.class); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, + ActionSubtypeClass.class), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(GotoTable.class); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + GotoTable.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow + .common.instruction.rev130731.Experimenter.class); + ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, + 42L), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(InPort.class); + builder.setHasMask(true); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPort.class); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(ExperimenterClass.class); + builder.setOxmMatchField(OxmMatchFieldClass.class); + builder.setHasMask(true); + ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + ExperimenterClass.class, OxmMatchFieldClass.class); + comparationKey.setExperimenterId(42L); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + private class ActionSubtypeClass extends ExperimenterActionSubType { + // only for testing purposes + } + + private class OxmMatchFieldClass extends MatchField { + // only for testing purposes + } +} \ No newline at end of file From 1c1442a7f91699dc9be315cfa984838d162a468e Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 16 Oct 2014 13:13:07 +0200 Subject: [PATCH 064/285] Increased unit test coverage for keys - removed check in DeserializationFactory as it is done in DeserializerRegistry - also updated DeserializerRegistryImplTest Change-Id: I4baa4fea035104827b34ec7e1b99e1ca4056dd44 Signed-off-by: Michal Polkorab --- .../EnhancedMessageCodeKeyTest.java | 14 ++++++- .../EnhancedMessageTypeKeyTest.java | 16 ++++++-- .../api/extensibility/MessageCodeKeyTest.java | 34 ++++++++------- .../api/extensibility/MessageTypeKeyTest.java | 24 ++++++++--- .../api/keys/ActionDeserializerKeyTest.java | 20 ++++++--- .../api/keys/ActionSerializerKeyTest.java | 21 ++++++++-- .../keys/InstructionDeserializerKeyTest.java | 20 ++++++--- .../keys/InstructionSerializerKeyTest.java | 27 ++++++++---- .../keys/MatchEntryDeserializerKeyTest.java | 20 ++++++--- .../api/keys/MatchEntrySerializerKeyTest.java | 22 ++++++++++ .../DeserializationFactory.java | 4 +- .../DeserializerRegistryImplTest.java | 41 +++++++++++++++---- .../MessageTypeCodeKeyTest.java | 41 +++++++++++-------- .../deserialization/TypeToClassKeyTest.java | 4 +- 14 files changed, 228 insertions(+), 80 deletions(-) diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index a99b8901..7b350d55 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -53,12 +53,22 @@ public void test() { */ @Test public void testEquals() { - EnhancedMessageCodeKey key1 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + } + + /** + * Test EnhancedMessageCodeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index ec48d7ea..e6be8a8d 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -57,12 +57,10 @@ public void test() { public void testEquals() { EnhancedMessageTypeKey key1; EnhancedMessageTypeKey key2; - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); @@ -70,8 +68,18 @@ public void testEquals() { key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); + } + /** + * Test EnhancedMessageTypeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, + Action.class, Output.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); } - - } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java index 7b3f36a0..4087a55b 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -44,28 +44,34 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** - * Test EnhancedMessageTypeKey equals - additional test + * Test MessageCodeKey equals - additional test */ @Test public void testEquals() { - - MessageCodeKey key1; - MessageCodeKey key2; - - key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - - + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to null.", key1.equals(null)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - + MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); - + + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2)); + } + + /** + * Test MessageCodeKey toString() + */ + @Test + public void testToString() { + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString()); } - } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 73dee304..4dbd5541 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -41,24 +41,36 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** - * Test EnhancedMessageTypeKey equals - additional test + * Test MessageTypeKey equals - additional test */ @Test public void testEquals() { MessageTypeKey key1; MessageTypeKey key2; - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to null.", key1.equals(null)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); + } + + /** + * Test MessageTypeKey toString() + */ + @Test + public void testToString() { + MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 3ffe358f..66a09fe9 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -46,15 +46,25 @@ public void test() { */ @Test public void testEquals(){ - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" + + " experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index e145e8a2..f9c5225d 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -49,18 +49,33 @@ public void test() { } /** - * Test ActionDeserializerKey equals - additional test + * Test ActionSerializerKey equals - additional test */ @Test public void testEquals(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test ActionSerializerKey toString() + */ + @Test + public void testToString(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java index ccd33111..2497413a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -46,15 +46,25 @@ public void test() { */ @Test public void testEquals(){ - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction msgType: 11" + + " experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index f6b65a90..8e7d1f5f 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -53,20 +53,33 @@ public void test() { */ @Test public void testEquals(){ - InstructionSerializerKey key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); InstructionSerializerKey key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertFalse("Wrong equal by instructionType.", key1.equals(key2)); - + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2)); + } + + /** + * Test InstructionSerializerKey toString() + */ + @Test + public void testToString(){ + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" + + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index 0f8e254e..be87d557 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -52,24 +52,32 @@ public void test() { */ @Test public void testEquals() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Long expId1=123456L; Long expId2=654321L; - key1.setExperimenterId(null); key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); + } + + /** + * Test MatchEntryDeserializerKey toString() + */ + @Test + public void testToString(){ + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" + + " experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 5e79712d..576c446f 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -53,6 +53,8 @@ public void test() { null, InPhyPort.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2.setExperimenterId(42L); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } /** @@ -78,8 +80,28 @@ public void testEquals(){ key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); key1.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2)); key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); key1.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2)); + } + + /** + * Test MatchEntrySerializerKey toString() + */ + @Test + public void testToString(){ + MatchEntrySerializerKey key1; + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index f459c97f..274b9740 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -49,9 +49,7 @@ public DataObject deserialize(ByteBuf rawMessage, short version) { rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); OFDeserializer deserializer = registry.getDeserializer( new MessageCodeKey(version, type, clazz)); - if (deserializer != null) { - dataObject = deserializer.deserialize(rawMessage); - } + dataObject = deserializer.deserialize(rawMessage); return dataObject; } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java index 655702b9..aec3df43 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; /** * * @author madamjak @@ -22,7 +23,7 @@ public class DeserializerRegistryImplTest { private static final short OF13 = EncodeConstants.OF13_VERSION_ID; private static final short OF10 = EncodeConstants.OF10_VERSION_ID; - public static final int EMPTY_VALUE = EncodeConstants.EMPTY_VALUE; + private static final int EMPTY_VALUE = EncodeConstants.EMPTY_VALUE; /** * Test - register deserializer without arguments @@ -34,26 +35,52 @@ public void testRegisterDeserializerNoArgs(){ } /** - * Test - unregister deserializer without MessageTypeKye + * Test - register deserializer with no key + */ + @Test(expected = IllegalArgumentException.class) + public void testRegisterDeserializerNoKey(){ + DeserializerRegistryImpl serReg = new DeserializerRegistryImpl(); + serReg.registerDeserializer(null, new MatchDeserializer()); + } + + /** + * Test - register deserializer with no deserializer + */ + @Test(expected = IllegalArgumentException.class) + public void testRegisterDeserializerNoDeserializer(){ + DeserializerRegistryImpl serReg = new DeserializerRegistryImpl(); + serReg.registerDeserializer(new MessageCodeKey(OF13, EMPTY_VALUE, Match.class), null); + } + + /** + * Test - unregister deserializer without MessageTypeKey */ @Test(expected = IllegalArgumentException.class) public void testUnRegisterDeserializerNoMessageTypeKey(){ DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl(); derserReg.init(); - derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer()); derserReg.unregisterDeserializer(null); } /** - * Test - unregister deserializer + * Test - unregister deserializer */ @Test public void testUnRegisterDeserializer(){ DeserializerRegistryImpl derserReg = new DeserializerRegistryImpl(); derserReg.init(); - derserReg.registerDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class), new MatchDeserializer()); Assert.assertTrue("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF13,EMPTY_VALUE, Match.class))); - derserReg.registerDeserializer(new MessageCodeKey(OF13, EMPTY_VALUE, Match.class), new MatchDeserializer()); Assert.assertFalse("Wrong - unregister serializer",derserReg.unregisterDeserializer(new MessageCodeKey(OF10,EMPTY_VALUE, Match.class))); } -} + + /** + * Test - get deserializer + */ + @Test(expected=IllegalStateException.class) + public void testGetDeserializer(){ + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + registry.getDeserializer(new MessageCodeKey((short) 5000, EncodeConstants.EMPTY_VALUE, MatchV10.class)); + Assert.fail(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java index d63a792f..337d3d36 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; +import org.junit.Assert; import org.junit.Test; -import junit.framework.Assert; /** * @@ -19,37 +19,44 @@ */ public class MessageTypeCodeKeyTest { + /** + * Tests equals and hashCode + */ @Test - public void testEquals(){ + public void testEqualsAndHashcode(){ short msgType1 = 12; short msgVersion1 = 34; short msgType2 = 21; short msgVersion2 = 43; - MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion1, msgType1); - - Assert.assertTrue("Wrong - equals to same obejct",key1.equals(key1)); - Assert.assertFalse("Wrong - equals to null",key1.equals(null)); - Assert.assertFalse("Wrong - equals to different class",key1.equals(new Object())); - - MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion2, msgType2); - Assert.assertFalse("Wrong - equals by msgType",key1.equals(key2)); - + + Assert.assertTrue("Wrong - equals to same object", key1.equals(key1)); + Assert.assertFalse("Wrong - equals to null", key1.equals(null)); + Assert.assertFalse("Wrong - equals to different class", key1.equals(new Object())); + + MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion1, msgType1); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + Assert.assertTrue("Wrong - equals to mirror object", key1.equals(key2)); + + key2 = new MessageTypeCodeKey(msgVersion2, msgType2); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + Assert.assertFalse("Wrong - equals by msgType", key1.equals(key2)); + key2 = new MessageTypeCodeKey(msgVersion2, msgType1); - Assert.assertFalse("Wrong - equals by msgVersion",key1.equals(key2)); + Assert.assertFalse("Wrong - equals by msgVersion", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + /** + * Tests getters + */ @Test public void testGetter(){ - short msgType = 12; short msgVersion = 34; - MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion, msgType); Assert.assertEquals(msgType, key1.getMsgType()); Assert.assertEquals(msgVersion, key1.getMsgVersion()); - } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java index 6756ac3a..bf9d060f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java @@ -26,11 +26,13 @@ public void test(){ final short ver10 = EncodeConstants.OF10_VERSION_ID; final short ver13 = EncodeConstants.OF13_VERSION_ID; final int type1 = 1; + final int type2 = 2; TypeToClassKey typeToClsKey10 = new TypeToClassKey(ver10,type1); Assert.assertTrue("Wrong - equals to same object", typeToClsKey10.equals(typeToClsKey10)); Assert.assertFalse("Wrong - equals to null", typeToClsKey10.equals(null)); Assert.assertFalse("Wrong - equals to different class", typeToClsKey10.equals(new Object())); - TypeToClassKey typeToClsKey13 = new TypeToClassKey(ver13,type1); + TypeToClassKey typeToClsKey13 = new TypeToClassKey(ver13,type2); Assert.assertFalse("Wrong - equals by different version", typeToClsKey13.equals(new Object())); + Assert.assertFalse("Wrong - equals by different type", typeToClsKey13.equals(typeToClsKey10)); } } From 3dda40723d3799a818bcad9b5eddc725ae63d946 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 16 Oct 2014 16:00:30 +0200 Subject: [PATCH 065/285] Added unit tests for Error and Vendor/Experimenter message factories - + covered AbstractInstructionDeserializer Change-Id: I80804f7e38b42d0b53200e8e06ed41f415152605 Signed-off-by: Michal Polkorab --- .../factories/ErrorMessageFactoryTest.java | 319 +++++++++++++++++- .../OF10ErrorMessageFactoryTest.java | 141 +++++++- .../factories/VendorMessageFactoryTest.java | 48 +++ .../AbstractInstructionDeserializerTest.java | 65 ++++ .../VendorInputMessageFactoryTest.java | 57 ++++ 5 files changed, 605 insertions(+), 25 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java index 5e114778..367062f5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java @@ -13,31 +13,34 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; /** * @author michal.polkorab * @author timotej.kubas */ +@RunWith(MockitoJUnitRunner.class) public class ErrorMessageFactoryTest { - private OFDeserializer errorFactory; + @Mock DeserializerRegistry registry; + @Mock ErrorMessageFactory deserializer; + + private ErrorMessageFactory errorFactory; /** * Initializes deserializer registry and lookups correct deserializer */ @Before public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - errorFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 1, ErrorMessage.class)); + errorFactory = new ErrorMessageFactory(); } /** @@ -45,17 +48,294 @@ public void startUp() { */ @Test public void testWithoutData() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02"); + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb); + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "INCOMPATIBLE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 01 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue()); - Assert.assertEquals("Wrong code", 2, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString()); - Assert.assertEquals("Wrong code string", "BADMULTIPART", builtByFactory.getCodeString()); + Assert.assertEquals("Wrong code string", "BADVERSION", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 02 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADTYPE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 03 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADINSTRUCTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWNINST", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 04 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADMATCH", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADTYPE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 05 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 06 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 6, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "GROUPMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "GROUPEXISTS", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 07 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 7, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 08 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "TABLEMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADTABLE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 09 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 9, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0A 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "SWITCHCONFIGFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADFLAGS", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0B 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "ROLEREQUESTFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "STALE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0C 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "METERMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0D 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "TABLEFEATURESFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADTABLE", builtByFactory.getCodeString()); Assert.assertNull("Data is not null", builtByFactory.getData()); } - + + /** + * Test of {@link ErrorMessageFactory} for correct translation into POJO + * - not existing code used + */ + @Test + public void testWithoutData2() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 FF FF"); + ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 01 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 02 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 03 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADINSTRUCTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 04 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADMATCH", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 05 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 06 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 6, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "GROUPMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 07 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 7, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 08 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "TABLEMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 09 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 9, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0A FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "SWITCHCONFIGFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0B FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "ROLEREQUESTFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0C FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "METERMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 0D FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "TABLEFEATURESFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + } + /** * Test of {@link ErrorMessageFactory} for correct translation into POJO */ @@ -103,4 +383,17 @@ public void testWithIncorrectCodeEnum() { Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData()); } -} + + /** + * Test of {@link ErrorMessageFactory} for correct translation into POJO + */ + @Test + public void testExperimenterError() { + Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); + errorFactory.injectDeserializerRegistry(registry); + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 00 00 01"); + BufferHelper.deserialize(errorFactory, bb); + + Mockito.verify(deserializer, Mockito.times(1)).deserialize(bb); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java index 98be668f..bf058b7b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java @@ -39,20 +39,137 @@ public void startUp() { } /** - * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO + * Test of {@link ErrorMessageFactory} for correct translation into POJO */ - @Test - public void testWithoutData() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 02"); - ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb); + @Test + public void testWithoutData() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); + ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb); - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue()); - Assert.assertEquals("Wrong code", 2, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString()); - Assert.assertEquals("Wrong code string", "BADSTAT", builtByFactory.getCodeString()); - Assert.assertNull("Data is not null", builtByFactory.getData()); - } + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "INCOMPATIBLE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 01 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADVERSION", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 02 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADTYPE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 03 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "ALLTABLESFULL", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 04 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 05 00 00"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + } + + /** + * Test of {@link ErrorMessageFactory} for correct translation into POJO + * - not existing code used + */ + @Test + public void testWithoutData2() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 FF FF"); + ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 01 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 02 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 03 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 04 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + + bb = BufferHelper.buildBuffer("00 05 FF FF"); + builtByFactory = BufferHelper.deserialize(errorFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + } /** * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java new file mode 100644 index 00000000..d293efcb --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock ExperimenterMessageFactory deserializer; + + /** + * Tests {@link VendorMessageFactory#deserialize(ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); + VendorMessageFactory factory = new VendorMessageFactory(); + factory.injectDeserializerRegistry(registry); + factory.deserialize(buffer); + + Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java new file mode 100644 index 00000000..dcfbe924 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class AbstractInstructionDeserializerTest { + + /** + * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different + * instruction types + */ + @Test(expected=IllegalStateException.class) + public void test() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); + GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); + instruction = deserializer.deserializeHeader(buffer); + // exception expected + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java new file mode 100644 index 00000000..df1c3455 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock ExperimenterInputMessageFactory serializer; + + /** + * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) + .thenReturn(serializer); + VendorInputMessageFactory factory = new VendorInputMessageFactory(); + factory.injectSerializerRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(12345L); + builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(84L); + ExperimenterInput experimenterInput = builder.build(); + + factory.serialize(experimenterInput, buffer); + Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); + } +} \ No newline at end of file From 2f8854e57828fd12d20f3f5177bd3c4bf3c37b8f Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 17 Oct 2014 12:01:02 +0200 Subject: [PATCH 066/285] Bug 2212 - Fixed MultipartReply - GroupFeatures action bitmap translation + added unit test for GroupFeatures type Change-Id: I3a4dbcdfe274a960dbf26231637324298220602d Signed-off-by: Michal Polkorab --- .../MultipartReplyMessageFactory.java | 32 +++--- .../MultipartReplyGroupFeaturesTest.java | 104 ++++++++++++++++++ 2 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 1379071d..43d78d49 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -783,22 +783,22 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa private static ActionType createActionBitmap(long input) { final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0; - final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<1)) != 0; - final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<2)) != 0; - final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<3)) != 0; - final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<4)) != 0; - final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<5)) != 0; - final Boolean OFPAT_POP_VLAN = ((input) & (1<<6)) != 0; - final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<7)) != 0; - final Boolean OFPAT_POP_MPLS = ((input) & (1<<8)) != 0; - final Boolean OFPAT_SET_QUEUE = ((input) & (1<<9)) != 0; - final Boolean OFPAT_GROUP = ((input) & (1<<10)) != 0; - final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<11)) != 0; - final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<12)) != 0; - final Boolean OFPAT_SET_FIELD = ((input) & (1<<13)) != 0; - final Boolean OFPAT_PUSH_PBB = ((input) & (1<<14)) != 0; - final Boolean OFPAT_POP_PBB = ((input) & (1<<15)) != 0; - final Boolean OFPAT_EXPERIMENTER = ((input) & (1<<16)) != 0; + final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<11)) != 0; + final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<12)) != 0; + final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<15)) != 0; + final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<16)) != 0; + final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<17)) != 0; + final Boolean OFPAT_POP_VLAN = ((input) & (1<<18)) != 0; + final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<19)) != 0; + final Boolean OFPAT_POP_MPLS = ((input) & (1<<20)) != 0; + final Boolean OFPAT_SET_QUEUE = ((input) & (1<<21)) != 0; + final Boolean OFPAT_GROUP = ((input) & (1<<22)) != 0; + final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<23)) != 0; + final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<24)) != 0; + final Boolean OFPAT_SET_FIELD = ((input) & (1<<25)) != 0; + final Boolean OFPAT_PUSH_PBB = ((input) & (1<<26)) != 0; + final Boolean OFPAT_POP_PBB = ((input) & (1<<27)) != 0; + final Boolean OFPAT_EXPERIMENTER = false; return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL, OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS, OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN, diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java new file mode 100644 index 00000000..906d87fd --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyGroupFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyGroupFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 0F "+// types + "00 00 00 0F "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "0F FF 98 01 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), + message.getCapabilities()); + Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue()); + Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue()); + Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue()); + Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue()); + Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, + true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + * (with different group types and capabilities) + */ + @Test + public void testMultipartReplyGroupFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 00 "+// types + "00 00 00 00 "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "00 00 00 00 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), + message.getCapabilities()); + } +} \ No newline at end of file From 1a13b24590d2ff8c57204b8d6c8a8f4597d3fed5 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 17 Oct 2014 17:18:20 +0200 Subject: [PATCH 067/285] Fixed MultipartReply - MeterFeatures capabilities bitmap translation - meter features test moved into separate file - updated name conversion in TableFeatures translation Change-Id: Iaa85dd176e02cb9d7bd99dd1bce347252de08180 Signed-off-by: Michal Polkorab --- .../MultipartReplyMessageFactory.java | 6 +- .../MultipartReplyMessageFactoryTest.java | 34 +------- .../MultipartReplyMeterFeaturesTest.java | 80 +++++++++++++++++++ 3 files changed, 84 insertions(+), 36 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 43d78d49..20d7eda2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -349,7 +349,7 @@ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { int length = input.readUnsignedShort(); featuresBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES); - featuresBuilder.setName(input.readBytes(MAX_TABLE_NAME_LENGTH).toString()); + featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataMatch); featuresBuilder.setMetadataMatch(metadataMatch); @@ -588,8 +588,8 @@ private static MeterFlags createMeterFlags(long input){ } private static MeterBandTypeBitmap createMeterBandsBitmap(long input) { - final Boolean _oFPMBTDROP = (input & (1 << 0)) != 0; - final Boolean _oFPMBTDSCPREMARK = (input & (1 << 1)) != 0; + final Boolean _oFPMBTDROP = (input & (1 << 1)) != 0; + final Boolean _oFPMBTDSCPREMARK = (input & (1 << 2)) != 0; return new MeterBandTypeBitmap(_oFPMBTDROP, _oFPMBTDSCPREMARK); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 1920e07d..fc27d1e5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -48,7 +48,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; @@ -68,7 +67,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; @@ -81,7 +79,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; @@ -488,36 +485,7 @@ public void testMultipartReplyGroupBody(){ new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount()); } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyMeterFeaturesBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ - "00 00 00 09 "+//maxMeter - "00 00 00 01 "+//bandTypes - "00 00 00 03 "+//capabilities - "03 "+//maxBands - "04 "+//maxColor - "00 00"//pad - ); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); - Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); - Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, false), message.getBandTypes()); - Assert.assertEquals("Wrong capabilities", new MeterFlags(false, true, true, false), - message.getCapabilities()); - Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); - Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); - } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java new file mode 100644 index 00000000..208bea19 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyMeterFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 0A " + // maxMeter + "00 00 00 06 " + // bandTypes + "00 00 00 0F " + // capabilities + "07 08 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures2(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 09 " + // maxMeter + "00 00 00 00 " + // bandTypes + "00 00 00 00 " + // capabilities + "03 04 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); + } +} \ No newline at end of file From 947b220207ef75e679d72595b9d120fd8a1c8192 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 17 Oct 2014 12:50:17 +0200 Subject: [PATCH 068/285] Added unit tests for MultipartReply message factory Change-Id: I5de66ba1a4ae97e527342b7d8de31512d2be5d5a Signed-off-by: Michal Polkorab --- .../MultipartReplyMessageFactoryTest.java | 152 +------------- .../MultipartReplyExperimenterTest.java | 63 ++++++ .../multipart/MultipartReplyFlowTest.java | 136 +++++++++++++ .../multipart/MultipartReplyPortDescTest.java | 122 ++++++++++++ .../MultipartReplyTableFeaturesTest.java | 187 ++++++++++++++++++ 5 files changed, 509 insertions(+), 151 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index fc27d1e5..11322641 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -21,7 +21,6 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; @@ -47,14 +46,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; @@ -62,24 +56,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; @@ -160,74 +149,7 @@ public void testMultipartReplyDescBody(){ Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum()); Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc()); } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ - "00 48 "+//length - "08 "+//tableId - "00 "+//pad_01 - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C "+//priority - "00 0E "+//idleTimeout - "00 0F "+//hardTimeout - "00 0B "+//flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00 "+ - "00 48 "+//length - "08 "+//tableId - "00 "+//pad_01 - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C "+//priority - "00 0E "+//idleTimeout - "00 0F "+//hardTimeout - "00 0B "+//flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - FlowStats flowStats1 = message.getFlowStats().get(0); - Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); - Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), - flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - flowStats1.getByteCount()); - Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); - } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -778,78 +700,6 @@ public void testMultipartReplyMeterConfigBodyMulti(){ } - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyPortDescBody(){ - final byte MAX_PORT_NAME_LEN = 16; - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 01 00 00 00 00 "+ - "00 01 02 03 "+ //portNo - "00 00 00 00 "+ //padding01 - "08 00 27 00 B0 EB " + //mac address - "00 00"); //padding02 - //port name - String portName = "SampleText"; - byte[] portNameBytes = new byte[MAX_PORT_NAME_LEN]; - portNameBytes = portName.getBytes(); - bb.writeBytes(portNameBytes); - bb.writeZero(MAX_PORT_NAME_LEN - portNameBytes.length); - - ByteBuf bb2 = BufferHelper.buildBuffer("00 00 00 41 " + //port config - "00 00 00 05 " + //port state - "00 00 00 81 " + //current features - "00 00 81 81 " + //advertised features - "00 00 C1 89 " + //supported features - "00 00 C5 8D " + //peer features - "00 00 00 81 " + //curr speed - "00 00 00 80" //max speed - ); - bb.writeBytes(bb2.copy(4, bb2.readableBytes()-4));//excluding version and xid - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong portNo", 66051L, message.getPorts().get(0).getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), - message.getPorts().get(0).getHwAddr()); - Assert.assertEquals("Wrong portName", "SampleText", - message.getPorts().get(0).getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), - message.getPorts().get(0).getConfig()); - Assert.assertEquals("Wrong portState", new PortState(false, true, true), - message.getPorts().get(0).getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, - false, true, false, false, - false, true, false, false, - false, false, false, false), - message.getPorts().get(0).getCurrentFeatures()); - Assert.assertEquals("Wrong advertisedFeatures", - new PortFeatures(true, false, false, false, - false, true, false, false, - false, true, false, false, - false, false, false, true), - message.getPorts().get(0).getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", - new PortFeatures(true, true, false, false, - false, true, false, false, - false, true, false, false, - false, false, true, true), - message.getPorts().get(0).getSupportedFeatures()); - Assert.assertEquals("Wrong peerFeatures", - new PortFeatures(true, true, true, false, - false, true, false, false, - false, true, false, false, - false, true, true, true), - message.getPorts().get(0).getPeerFeatures()); - Assert.assertEquals("Wrong currSpeed", 129L, message.getPorts().get(0).getCurrSpeed().longValue()); - Assert.assertEquals("Wrong maxSpeed", 128L, message.getPorts().get(0).getMaxSpeed().longValue()); - } - /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Output, Copy TTL Out, Copy TTL In diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java new file mode 100644 index 00000000..61110453 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyExperimenter() { + factory.injectDeserializerRegistry(registry); + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+ + "00 00 00 0F "+// types + "00 00 00 0F "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "0F FF 98 01 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java new file mode 100644 index 00000000..ecb206e4 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyFlowTest { + + private OFDeserializer factory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ + // first flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00 "+ + // second flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size()); + FlowStats flowStats1 = message.getFlowStats().get(0); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + flowStats1 = message.getFlowStats().get(1); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java new file mode 100644 index 00000000..139ea08a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyPortDescTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + + // first port desc + "00 01 02 03 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 65 " + //port config + "00 00 00 07 " + //port state + "00 00 00 81 " + //current features + "00 00 FF FF " + //advertised features + "00 00 C1 89 " + //supported features + "00 00 C5 8D " + //peer features + "00 00 00 81 " + //curr speed + "00 00 00 80 " + //max speed + // second port desc + "00 00 00 01 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 00 " + //port config + "00 00 00 00 " + //port state + "00 00 00 00 " + //current features + "00 00 00 00 " + //advertised features + "00 00 00 00 " + //supported features + "00 00 00 00 " + //peer features + "00 00 00 05 " + //curr speed + "00 00 00 06" //max speed + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); + Ports port = message.getPorts().get(0); + Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, + false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, + false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, + false, false, true, false, false, false, true, true, true), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); + port = message.getPorts().get(1); + Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java new file mode 100644 index 00000000..64ad0970 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyTableFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + // first table feature + "00 40 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + // second table feature + "00 40 02 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 03 "+// metadata match + "00 00 00 00 00 00 00 04 "+// metadata write + "00 00 00 03 "+// config + "00 00 00 2B" // max entries + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + feature = message.getTableFeatures().get(1); + Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + "00 B0 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + "00 00 00 04 00 00 00 00 "+ + "00 01 00 04 00 00 00 00 "+ + "00 02 00 08 01 02 03 04 "+ + "00 03 00 07 05 06 07 00 "+ + "00 04 00 04 00 00 00 00 "+ + "00 05 00 04 00 00 00 00 "+ + "00 06 00 04 00 00 00 00 "+ + "00 07 00 04 00 00 00 00 "+ + "00 08 00 04 00 00 00 00 "+ + "00 0A 00 04 00 00 00 00 "+ + "00 0C 00 04 00 00 00 00 "+ + "00 0D 00 04 00 00 00 00 "+ + "00 0E 00 04 00 00 00 00 "+ + "00 0F 00 04 00 00 00 00" + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, + feature.getTableFeatureProperties().get(0).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, + feature.getTableFeatureProperties().get(1).getType()); + TableFeatureProperties property = feature.getTableFeatureProperties().get(2); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, + property.getType()); + List tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 4, tableIds.size()); + Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue()); + property = feature.getTableFeatureProperties().get(3); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, + property.getType()); + tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 3, tableIds.size()); + Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, + feature.getTableFeatureProperties().get(4).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, + feature.getTableFeatureProperties().get(5).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, + feature.getTableFeatureProperties().get(6).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, + feature.getTableFeatureProperties().get(7).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, + feature.getTableFeatureProperties().get(8).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, + feature.getTableFeatureProperties().get(9).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, + feature.getTableFeatureProperties().get(10).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, + feature.getTableFeatureProperties().get(11).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, + feature.getTableFeatureProperties().get(12).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, + feature.getTableFeatureProperties().get(13).getType()); + } +} \ No newline at end of file From c5fcb334ac4a35a819d659efaba0d68f11867b22 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 16 Oct 2014 15:10:21 +0200 Subject: [PATCH 069/285] Add unit tests for EchoInputMessageFactory, EchoReplyInputMessageFactory Change-Id: I519e6cf4cb5657be3f506716c999da611079a1d6 Signed-off-by: Marian Adamjak Signed-off-by: Michal Polkorab --- .../EchoInputMessageFactoryTest.java | 24 +++++++++++++++---- .../EchoReplyInputMessageFactoryTest.java | 24 +++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java index 25bc0ff7..ebe8351b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; +import org.junit.Assert; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; @@ -52,10 +53,8 @@ public void testV13() throws Exception { EchoInputBuilder eib = new EchoInputBuilder(); BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID); EchoInput ei = eib.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(ei, out); - BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8); } @@ -68,11 +67,28 @@ public void testV10() throws Exception { EchoInputBuilder eib = new EchoInputBuilder(); BufferHelper.setupHeader(eib, EncodeConstants.OF10_VERSION_ID); EchoInput ei = eib.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(ei, out); - BufferHelper.checkHeaderV10(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8); } + /** + * Testing of {@link EchoInputMessageFactory} for correct data serialization + * @throws Exception + */ + @Test + public void testData() throws Exception{ + byte[] dataToTest = new byte[]{91,92,93,94,95,96,97,98}; + EchoInputBuilder eib = new EchoInputBuilder(); + BufferHelper.setupHeader(eib, EncodeConstants.OF13_VERSION_ID); + eib.setData(dataToTest); + EchoInput ei = eib.build(); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + echoFactory.serialize(ei, out); + BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8+dataToTest.length); + byte[] outData = new byte[dataToTest.length]; + out.readBytes(outData); + Assert.assertArrayEquals(dataToTest, outData); + out.release(); + } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java index 40aa9a0d..970bace0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; +import org.junit.Assert; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; @@ -52,10 +53,8 @@ public void testV13() throws Exception { EchoReplyInputBuilder erib = new EchoReplyInputBuilder(); BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID); EchoReplyInput eri = erib.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(eri, out); - BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8); } @@ -68,11 +67,28 @@ public void testV10() throws Exception { EchoReplyInputBuilder erib = new EchoReplyInputBuilder(); BufferHelper.setupHeader(erib, EncodeConstants.OF10_VERSION_ID); EchoReplyInput eri = erib.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); echoFactory.serialize(eri, out); - BufferHelper.checkHeaderV10(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8); } + /** + * Testing of {@link EchoReplyInputMessageFactory} for correct message serialization + * @throws Exception + */ + @Test + public void testDataSerialize()throws Exception { + byte[] dataToTest = new byte[]{91,92,93,94,95,96,97,98}; + EchoReplyInputBuilder erib = new EchoReplyInputBuilder(); + BufferHelper.setupHeader(erib, EncodeConstants.OF13_VERSION_ID); + erib.setData(dataToTest); + EchoReplyInput eri = erib.build(); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + echoFactory.serialize(eri, out); + BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8+dataToTest.length); + byte[] outData = new byte[dataToTest.length]; + out.readBytes(outData); + Assert.assertArrayEquals("Wrong - different output data.",dataToTest, outData); + out.release(); + } } From 548217b93ab731a30a2fc883c11c87b43f044b3b Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 16 Oct 2014 15:21:52 +0200 Subject: [PATCH 070/285] Add unit tests for ExperimenterIdSerializerKey, ExperimenterIdDeserializerKey Change-Id: Iaf2ad17a1b6ceee6ed1ec040cb12943f0964f582 Signed-off-by: Marian Adamjak --- .../ExperimenterIdDeserializerKeyTest.java | 12 +++++------- .../ExperimenterIdSerializerKeyTest.java | 7 +++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index 8526f54a..dc3e956b 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; @@ -47,23 +48,20 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test ExperimenterIdDeserializerKey equals - additional test */ @Test public void testEquals() { - ExperimenterIdDeserializerKey key1 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); ExperimenterIdDeserializerKey key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } - + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index 27f243b0..97fd73e1 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; @@ -55,14 +56,12 @@ public void test() { public void testEquals() { ExperimenterIdSerializerKey key1 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); ExperimenterIdSerializerKey key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } } \ No newline at end of file From e3261ca20db3ad074c2c548c1a29f3e004e79f22 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 17 Oct 2014 14:26:41 +0200 Subject: [PATCH 071/285] Add unit test - fully covered SwitchConnectionProviderImpl, ConnectionAdapterImpl Change-Id: I038649bd02d95ab8b37888f3a3c22daeaac99caa Signed-off-by: Marian Adamjak --- openflow-protocol-api/pom.xml | 4 + .../ExperimenterIdSerializerKey.java | 3 +- .../ExperimenterActionSerializerKeyTest.java | 14 +- .../ConnectionAdapterImp02lTest.java | 206 +++++++++++++++ .../connection/ConnectionAdapterImplTest.java | 8 +- .../SwitchConnectionProviderImpl02Test.java | 238 ++++++++++++++++++ .../SwitchConnectionProviderImplTest.java | 1 + .../impl/connection/UdpHandlerTest.java | 98 ++++++++ .../EchoInputMessageFactoryTest.java | 6 +- .../EchoReplyInputMessageFactoryTest.java | 3 +- 10 files changed, 562 insertions(+), 19 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 5d5bfb1e..6b580791 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -129,5 +129,9 @@ junit test + + org.mockito + mockito-all + diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java index 1e9325e9..47d3608a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -15,7 +15,8 @@ * @author michal.polkorab * @param class of object to be serialized */ -public class ExperimenterIdSerializerKey extends MessageTypeKey { +public class ExperimenterIdSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { private Long experimenterId; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index 657a34c3..761698d3 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -19,6 +19,7 @@ */ public class ExperimenterActionSerializerKeyTest { + /** * Test ExperimenterActionSerializerKey equals and hashCode */ @@ -49,24 +50,17 @@ public void test() { @Test public void testEquals() { - ExperimenterActionSerializerKey key1; ExperimenterActionSerializerKey key2; - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - } - - + + private static class TestSubType extends ExperimenterActionSubType { // empty class - only used in test for comparation } @@ -74,4 +68,6 @@ private static class TestSubType extends ExperimenterActionSubType { private static class TestSubType2 extends ExperimenterActionSubType { // empty class - only used in test for comparation } + + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java new file mode 100644 index 00000000..e9645cf8 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; +import junit.framework.Assert; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author madamjak + * @author michal.polkorab + */ +public class ConnectionAdapterImp02lTest { + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock EchoInput echoInput; + @Mock BarrierInput barrierInput; + @Mock EchoReplyInput echoReplyInput; + @Mock ExperimenterInput experimenterInput; + @Mock FlowModInput flowModInput; + @Mock GetConfigInput getConfigInput; + @Mock GetFeaturesInput getFeaturesInput; + @Mock GetQueueConfigInput getQueueConfigInput; + @Mock GroupModInput groupModInput; + @Mock HelloInput helloInput; + @Mock MeterModInput meterModInput; + @Mock PacketOutInput packetOutInput; + @Mock MultipartRequestInput multipartRequestInput; + @Mock PortModInput portModInput; + @Mock RoleRequestInput roleRequestInput; + @Mock SetConfigInput setConfigInput; + @Mock TableModInput tableModInput; + @Mock GetAsyncInput getAsyncInput; + @Mock SetAsyncInput setAsyncInput; + private ConnectionAdapterImpl adapter; + private Cache> cache; + private OfHeader responseOfCall; + /** + * Initialize mocks + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + /** + * Disconnect adapter + */ + @After + public void tierDown(){ + if (adapter != null && adapter.isAlive()) { + adapter.disconnect(); + } + } + /** + * Test Rpc Calls + */ + @Test + public void testRcp() { + EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + // -- barrier + adapter.barrier(barrierInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - barrier", barrierInput, responseOfCall); + // -- echo + adapter.echo(echoInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - echo", echoInput, responseOfCall); + // -- echoReply + adapter.echoReply(echoReplyInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - echoReply",echoReplyInput, responseOfCall); + // -- experimenter + adapter.experimenter(experimenterInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - experimenter",experimenterInput, responseOfCall); + // -- flowMod + adapter.flowMod(flowModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - flowMod", flowModInput, responseOfCall); + // -- getConfig + adapter.getConfig(getConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getConfig", getConfigInput, responseOfCall); + // -- getFeatures + adapter.getFeatures(getFeaturesInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getFeatures",getFeaturesInput, responseOfCall); + // -- getQueueConfig + adapter.getQueueConfig(getQueueConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getQueueConfig",getQueueConfigInput, responseOfCall); + // -- groupMod + adapter.groupMod(groupModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - groupMod", groupModInput, responseOfCall); + // -- hello + adapter.hello(helloInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - helloInput",helloInput, responseOfCall); + // -- meterMod + adapter.meterMod(meterModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - meterMod",meterModInput, responseOfCall); + // -- packetOut + adapter.packetOut(packetOutInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - packetOut",packetOutInput, responseOfCall); + // -- multipartRequest + adapter.multipartRequest(multipartRequestInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - multipartRequest", multipartRequestInput, responseOfCall); + // -- portMod + adapter.portMod(portModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - portMod", portModInput, responseOfCall); + // -- roleRequest + adapter.roleRequest(roleRequestInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - roleRequest", roleRequestInput, responseOfCall); + // -- setConfig + adapter.setConfig(setConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - setConfig",setConfigInput, responseOfCall); + // -- tableMod + adapter.tableMod(tableModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - tableMod", tableModInput, responseOfCall); + // -- getAsync + adapter.getAsync(getAsyncInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getAsync", getAsyncInput, responseOfCall); + // -- setAsync + adapter.setAsync(setAsyncInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - setAsync", setAsyncInput, responseOfCall); + adapter.disconnect(); + } + + /** + * Channel Handler for testing + * @author madamjak + * + */ + private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, + ChannelPromise promise) throws Exception { + responseOfCall = null; + if(msg instanceof MessageListenerWrapper){ + MessageListenerWrapper listener = (MessageListenerWrapper) msg; + OfHeader ofHeader = listener.getMsg(); + responseOfCall = ofHeader; + } + } + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java index 65cbd6a8..80d53dd4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java @@ -83,7 +83,8 @@ public void onRemoval( @Mock SystemNotificationsListener systemListener; @Mock ConnectionReadyListener readyListener; @Mock Cache> mockCache; - @Mock ChannelFuture channelFuture; + @Mock ChannelFuture channelFuture; + private ConnectionAdapterImpl adapter; private Cache> cache; @@ -189,11 +190,11 @@ public void testIsAlive(){ Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionAdapterImpl.isAlive()", channel.isOpen(), connAddapter.isAlive()); connAddapter.disconnect(); - Assert.assertFalse("Wrong - ConnectionAdapterImpl can not be aliva after disconnet.", connAddapter.isAlive()); + Assert.assertFalse("Wrong - ConnectionAdapterImpl can not be alive after disconnet.", connAddapter.isAlive()); } /** - * Test throw exception if no listener are present + * Test throw exception if no listeners are present */ @Test(expected = java.lang.IllegalStateException.class) public void testMissingListeners(){ @@ -206,5 +207,4 @@ public void testMissingListeners(){ connAddapter.setConnectionReadyListener(null); connAddapter.checkListeners(); } - } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java new file mode 100644 index 00000000..e0fecc27 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.connection; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @author madamjak + * @author michal.polkorab + */ +public class SwitchConnectionProviderImpl02Test { + @Mock SwitchConnectionHandler handler; + @Mock OFGeneralSerializer serializer; + @Mock OFGeneralDeserializer deserializer; + @Mock OFDeserializer deserializerError; + @Mock OFDeserializer deserializerExpMsg; + @Mock OFDeserializer deserializerMultipartRplMsg; + @Mock OFDeserializer deserializerQueueProperty; + @Mock OFDeserializer deserializerMeterBandExpCase; + @Mock OFSerializer serializerExperimenterInput; + @Mock OFSerializer serializerMultipartRequestExpCase; + @Mock OFSerializer serializerMeterBandExpCase; + private static final int SWITCH_IDLE_TIMEOUT = 2000; + private InetAddress startupAddress; + private TlsConfiguration tlsConfiguration; + private SwitchConnectionProviderImpl provider; + private ConnectionConfigurationImpl config; + + /** + * Creates new {@link SwitchConnectionProvider} instance for each test + * @param protocol communication protocol + */ + public void startUp(TransportProtocol protocol) { + MockitoAnnotations.initMocks(this); + config = null; + if (protocol != null) { + createConfig(protocol); + } + provider = new SwitchConnectionProviderImpl(); + } + + private void createConfig(TransportProtocol protocol) { + try { + startupAddress = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + tlsConfiguration = null; + if (protocol.equals(TransportProtocol.TLS)) { + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; + } + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config.setTransferProtocol(protocol); + } + + + /** + * Test getServerFacade + */ + @Test + public void testServerFacade(){ + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + ListenableFuture future = provider.startup(); + ServerFacade serverFacade = provider.getServerFacade(); + Assert.assertNotNull("Wrong -- getServerFacade return null",serverFacade); + } + + /** + * Test unregister by wrong key + */ + @Test + public void testUnregisterWrongKeys(){ + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + ExperimenterInstructionSerializerKey testSerKey + = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); + Assert.assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey)); + ExperimenterInstructionDeserializerKey tesDeserKey + = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,24L); + Assert.assertFalse("Wrong -- unregisterDeserializer",provider.unregisterDeserializer(tesDeserKey)); + } + + /** + * Test register and unregister method + */ + @Test + public void testUnregisterExistingKeys(){ + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + // -- registerActionSerializer + ExperimenterActionSerializerKey key1 + = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + provider.registerActionSerializer(key1, serializer); + Assert.assertTrue("Wrong -- unregister ActionSerializer", provider.unregisterSerializer(key1)); + Assert.assertFalse("Wrong -- unregister ActionSerializer by not existing key", provider.unregisterSerializer(key1)); + // -- registerActionDeserializer + ExperimenterActionDeserializerKey key2 + = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + provider.registerActionDeserializer(key2, deserializer); + Assert.assertTrue("Wrong -- unregister ActionDeserializer", provider.unregisterDeserializer(key2)); + Assert.assertFalse("Wrong -- unregister ActionDeserializer by not existing key", provider.unregisterDeserializer(key2)); + // -- registerInstructionSerializer + ExperimenterInstructionSerializerKey key3 + = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); + provider.registerInstructionSerializer(key3, serializer); + Assert.assertTrue("Wrong -- unregister InstructionSerializer", provider.unregisterSerializer(key3)); + Assert.assertFalse("Wrong -- unregister InstructionSerializer by not existing key", provider.unregisterSerializer(key3)); + // -- registerInstructionDeserializer + ExperimenterInstructionDeserializerKey key4 + = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,42L); + provider.registerInstructionDeserializer(key4, deserializer); + Assert.assertTrue("Wrong -- unregister InstructionDeserializer", provider.unregisterDeserializer(key4)); + Assert.assertFalse("Wrong -- unregister InstructionDeserializer by not existing key", provider.unregisterDeserializer(key4)); + // -- registerMatchEntryDeserializer + MatchEntryDeserializerKey key5 + = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + provider.registerMatchEntryDeserializer(key5, deserializer); + Assert.assertTrue("Wrong -- unregister MatchEntryDeserializer", provider.unregisterDeserializer(key5)); + Assert.assertFalse("Wrong -- unregister MatchEntryDeserializer by not existing key", provider.unregisterDeserializer(key5)); + // -- registerErrorDeserializer + ExperimenterIdDeserializerKey key6 + = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); + provider.registerErrorDeserializer(key6, deserializerError); + Assert.assertTrue("Wrong -- unregister ErrorDeserializer", provider.unregisterDeserializer(key6)); + Assert.assertFalse("Wrong -- unregister ErrorDeserializer by not existing key", provider.unregisterDeserializer(key6)); + // -- registerExperimenterMessageDeserializer + ExperimenterIdDeserializerKey key7 + = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + provider.registerExperimenterMessageDeserializer(key7, deserializerExpMsg); + Assert.assertTrue("Wrong -- unregister ExperimenterMessageDeserializer", provider.unregisterDeserializer(key7)); + Assert.assertFalse("Wrong -- unregister ExperimenterMessageDeserializer by not existing key", provider.unregisterDeserializer(key7)); + // -- registerMultipartReplyMessageDeserializer + ExperimenterIdDeserializerKey key8 + = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MultipartReplyMessage.class); + provider.registerMultipartReplyMessageDeserializer(key8, deserializerMultipartRplMsg); + Assert.assertTrue("Wrong -- unregister MultipartReplyMessageDeserializer", provider.unregisterDeserializer(key8)); + Assert.assertFalse("Wrong -- unregister MultipartReplyMessageDeserializer by not existing key", provider.unregisterDeserializer(key8)); + // -- registerMultipartReplyTFDeserializer + ExperimenterIdDeserializerKey key9 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MultipartReplyMessage.class); + provider.registerMultipartReplyTFDeserializer(key9, deserializer); + Assert.assertTrue("Wrong -- unregister MultipartReplyTFDeserializer", provider.unregisterDeserializer(key9)); + Assert.assertFalse("Wrong -- unregister MultipartReplyTFDeserializer by non existing key", provider.unregisterDeserializer(key9)); + // -- registerQueuePropertyDeserializer + ExperimenterIdDeserializerKey key10 + = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, QueueProperty.class); + provider.registerQueuePropertyDeserializer(key10, deserializerQueueProperty); + Assert.assertTrue("Wrong -- unregister QueuePropertyDeserializer", provider.unregisterDeserializer(key10)); + Assert.assertFalse("Wrong -- unregister QueuePropertyDeserializer by not existing key", provider.unregisterDeserializer(key10)); + // -- registerMeterBandDeserializer + ExperimenterIdDeserializerKey key11 + = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MeterBandExperimenterCase.class); + provider.registerMeterBandDeserializer(key11, deserializerMeterBandExpCase); + Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11)); + Assert.assertFalse("Wrong -- unregister MeterBandDeserializer by not existing key", provider.unregisterDeserializer(key11)); + // -- registerExperimenterMessageSerializer + ExperimenterIdSerializerKey key12 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,ExperimenterInput.class); + provider.registerExperimenterMessageSerializer(key12, serializerExperimenterInput); + Assert.assertTrue("Wrong -- unregister ExperimenterMessageSerializer", provider.unregisterSerializer(key12)); + Assert.assertFalse("Wrong -- unregister ExperimenterMessageSerializer by not existing key", provider.unregisterSerializer(key12)); + //registerMultipartRequestSerializer + ExperimenterIdSerializerKey key13 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MultipartRequestExperimenterCase.class); + provider.registerMultipartRequestSerializer(key13, serializerMultipartRequestExpCase); + Assert.assertTrue("Wrong -- unregister MultipartRequestSerializer", provider.unregisterSerializer(key13)); + Assert.assertFalse("Wrong -- unregister MultipartRequestSerializer by not existing key", provider.unregisterSerializer(key13)); + // -- registerMultipartRequestTFSerializer + ExperimenterIdSerializerKey key14 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,TableFeatureProperties.class); + provider.registerMultipartRequestTFSerializer(key14, serializer); + Assert.assertTrue("Wrong -- unregister MultipartRequestTFSerializer", provider.unregisterSerializer(key14)); + Assert.assertFalse("Wrong -- unregister MultipartRequestTFSerializer by not existing key", provider.unregisterSerializer(key14)); + // -- registerMeterBandSerializer + ExperimenterIdSerializerKey key15 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MeterBandExperimenterCase.class); + provider.registerMeterBandSerializer(key15, serializerMeterBandExpCase); + Assert.assertTrue("Wrong -- unregister MeterBandSerializer", provider.unregisterSerializer(key15)); + Assert.assertFalse("Wrong -- unregister MeterBandSerializer by not existing key", provider.unregisterSerializer(key15)); + // -- registerMatchEntrySerializer + MatchEntrySerializerKey key16 + = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + provider.registerMatchEntrySerializer(key16, serializer); + Assert.assertTrue("Wrong -- unregister MatchEntrySerializer", provider.unregisterSerializer(key16)); + Assert.assertFalse("Wrong -- unregister MatchEntrySerializer by not existing key", provider.unregisterSerializer(key15)); + } + + private static class TestSubType extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java index 5c33b8d2..7a70f757 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java @@ -177,4 +177,5 @@ public void testShutdown() { e.printStackTrace(); } } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java new file mode 100644 index 00000000..e6922c9a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.connection; + +import java.io.IOException; +import java.net.InetAddress; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.UdpChannelInitializer; +import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @author madamjak + * + */ +public class UdpHandlerTest { + @Mock UdpChannelInitializer udpChannelInitializerMock; + UdpHandler udpHandler; + /** + * Mock init + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test to create UdpHandler with empty address and zero port + * @throws InterruptedException + * @throws ExecutionException + * @throws IOException + */ + @Test + public void testWithEmptyAddress() throws InterruptedException, ExecutionException, IOException { + udpHandler = new UdpHandler(null, 0); + udpHandler.setChannelInitializer(udpChannelInitializerMock); + Assert.assertTrue("Wrong - start server", startupServer()); + try { + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + } catch (TimeoutException e) { + Assert.fail("Wrong - getIsOnlineFuture timed out"); + } + Assert.assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); + shutdownServer(); + } + + /** + * Test to create UdpHandler with fill address and given port + * @throws InterruptedException + * @throws ExecutionException + * @throws IOException + */ + @Test + public void testWithAddressAndPort() throws InterruptedException, ExecutionException, IOException{ + int port = 9874; + udpHandler = new UdpHandler(InetAddress.getLocalHost(), port); + udpHandler.setChannelInitializer(udpChannelInitializerMock); + Assert.assertTrue("Wrong - start server", startupServer()); + try { + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + } catch (TimeoutException e) { + Assert.fail("Wrong - getIsOnlineFuture timed out"); + } + Assert.assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); + shutdownServer(); + } + + private Boolean startupServer() throws InterruptedException, IOException, ExecutionException { + ListenableFuture online = udpHandler.getIsOnlineFuture(); + + (new Thread(udpHandler)).start(); + int retry = 0; + while (online.isDone() != true && retry++ < 20) { + Thread.sleep(100); + } + return online.isDone() ; + } + + private void shutdownServer() throws InterruptedException, ExecutionException { + ListenableFuture shutdownRet = udpHandler.shutdown() ; + while ( shutdownRet.isDone() != true ) + Thread.sleep(100) ; + Assert.assertTrue("Wrong - shutdown failed", shutdownRet.get()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java index ebe8351b..f9df80d2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java @@ -8,18 +8,18 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; -import org.junit.Assert; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder; @@ -88,7 +88,7 @@ public void testData() throws Exception{ BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8+dataToTest.length); byte[] outData = new byte[dataToTest.length]; out.readBytes(outData); - Assert.assertArrayEquals(dataToTest, outData); + Assert.assertArrayEquals("Wrong - different output data.", dataToTest, outData); out.release(); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java index 970bace0..64a5f078 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java @@ -11,15 +11,14 @@ import org.junit.Assert; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; From f690b42b6791c03d1c2a8244a47614c01bc352e0 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 15 Oct 2014 13:06:19 +0200 Subject: [PATCH 072/285] Removed EnhancedKeyRegistryHelper - as it is no longer used Change-Id: I3f9643cb94f022fd4d784f4afd038af0221aa636 Signed-off-by: Michal Polkorab --- .../impl/util/EnhancedKeyRegistryHelper.java | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedKeyRegistryHelper.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedKeyRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedKeyRegistryHelper.java deleted file mode 100644 index 1f36c257..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/EnhancedKeyRegistryHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; - -/** - * @author michal.polkorab - * @param OXM class - */ -public class EnhancedKeyRegistryHelper { - - private short version; - private Class generalClass; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param generalClass - * @param serializerRegistry - */ - public EnhancedKeyRegistryHelper(short version, Class generalClass, - SerializerRegistry serializerRegistry) { - this.version = version; - this.generalClass = generalClass; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param specificClass - * @param serializer - */ - public void registerSerializer(Class specificClass, OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new EnhancedMessageTypeKey<>(version, - generalClass, specificClass), serializer); - } -} From ba9b36dae13ea6deb1b34c2d40281c1dd68a2eff Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 20 Oct 2014 14:25:09 +0200 Subject: [PATCH 073/285] Increased unit test coverage for some deserialization factories Change-Id: If770094c17a7c2988602d17a7463243cbce63fee Signed-off-by: Michal Polkorab --- .../OF10FeaturesReplyMessageFactory.java | 65 +++------------- .../OF10PortStatusMessageFactory.java | 60 +++------------ .../protocol/impl/util/OpenflowUtils.java | 76 +++++++++++++++++++ .../FeaturesReplyMessageFactoryTest.java | 20 ++++- .../OF10FeaturesReplyMessageFactoryTest.java | 54 ++++++++----- .../OF10PortStatusMessageFactoryTest.java | 7 +- .../protocol/impl/util/OpenflowUtilsTest.java | 68 +++++++++++++++++ 7 files changed, 217 insertions(+), 133 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index 2d3cc782..13da41f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -15,14 +15,12 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.OpenflowUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort; @@ -88,7 +86,7 @@ private static ActionTypeV10 createActionsV10(long input) { SET_NW_DST, SET_NW_SRC, SET_NW_TOS, SET_TP_DST, SET_TP_SRC, SET_VLAN_PCP, SET_VLAN_VID, STRIP_VLAN, VENDOR); } - + private static PhyPort deserializePort(ByteBuf rawMessage) { PhyPortBuilder builder = new PhyPortBuilder(); builder.setPortNo((long) rawMessage.readUnsignedShort()); @@ -96,55 +94,12 @@ private static PhyPort deserializePort(ByteBuf rawMessage) { rawMessage.readBytes(address); builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address))); builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH)); - builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); - builder.setStateV10(createPortState(rawMessage.readUnsignedInt())); - builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); + builder.setConfigV10(OpenflowUtils.createPortConfig(rawMessage.readUnsignedInt())); + builder.setStateV10(OpenflowUtils.createPortState(rawMessage.readUnsignedInt())); + builder.setCurrentFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setAdvertisedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setSupportedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setPeerFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); return builder.build(); } - - - - private static PortStateV10 createPortState(long input){ - final Boolean _linkDown = ((input) & (1<<0)) != 0; - final Boolean _blocked = ((input) & (1<<1)) != 0; - final Boolean _live = ((input) & (1<<2)) != 0; - final Boolean _stpListen = ((input) & (0<<8)) != 0; - final Boolean _stpLearn = ((input) & (1<<8)) != 0; - final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 - final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 - final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 - return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); - } - - private static PortConfigV10 createPortConfig(long input){ - final Boolean _portDown = ((input) & (1<<0)) != 0; - final Boolean _noStp = ((input) & (1<<1)) != 0; - final Boolean _noRecv = ((input) & (1<<2)) != 0; - final Boolean _noRecvStp = ((input) & (1<<3)) != 0; - final Boolean _noFlood = ((input) & (1<<4)) != 0; - final Boolean _noFwd = ((input) & (1<<5)) != 0; - final Boolean _noPacketIn = ((input) & (1<<6)) != 0; - return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); - } - - private static PortFeaturesV10 createPortFeatures(long input){ - final Boolean _10mbHd = ((input) & (1<<0)) != 0; - final Boolean _10mbFd = ((input) & (1<<1)) != 0; - final Boolean _100mbHd = ((input) & (1<<2)) != 0; - final Boolean _100mbFd = ((input) & (1<<3)) != 0; - final Boolean _1gbHd = ((input) & (1<<4)) != 0; - final Boolean _1gbFd = ((input) & (1<<5)) != 0; - final Boolean _10gbFd = ((input) & (1<<6)) != 0; - final Boolean _copper = ((input) & (1<<7)) != 0; - final Boolean _fiber = ((input) & (1<<8)) != 0; - final Boolean _autoneg = ((input) & (1<<9)) != 0; - final Boolean _pause = ((input) & (1<<10)) != 0; - final Boolean _pauseAsym = ((input) & (1<<11)) != 0; - return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, - _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym); - } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java index e7036ed8..eed4b104 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java @@ -11,13 +11,11 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.OpenflowUtils; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; @@ -40,57 +38,17 @@ public PortStatusMessage deserialize(ByteBuf rawMessage) { return builder.build(); } - private static PortStateV10 createPortState(long input){ - final Boolean _linkDown = ((input) & (1<<0)) != 0; - final Boolean _blocked = ((input) & (1<<1)) != 0; - final Boolean _live = ((input) & (1<<2)) != 0; - final Boolean _stpListen = ((input) & (0<<8)) != 0; - final Boolean _stpLearn = ((input) & (1<<8)) != 0; - final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 - final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 - final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 - return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); - } - - private static PortConfigV10 createPortConfig(long input){ - final Boolean _portDown = ((input) & (1<<0)) != 0; - final Boolean _noStp = ((input) & (1<<1)) != 0; - final Boolean _noRecv = ((input) & (1<<2)) != 0; - final Boolean _noRecvStp = ((input) & (1<<3)) != 0; - final Boolean _noFlood = ((input) & (1<<4)) != 0; - final Boolean _noFwd = ((input) & (1<<5)) != 0; - final Boolean _noPacketIn = ((input) & (1<<6)) != 0; - return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); - } - - private static PortFeaturesV10 createPortFeatures(long input){ - final Boolean _10mbHd = ((input) & (1<<0)) != 0; - final Boolean _10mbFd = ((input) & (1<<1)) != 0; - final Boolean _100mbHd = ((input) & (1<<2)) != 0; - final Boolean _100mbFd = ((input) & (1<<3)) != 0; - final Boolean _1gbHd = ((input) & (1<<4)) != 0; - final Boolean _1gbFd = ((input) & (1<<5)) != 0; - final Boolean _10gbFd = ((input) & (1<<6)) != 0; - final Boolean _copper = ((input) & (1<<7)) != 0; - final Boolean _fiber = ((input) & (1<<8)) != 0; - final Boolean _autoneg = ((input) & (1<<9)) != 0; - final Boolean _pause = ((input) & (1<<10)) != 0; - final Boolean _pauseAsym = ((input) & (1<<11)) != 0; - return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, - _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym); - } - private static void deserializePort(ByteBuf rawMessage, PortStatusMessageBuilder builder) { builder.setPortNo((long) rawMessage.readUnsignedShort()); byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; rawMessage.readBytes(address); builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address))); builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH)); - builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); - builder.setStateV10(createPortState(rawMessage.readUnsignedInt())); - builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); - builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); + builder.setConfigV10(OpenflowUtils.createPortConfig(rawMessage.readUnsignedInt())); + builder.setStateV10(OpenflowUtils.createPortState(rawMessage.readUnsignedInt())); + builder.setCurrentFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setAdvertisedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setSupportedFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); + builder.setPeerFeaturesV10(OpenflowUtils.createPortFeatures(rawMessage.readUnsignedInt())); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java new file mode 100644 index 00000000..8ba8e74c --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; + +/** + * Used for common structures translation / conversion + * + * @author michal.polkorab + */ +public abstract class OpenflowUtils { + + /** + * Creates PortState (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortStateV10 createPortState(long input){ + final Boolean _linkDown = ((input) & (1<<0)) != 0; + final Boolean _blocked = ((input) & (1<<1)) != 0; + final Boolean _live = ((input) & (1<<2)) != 0; + final Boolean _stpListen = ((input) & (1<<8)) == 0; + final Boolean _stpLearn = ((input) & (1<<8)) != 0; + final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 + final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 + final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 + return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); + } + + /** + * Creates PortConfig (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortConfigV10 createPortConfig(long input){ + final Boolean _portDown = ((input) & (1<<0)) != 0; + final Boolean _noStp = ((input) & (1<<1)) != 0; + final Boolean _noRecv = ((input) & (1<<2)) != 0; + final Boolean _noRecvStp = ((input) & (1<<3)) != 0; + final Boolean _noFlood = ((input) & (1<<4)) != 0; + final Boolean _noFwd = ((input) & (1<<5)) != 0; + final Boolean _noPacketIn = ((input) & (1<<6)) != 0; + return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); + } + + /** + * Creates PortFeatures (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortFeaturesV10 createPortFeatures(long input){ + final Boolean _10mbHd = ((input) & (1<<0)) != 0; + final Boolean _10mbFd = ((input) & (1<<1)) != 0; + final Boolean _100mbHd = ((input) & (1<<2)) != 0; + final Boolean _100mbFd = ((input) & (1<<3)) != 0; + final Boolean _1gbHd = ((input) & (1<<4)) != 0; + final Boolean _1gbFd = ((input) & (1<<5)) != 0; + final Boolean _10gbFd = ((input) & (1<<6)) != 0; + final Boolean _copper = ((input) & (1<<7)) != 0; + final Boolean _fiber = ((input) & (1<<8)) != 0; + final Boolean _autoneg = ((input) & (1<<9)) != 0; + final Boolean _pause = ((input) & (1<<10)) != 0; + final Boolean _pauseAsym = ((input) & (1<<11)) != 0; + return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, + _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java index 233c7e38..ad4ccc59 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java @@ -47,7 +47,7 @@ public void startUp() { @Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" - + " 00 01 41 00 01 02 03"); + + " 00 00 00 00 01 02 03"); GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); @@ -55,7 +55,21 @@ public void test() { Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue()); Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue()); Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue()); - Assert.assertEquals("Wrong capabilities", new Capabilities(true, false, false, true, false, true, false), builtByFactory.getCapabilities()); + Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities()); Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue()); } -} + + /** + * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO + * (capabilities set) + */ + @Test + public void testCapabilities() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + + " 00 01 6F 00 01 02 03"); + GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong capabilities", new Capabilities(true, true, true, true, true, true, true), builtByFactory.getCapabilities()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index 4330e32d..9530eaba 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -53,31 +53,31 @@ public void startUp() { @Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " - + "00 00 00 8B 00 00 03 B5 " - + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 " - + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88"); + + "00 00 00 FF 00 00 0F FF " + + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 00 00 02 00 " + + "00 00 0F FF 00 00 00 00 00 00 03 0C 00 00 08 88"); GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue()); Assert.assertEquals("Wrong n-buffers", 0x00010203L, builtByFactory.getBuffers().longValue()); Assert.assertEquals("Wrong n-tables", 0x01, builtByFactory.getTables().shortValue()); - Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, false, false, false, false, true, true), + Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, true, true, true, true, true, true), builtByFactory.getCapabilitiesV10()); - Assert.assertEquals("Wrong actions", new ActionTypeV10(false, true, true, true, true, false, true, - false, true, true, false, false, false), builtByFactory.getActionsV10()); + Assert.assertEquals("Wrong actions", new ActionTypeV10(true, true, true, true, true, true, true, + true, true, true, true, true, false), builtByFactory.getActionsV10()); PhyPort port = builtByFactory.getPhyPort().get(0); Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue()); Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr()); Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName()); - Assert.assertEquals("Wrong port - config", new PortConfigV10(true, false, false, true, false, false, true), + Assert.assertEquals("Wrong port - config", new PortConfigV10(true, true, true, true, true, true, true), port.getConfigV10()); - Assert.assertEquals("Wrong port - state", new PortStateV10(false, true, false, false, false, true, false, false), + Assert.assertEquals("Wrong port - state", new PortStateV10(false, false, false, false, true, false, true, false), port.getStateV10()); - Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(false, false, false, false, true, true, true, - false, false, false, false, false), port.getCurrentFeaturesV10()); - Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, true, true, false, false, - false, false, false, false, true, false), port.getAdvertisedFeaturesV10()); + Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(true, true, true, true, true, true, true, + true, true, true, true, true), port.getCurrentFeaturesV10()); + Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, false, false, false, false, + false, false, false, false, false, false), port.getAdvertisedFeaturesV10()); Assert.assertEquals("Wrong port - supported", new PortFeaturesV10(true, true, false, false, false, false, false, true, false, true, false, false), port.getSupportedFeaturesV10()); Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false, @@ -88,30 +88,44 @@ public void test() { * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO */ @Test - public void testWithNoPortsSet() { + public void testWithTwoPortsSet() { ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 8B 00 00 03 B5 " - + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 " + + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 01 " + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88 " - + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 01 01 " + + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 " + "00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88"); GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong ports size", 2, builtByFactory.getPhyPort().size()); + PhyPort port = builtByFactory.getPhyPort().get(0); + Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue()); + Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr()); + Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName()); + Assert.assertEquals("Wrong port - config", new PortConfigV10(false, false, false, false, false, false, false), + port.getConfigV10()); + Assert.assertEquals("Wrong port - state", new PortStateV10(false, true, false, true, true, true, false, true), + port.getStateV10()); + port = builtByFactory.getPhyPort().get(1); + Assert.assertEquals("Wrong port - state", new PortStateV10(false, false, false, false, false, false, true, false), + port.getStateV10()); } - + /** * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO */ @Test - public void testWithTwoPortsSet() { + public void testWithNoPortsSet() { ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " - + "00 00 00 8B 00 00 03 B5"); + + "00 00 00 00 00 00 00 00"); GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(false, false, false, false, false, false, false, false), + builtByFactory.getCapabilitiesV10()); + Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false, + false, false, false, false, false, false), builtByFactory.getActionsV10()); Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size()); } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java index 759b0b66..6b451872 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java @@ -52,7 +52,7 @@ public void startUp() { public void test(){ ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00 00 00 00 00 " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 00 15 00 00 01 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88"); + + "00 00 00 00 15 00 00 00 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88"); PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); @@ -62,7 +62,7 @@ public void test(){ Assert.assertEquals("Wrong builtByFactory - name", new String("ALOHA"), builtByFactory.getName()); Assert.assertEquals("Wrong builtByFactory - config", new PortConfigV10(true, false, false, true, false, false, true), builtByFactory.getConfigV10()); - Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, true, false, false), + Assert.assertEquals("Wrong builtByFactory - state", new PortStateV10(false, true, false, false, false, false, true, false), builtByFactory.getStateV10()); Assert.assertEquals("Wrong builtByFactory - curr", new PortFeaturesV10(false, false, false, false, true, true, true, false, false, false, false, false), builtByFactory.getCurrentFeaturesV10()); @@ -73,5 +73,4 @@ public void test(){ Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), builtByFactory.getPeerFeaturesV10()); } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java new file mode 100644 index 00000000..47e92623 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; + +/** + * @author michal.polkorab + * + */ +public class OpenflowUtilsTest { + + /** + * Tests {@link OpenflowUtils#createPortState(long)} + */ + @Test + public void testPortState() { + PortStateV10 state = OpenflowUtils.createPortState(512L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, false, false, false, true, false, true, false), state); + + state = OpenflowUtils.createPortState(1793L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, true, true, true, false, true), state); + + state = OpenflowUtils.createPortState(1L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, false, false, false, true, false), state); + } + + /** + * Tests {@link OpenflowUtils#createPortConfig(long)} + */ + @Test + public void testPortConfig() { + PortConfigV10 config = OpenflowUtils.createPortConfig(127L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(true, true, true, true, true, true, true), config); + + config = OpenflowUtils.createPortConfig(0L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(false, false, false, false, false, false, false), config); + } + + /** + * Tests {@link OpenflowUtils#createPortFeatures(long)} + */ + @Test + public void testPortFeatures() { + PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, + true, true, true, true, true), features); + + features = OpenflowUtils.createPortFeatures(0L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, + false, false, false, false, false, false), features); + } +} \ No newline at end of file From 7a421fbfcec303ffbd5b6620f2725051be331ff5 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Tue, 21 Oct 2014 12:20:19 +0200 Subject: [PATCH 074/285] Add unit test ChannelOutboundQueue, tested by closed and read only channel Change-Id: I7ac6d35c8c2fd09fc53d2cf7974b77a717743aaf Signed-off-by: Marian Adamjak --- .../ChannelOutboundQueue02Test.java | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java new file mode 100644 index 00000000..c21f1cb8 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.connection; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author madamjak + * + */ +public class ChannelOutboundQueue02Test { + private static int counter; + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock EchoInput echoInput; + @Mock BarrierInput barrierInput; + @Mock EchoReplyInput echoReplyInput; + @Mock ExperimenterInput experimenterInput; + private ConnectionAdapterImpl adapter; + private Cache> cache; + /** + * Initialize mocks + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + /** + * Disconnect adapter after each test + */ + @After + public void tierDown(){ + if (adapter != null && adapter.isAlive()) { + adapter.disconnect(); + } + } + + /** + * Test write to closed / opened channel + * @throws Exception + */ + @Test + public void test01() throws Exception { + EmbeddedChannel ec = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(ec,InetSocketAddress.createUnresolved("localhost", 9876)); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + ChannelOutboundQueue cq = (ChannelOutboundQueue) ec.pipeline().last(); + counter=0; + adapter.barrier(barrierInput); + adapter.echo(echoInput); + cq.channelInactive(ec.pipeline().lastContext()); + ec.runPendingTasks(); + Assert.assertEquals("Wrong - ChannelOutboundHandlerAdapter.write was invoked on closed channel",0, counter); + cq.channelActive(ec.pipeline().lastContext()); + counter=0; + adapter.barrier(barrierInput); + adapter.experimenter(experimenterInput); + ec.runPendingTasks(); + Assert.assertEquals("Wrong - ChannelOutboundHandlerAdapter.write has not been invoked on opened channel",2, counter); + } + + /** + * Test write to read only / writable channel + */ + @Test + public void test02(){ + ChangeWritableEmbededChannel ec = new ChangeWritableEmbededChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(ec,InetSocketAddress.createUnresolved("localhost", 9876)); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + ec.setReadOnly(); + counter=0; + adapter.barrier(barrierInput); + adapter.echo(echoInput); + ec.runPendingTasks(); + Assert.assertEquals("Wrong - write to readonly channel",0, counter); + ec.setWritable(); + adapter.echoReply(echoReplyInput); + adapter.echo(echoInput); + ec.runPendingTasks(); + Assert.assertEquals("Wrong - write to writtable channel",4, counter); + } + + /** + * Channel Handler for testing + * @author madamjak + * + */ + private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, + ChannelPromise promise) throws Exception { + if(msg instanceof MessageListenerWrapper){ + counter++; + } + } + } + + /** + * Class for testing - channel can change state to read only or writable + * @author madamjak + * + */ + private class ChangeWritableEmbededChannel extends EmbeddedChannel { + private boolean isWrittable; + public ChangeWritableEmbededChannel(ChannelHandler channelHandler){ + super(channelHandler); + setReadOnly(); + } + + @Override + public boolean isWritable() { + return isWrittable; + } + + public void setWritable(){ + isWrittable = true; + } + + public void setReadOnly(){ + isWrittable = false; + } + } +} From 2eabec589d64e5da79a79c71a41183da954d5b67 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 21 Oct 2014 12:36:46 +0200 Subject: [PATCH 075/285] Increased unit test coverage for the rest of deserialization factories Change-Id: I6dcf3094071fcb8013084469574dc0af48f293bf Signed-off-by: Michal Polkorab --- .../GetAsyncReplyMessageFactoryTest.java | 32 +++++------- .../OF10PacketInMessageFactoryTest.java | 12 ++++- .../PortStatusMessageFactoryTest.java | 29 ++++++++++- .../MultipartReplyExperimenterTest.java | 14 +---- .../OF10StatsReplyExperimenterTest.java | 52 +++++++++++++++++++ 5 files changed, 107 insertions(+), 32 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java index 6dd6558d..937f7d8c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -57,29 +57,27 @@ public void startUp() { */ @Test public void testGetAsyncReplyMessage() { - ByteBuf bb = BufferHelper.buildBuffer("00 00 00 06 "+ - "00 00 00 05 "+ + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+ + "00 00 00 00 "+ "00 00 00 07 "+ "00 00 00 00 "+ - "00 00 00 03 "+ - "00 00 00 0A"); + "00 00 00 0F "+ + "00 00 00 00"); GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong packetInMask",createPacketInMask(), - builtByFactory.getPacketInMask()); - Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), - builtByFactory.getPortStatusMask()); - Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), - builtByFactory.getFlowRemovedMask()); + Assert.assertEquals("Wrong packetInMask",createPacketInMask(), builtByFactory.getPacketInMask()); + Assert.assertEquals("Wrong portStatusMask",createPortStatusMask(), builtByFactory.getPortStatusMask()); + Assert.assertEquals("Wrong flowRemovedMask",createFlowRemovedMask(), builtByFactory.getFlowRemovedMask()); } - + private static List createPacketInMask() { List inMasks = new ArrayList<>(); PacketInMaskBuilder maskBuilder; // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER maskBuilder = new PacketInMaskBuilder(); List reasons = new ArrayList<>(); + reasons.add(PacketInReason.OFPRNOMATCH); reasons.add(PacketInReason.OFPRACTION); reasons.add(PacketInReason.OFPRINVALIDTTL); maskBuilder.setMask(reasons); @@ -87,13 +85,11 @@ private static List createPacketInMask() { // OFPCR_ROLE_SLAVE maskBuilder = new PacketInMaskBuilder(); reasons = new ArrayList<>(); - reasons.add(PacketInReason.OFPRNOMATCH); - reasons.add(PacketInReason.OFPRINVALIDTTL); maskBuilder.setMask(reasons); inMasks.add(maskBuilder.build()); return inMasks; } - + private static List createPortStatusMask() { List inMasks = new ArrayList<>(); PortStatusMaskBuilder maskBuilder; @@ -111,7 +107,7 @@ private static List createPortStatusMask() { inMasks.add(maskBuilder.build()); return inMasks; } - + private static List createFlowRemovedMask() { List inMasks = new ArrayList<>(); FlowRemovedMaskBuilder maskBuilder; @@ -120,15 +116,15 @@ private static List createFlowRemovedMask() { List reasons = new ArrayList<>(); reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT); reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + reasons.add(FlowRemovedReason.OFPRRDELETE); + reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); maskBuilder.setMask(reasons); inMasks.add(maskBuilder.build()); // OFPCR_ROLE_SLAVE maskBuilder = new FlowRemovedMaskBuilder(); reasons = new ArrayList<>(); - reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); - reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); maskBuilder.setMask(reasons); inMasks.add(maskBuilder.build()); return inMasks; } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java index a632ba45..62387806 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java @@ -56,4 +56,14 @@ public void test(){ Assert.assertArrayEquals("Wrong data", ByteBufUtils.hexStringToBytes("01 02 03 04"), builtByFactory.getData()); } -} + /** + * Testing {@link OF10PacketInMessageFactory} for correct translation into POJO + */ + @Test + public void testWithNoAdditionalData(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00"); + PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); + + Assert.assertNull("Wrong data", builtByFactory.getData()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index b538e856..cf0499ae 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -91,4 +91,31 @@ public void test(){ Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue()); Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue()); } -} + + /** + * Testing {@link PortStatusMessageFactory} for correct translation into POJO + */ + @Test + public void testWithDifferentBitmaps(){ + ByteBuf bb = BufferHelper.buildBuffer("01 00 00 00 00 00 00 00 " + //reason, padding + "00 01 02 03 00 00 00 00 " + //port no, padding + "08 00 27 00 B0 EB 00 00 " + //mac address, padding + "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port name, String "s1-eth1" + "00 00 00 24 " + //port config + "00 00 00 02 " + //port state + "00 00 00 81 00 00 00 A1 " + //current + advertised features + "00 00 FF FF 00 00 00 00 " + //supported + peer features + "00 00 00 81 00 00 00 80" //curr speed, max speed + ); + PortStatusMessage message = BufferHelper.deserialize(statusFactory, bb); + + Assert.assertEquals("Wrong portConfig", new PortConfig(true, false, true, false), message.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(true, false, false), message.getState()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, true, true, + true, true, true, true, true, true, true, true, true, true, true, true), + message.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, + false, false, false, false, false, false, false, false, false, false, + false, false), message.getPeerFeatures()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java index 61110453..6e4de3f9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -40,18 +40,8 @@ public class MultipartReplyExperimenterTest { @Test public void testMultipartReplyExperimenter() { factory.injectDeserializerRegistry(registry); - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 "+ - "00 00 00 0F "+// types - "00 00 00 0F "+// capabilities - "00 00 00 01 "+// max groups - "00 00 00 02 "+// max groups - "00 00 00 03 "+// max groups - "00 00 00 04 "+// max groups - "0F FF 98 01 "+// actions bitmap (all actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00"// actions bitmap (no actions included) - ); + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01 00 00 00 02"); // expID, expType MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV13(builtByFactory); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java new file mode 100644 index 00000000..6ef4153d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + /** + * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation + */ + @Test + public void test() { + OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); + factory.injectDeserializerRegistry(registry); + + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01"); // expID + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } +} \ No newline at end of file From 7bc11e6553a62fee6f66083359fc9ef37e8d1a6b Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 21 Oct 2014 14:36:29 +0200 Subject: [PATCH 076/285] Increased unit test coverage of serialization factories Change-Id: Ia284e5e9050b4ab19deb3ba0e5dfa3d0317e2c38 Signed-off-by: Michal Polkorab --- .../OF10StatsRequestInputFactory.java | 2 +- .../GroupModInputMessageFactoryTest.java | 28 ++- .../MeterModInputMessageFactoryTest.java | 27 ++- .../OF10PacketOutInputMessageFactoryTest.java | 24 ++- .../OF10StatsRequestInputFactoryTest.java | 4 +- .../PacketOutInputMessageFactoryTest.java | 25 ++- .../SetAsyncInputMessageFactoryTest.java | 57 ++++-- .../MultipartRequestExperimenterTest.java | 79 ++++++++ .../MultipartRequestGroupDescTest.java | 77 ++++++++ .../MultipartRequestGroupFeaturesTest.java | 77 ++++++++ .../MultipartRequestMeterFeaturesTest.java | 77 ++++++++ .../MultipartRequestPortDescTest.java | 77 ++++++++ ...=> MultipartRequestTableFeaturesTest.java} | 187 +++++++++++++++++- .../multipart/MultipartRequestTableTest.java | 77 ++++++++ .../OF10StatsRequestAggregateTest.java | 102 ++++++++++ .../OF10StatsRequestExperimenterTest.java | 79 ++++++++ 16 files changed, 960 insertions(+), 39 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/{TableFeaturesTest.java => MultipartRequestTableFeaturesTest.java} (62%) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 74b79359..98f93b45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -136,7 +136,7 @@ private void serializeExperimenterBody(final MultipartRequestBody multipartReque MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter(); long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue(); OFSerializer serializer = registry.getSerializer( - ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( EncodeConstants.OF10_VERSION_ID, expId)); serializer.serialize(expCase, output); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java index dcb543fc..c5d41114 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java @@ -20,9 +20,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; @@ -105,4 +105,28 @@ private static List createBucketsListFromBufer(ByteBuf out){ bucketsList.add(bucket); return bucketsList; } -} + + /** + * Testing of {@link GroupModInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testGroupModInputWithNoBuckets() throws Exception { + GroupModInputBuilder builder = new GroupModInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setCommand(GroupModCommand.forValue(2)); + builder.setType(GroupType.forValue(3)); + builder.setGroupId(new GroupId(256L)); + GroupModInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + groupModFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16); + Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort()); + Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte()); + out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE); + Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt()); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index 718f134b..8dfa9554 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -134,5 +134,28 @@ private static List decodeBandsList(ByteBuf input){ bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); return bandsList; } - -} + + /** + * @throws Exception + * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO + */ + @Test + public void testMeterModInputMessageWithNoBands() throws Exception { + MeterModInputBuilder builder = new MeterModInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setCommand(MeterModCommand.forValue(1)); + builder.setFlags(new MeterFlags(false, true, true, false)); + builder.setMeterId(new MeterId(2248L)); + builder.setBands(null); + MeterModInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + meterModFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 29, 16); + Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); + Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); + Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt()); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 99d06a75..d98a8364 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -102,4 +102,26 @@ public void testPacketOutInputMessage() throws Exception { Assert.assertTrue("Unread data", out.readableBytes() == 0); } -} + /** + * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testPacketOutInputWithNoData() throws Exception { + PacketOutInputBuilder builder = new PacketOutInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setBufferId(256L); + builder.setInPort(new PortNumber(257L)); + List actions = new ArrayList<>(); + builder.setAction(actions); + builder.setData(null); + PacketOutInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + packetOutFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 13, 16); + out.skipBytes(8); // skip packet out message to data index + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 5909067e..9e38a5c6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -16,10 +16,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; @@ -300,4 +300,4 @@ public void testQueue() throws Exception { Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 394e70c2..8cc92e2a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -98,4 +98,27 @@ public void testPacketOutInputMessage() throws Exception { out.skipBytes(PADDING_IN_ACTION_HEADER); Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array()); } -} + + /** + * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO + * @throws Exception + */ + @Test + public void testPacketOutInputWithNoData() throws Exception { + PacketOutInputBuilder builder = new PacketOutInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setBufferId(256L); + builder.setInPort(new PortNumber(256L)); + List actions = new ArrayList<>(); + builder.setAction(actions); + builder.setData(null); + PacketOutInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + packetOutFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 24); + out.skipBytes(16); // skip packet out message to data index + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index 0b890765..c9ed91e3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -20,10 +20,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; @@ -35,16 +34,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author timotej.kubas * @author michal.polkorab */ public class SetAsyncInputMessageFactoryTest { - private static final Logger LOGGER = LoggerFactory - .getLogger(SetAsyncInputMessageFactoryTest.class); + private SerializerRegistry registry; private OFSerializer setAsyncFactory; @@ -71,20 +67,20 @@ public void testSetAsyncInputMessage() throws Exception { builder.setPortStatusMask(createPortStatusMask()); builder.setFlowRemovedMask(createFlowRemowedMask()); SetAsyncInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); setAsyncFactory.serialize(message, out); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(out)); + BufferHelper.checkHeaderV13(out,(byte) 28, 32); - Assert.assertEquals("Wrong packetInMask", 5, out.readUnsignedInt()); Assert.assertEquals("Wrong packetInMask", 7, out.readUnsignedInt()); - Assert.assertEquals("Wrong portStatusMask", 6, out.readUnsignedInt()); + Assert.assertEquals("Wrong packetInMask", 0, out.readUnsignedInt()); + Assert.assertEquals("Wrong portStatusMask", 7, out.readUnsignedInt()); Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt()); - Assert.assertEquals("Wrong flowRemovedMask", 10, out.readUnsignedInt()); - Assert.assertEquals("Wrong flowRemovedMask", 5, out.readUnsignedInt()); + Assert.assertEquals("Wrong flowRemovedMask", 15, out.readUnsignedInt()); + Assert.assertEquals("Wrong flowRemovedMask", 0, out.readUnsignedInt()); } - + private static List createPacketInMask() { List masks = new ArrayList<>(); PacketInMaskBuilder builder; @@ -92,26 +88,25 @@ private static List createPacketInMask() { builder = new PacketInMaskBuilder(); List packetInReasonList = new ArrayList<>(); packetInReasonList.add(PacketInReason.OFPRNOMATCH); + packetInReasonList.add(PacketInReason.OFPRACTION); packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); builder.setMask(packetInReasonList); masks.add(builder.build()); // OFPCR_ROLE_SLAVE builder = new PacketInMaskBuilder(); packetInReasonList = new ArrayList<>(); - packetInReasonList.add(PacketInReason.OFPRNOMATCH); - packetInReasonList.add(PacketInReason.OFPRACTION); - packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); builder.setMask(packetInReasonList); masks.add(builder.build()); return masks; } - + private static List createPortStatusMask() { List masks = new ArrayList<>(); PortStatusMaskBuilder builder; builder = new PortStatusMaskBuilder(); // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER List portReasonList = new ArrayList<>(); + portReasonList.add(PortReason.OFPPRADD); portReasonList.add(PortReason.OFPPRDELETE); portReasonList.add(PortReason.OFPPRMODIFY); builder.setMask(portReasonList); @@ -123,24 +118,44 @@ private static List createPortStatusMask() { masks.add(builder.build()); return masks; } - + private static List createFlowRemowedMask() { List masks = new ArrayList<>(); FlowRemovedMaskBuilder builder; // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER builder = new FlowRemovedMaskBuilder(); List flowRemovedReasonList = new ArrayList<>(); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); builder.setMask(flowRemovedReasonList); masks.add(builder.build()); // OFPCR_ROLE_SLAVE builder = new FlowRemovedMaskBuilder(); flowRemovedReasonList = new ArrayList<>(); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); - flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); builder.setMask(flowRemovedReasonList); masks.add(builder.build()); return masks; } -} + + /** + * @throws Exception + * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO + */ + @Test + public void testSetAsyncInputWithNullMasks() throws Exception { + SetAsyncInputBuilder builder = new SetAsyncInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setPacketInMask(null); + builder.setPortStatusMask(null); + builder.setFlowRemovedMask(null); + SetAsyncInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + setAsyncFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out,(byte) 28, 8); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java new file mode 100644 index 00000000..b5b93b89 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java new file mode 100644 index 00000000..db068d71 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); + MultipartRequestGroupDescBuilder descBuilder = new MultipartRequestGroupDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java new file mode 100644 index 00000000..2097974a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); + MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java new file mode 100644 index 00000000..3eb74b1b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestMeterFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - MeterFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPMETERFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); + MultipartRequestMeterFeaturesBuilder featuresBuilder = new MultipartRequestMeterFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestMeterFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java new file mode 100644 index 00000000..2172e822 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestPortDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - PortDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPPORTDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); + MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestPortDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java similarity index 62% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index 347ca633..86f0fef4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/TableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -17,15 +17,24 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; @@ -34,6 +43,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; @@ -42,6 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; @@ -66,17 +79,24 @@ * @author michal.polkorab * */ -public class TableFeaturesTest { +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestTableFeaturesTest { + private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = MultipartRequestInputFactoryTest.PADDING_IN_MULTIPART_REQUEST_MESSAGE; private SerializerRegistry registry; private OFSerializer multipartFactory; + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + /** * Initializes serializer registry and stores correct factory in field */ @Before public void startUp() { + Mockito.when(mockRegistry.getSerializer((MessageTypeKey)Matchers.any())) + .thenReturn(serializer); registry = new SerializerRegistryImpl(); registry.init(); multipartFactory = registry.getSerializer( @@ -118,7 +138,6 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); nextIds = new ArrayList<>(); - nextIds.add(new NextTableIdsBuilder().setTableId((short) 3).build()); nextPropBuilder.setNextTableIds(nextIds); propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); properties.add(propBuilder.build()); @@ -169,6 +188,37 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { tableFeaturesBuilder.setMaxEntries(67L); properties = new ArrayList<>(); propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); + ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + actions.add(actionBuilder.build()); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); List entries = new ArrayList<>(); @@ -186,6 +236,27 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); @@ -202,6 +273,13 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { oxmBuilder.setMatchEntries(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); tableFeaturesBuilder.setTableFeatureProperties(properties); tableFeaturesList.add(tableFeaturesBuilder.build()); featuresBuilder.setTableFeatures(tableFeaturesList); @@ -212,7 +290,7 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - BufferHelper.checkHeaderV13(out, (byte) 18, 232); + BufferHelper.checkHeaderV13(out, (byte) 18, 296); Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); @@ -237,9 +315,8 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); out.skipBytes(2); Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong next-registry-id", 3, out.readUnsignedByte()); - out.skipBytes(3); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); @@ -259,7 +336,7 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong length", 96, out.readUnsignedShort()); + Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); out.skipBytes(5); Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", @@ -274,6 +351,19 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); @@ -283,6 +373,15 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); out.skipBytes(4); + Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); @@ -292,7 +391,77 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); out.skipBytes(4); + Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); Assert.assertTrue("Unread data", out.readableBytes() == 0); } -} + /** + * @throws Exception + * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO + */ + @Test + public void testMultipartRequestTableFeaturesExperimenter() throws Exception { + MultipartRequestInputFactory factory = new MultipartRequestInputFactory(); + factory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.forValue(12)); + builder.setFlags(new MultipartRequestFlags(true)); + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); + ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(42L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); + expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(43L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 80); + Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + Assert.assertEquals("Wrong length", 64, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); + Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), + Matchers.any(ByteBuf.class)); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java new file mode 100644 index 00000000..8ffcdd7d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestTableTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - Table case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPTABLE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder(); + tablesBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tablesBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java new file mode 100644 index 00000000..448c5298 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestAggregateTest { + + private SerializerRegistry registry; + private OFSerializer statsFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + statsFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link OF10StatsRequestInputFactory} for correct serialization + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPAGGREGATE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, + true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + aggBuilder.setMatchV10(matchBuilder.build()); + aggBuilder.setTableId((short) 5); + aggBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestAggregate(aggBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + statsFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(40); // skip match check + Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java new file mode 100644 index 00000000..b26d4ffe --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } +} \ No newline at end of file From d8629ad6c80f82e588f77707c80e3edb1dc743fb Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 22 Oct 2014 07:55:28 +0200 Subject: [PATCH 077/285] Fix HelloMessageFactory - repair handling message with bad HelloElementType - when message has bad HelloElementType empty list of elements will return - modifying test to follow fix HelloMessageFactory - add test for message with padding Change-Id: Ie6a97f79a4d133b9da07b15023cda60ba74eec2f Signed-off-by: Marian Adamjak --- .../factories/HelloMessageFactory.java | 2 + .../factories/HelloMessageFactoryTest.java | 54 ++++++++++++++----- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java index b596cd92..5fafb5e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java @@ -57,6 +57,8 @@ private static List readElement(ByteBuf input) { if (paddingRemainder != 0) { input.readBytes(EncodeConstants.PADDING - paddingRemainder); } + } else { + return elementsList; } elementsList.add(elementsBuilder.build()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index 0be6bb94..89f10225 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -30,11 +30,10 @@ /** * @author michal.polkorab * @author timotej.kubas + * @author madamjak */ public class HelloMessageFactoryTest { - /** Number of currently supported version / codec */ - public static final Short VERSION_YET_SUPPORTED = 0x04; private OFDeserializer helloFactory; /** @@ -49,25 +48,56 @@ public void startUp() { } /** - * Testing {@link HelloMessageFactory} for correct translation into POJO + * Testing {@link HelloMessageFactory} for correct length without padding */ @Test - public void test() { + public void testWithoutPadding() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type + + "00 08 " // length + + "00 00 00 11" // bitmap 1 + ); + HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); + BufferHelper.checkHeaderV13(builtByFactory); + List element = createElement(4,HelloElementType.VERSIONBITMAP.getIntValue()); + Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); + Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); + } + + /** + * Testing {@link HelloMessageFactory} for correct length with padding + */ + @Test + public void testWithPadding() { ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type + "00 0c " // length + "00 00 00 11 " // bitmap 1 + "00 00 00 00 " // bitmap 2 + "00 00 00 00" // padding - ); + ); HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); - BufferHelper.checkHeaderV13(builtByFactory); - List element = createElement(); + List element = createElement(8,HelloElementType.VERSIONBITMAP.getIntValue()); Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); } - - private static List createElement() { + + /** + * Testing {@link HelloMessageFactory} if incorrect version is set + */ + @Test + public void testBadType(){ + ByteBuf bb = BufferHelper.buildBuffer("00 02 " // type + + "00 0c " // length + + "00 00 00 11 " // bitmap 1 + + "00 00 00 00 " // bitmap 2 + + "00 00 00 00" // padding + ); + HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.getElements().size()); + } + + private static List createElement(int lengthInByte, int type) { ElementsBuilder elementsBuilder = new ElementsBuilder(); List elementsList = new ArrayList<>(); List booleanList = new ArrayList<>(); @@ -76,13 +106,13 @@ private static List createElement() { booleanList.add(false); booleanList.add(false); booleanList.add(true); - for (int i = 1; i < 60; i++) { + int inSize = booleanList.size(); + for (int i = 1; i < ((lengthInByte * 8) - inSize + 1); i++) { booleanList.add(false); } - elementsBuilder.setType(HelloElementType.forValue(1)); + elementsBuilder.setType(HelloElementType.forValue(type)); elementsBuilder.setVersionBitmap(booleanList); elementsList.add(elementsBuilder.build()); - return elementsList; } } From 8b321e8cdb91b905c289bb6f03edbb8ae1b378e4 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 22 Oct 2014 13:05:11 +0200 Subject: [PATCH 078/285] Add unit test for OF13SetFieldActionSerializer (experimenter) Change-Id: Ib058979325b75cc8972648360b99069d8007db32 Signed-off-by: Marian Adamjak --- .../OF13SetFieldActionSerializerTest.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java new file mode 100644 index 00000000..d178fdc2 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author madamjak + * + */ +public class OF13SetFieldActionSerializerTest { + + private SerializerRegistry registry; + @Mock OFSerializer serializerMock; + + /** + * Initialize registry and mock + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Test identify ExperimenterClass serializer + */ + @Test + public void test(){ + OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer(); + ser.injectSerializerRegistry(registry); + ActionBuilder actionBuilder = new ActionBuilder(); + long experimenterId = 12L; + ExperimenterIdMatchEntryBuilder expIdMatchBuilder = new ExperimenterIdMatchEntryBuilder(); + expIdMatchBuilder.setExperimenter(new ExperimenterId(experimenterId)); + MatchEntriesBuilder meb = new MatchEntriesBuilder(); + meb.setOxmClass(ExperimenterClass.class); + meb.setOxmMatchField(OxmMatchFieldClass.class); + meb.addAugmentation(ExperimenterIdMatchEntry.class, expIdMatchBuilder.build()); + List matchEntries = new ArrayList<>(); + MatchEntries me = meb.build(); + matchEntries.add(me); + OxmFieldsActionBuilder oxmActBuilder = new OxmFieldsActionBuilder(); + oxmActBuilder.setMatchEntries(matchEntries); + actionBuilder.addAugmentation(OxmFieldsAction.class, oxmActBuilder.build()); + actionBuilder.setType(SetField.class); + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class); + key.setExperimenterId(experimenterId); + registry.registerSerializer(key, serializerMock); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ser.serialize(actionBuilder.build(), out); + Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntries)Mockito.anyObject(), (ByteBuf)Mockito.anyObject()); + int lenght = out.readableBytes(); + Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort()); + Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort()); + } + + private class OxmMatchFieldClass extends MatchField { + // only for testing purposes + } +} From deae01ba7f45087e38f04287661fb215cd8ea03e Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 23 Oct 2014 12:09:49 +0200 Subject: [PATCH 079/285] Bug 2245 - Fixed 'If Stmts Must Use Braces' Change-Id: Ibef534ef02ef6058ec34dbca7ec172a03612d8d1 Signed-off-by: Michal Polkorab --- .../extensibility/EnhancedMessageCodeKey.java | 12 ++++++--- .../extensibility/EnhancedMessageTypeKey.java | 17 +++++++----- .../api/extensibility/MessageCodeKey.java | 22 +++++++++------ .../api/extensibility/MessageTypeKey.java | 21 +++++++++------ .../api/keys/ActionDeserializerKey.java | 15 +++++++---- .../api/keys/ActionSerializerKey.java | 21 ++++++++++----- .../api/keys/InstructionDeserializerKey.java | 15 +++++++---- .../api/keys/InstructionSerializerKey.java | 21 ++++++++++----- .../api/keys/MatchEntryDeserializerKey.java | 18 ++++++++----- .../api/keys/MatchEntrySerializerKey.java | 27 ++++++++++++------- .../ExperimenterActionSerializerKey.java | 16 ++++++----- .../ExperimenterIdDeserializerKey.java | 15 +++++++---- .../ExperimenterIdSerializerKey.java | 15 +++++++---- .../impl/connection/RpcResponseKey.java | 18 ++++++++----- .../deserialization/MessageTypeCodeKey.java | 18 ++++++++----- .../impl/deserialization/TypeToClassKey.java | 17 +++++++----- 16 files changed, 187 insertions(+), 101 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java index 8db03d93..08db5a01 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java @@ -37,15 +37,19 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj; - if (msgType2 != other.msgType2) + if (msgType2 != other.msgType2) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index 15919e4f..a2157210 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -30,19 +30,24 @@ public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgTy @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } @SuppressWarnings("rawtypes") EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj; if (msgType2 == null) { - if (other.msgType2 != null) + if (other.msgType2 != null) { return false; - } else if (!msgType2.getName().equals(other.msgType2.getName())) + } + } else if (!msgType2.getName().equals(other.msgType2.getName())) { return false; + } return true; } @@ -50,4 +55,4 @@ public boolean equals(Object obj) { public String toString() { return super.toString() + " msgType2: " + msgType2.getName(); } -} +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index 86d5a4d1..56b6bb1a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -40,22 +40,29 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (!(obj instanceof MessageCodeKey)) + } + if (!(obj instanceof MessageCodeKey)) { return false; + } MessageCodeKey other = (MessageCodeKey) obj; if (clazz == null) { - if (other.clazz != null) + if (other.clazz != null) { return false; - } else if (!clazz.equals(other.clazz)) + } + } else if (!clazz.equals(other.clazz)) { return false; - if (msgType != other.msgType) + } + if (msgType != other.msgType) { return false; - if (msgVersion != other.msgVersion) + } + if (msgVersion != other.msgVersion) { return false; + } return true; } @@ -63,5 +70,4 @@ public boolean equals(Object obj) { public String toString() { return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; } - } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java index d5d303e4..2e1d0189 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java @@ -45,21 +45,26 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (!(obj instanceof MessageTypeKey)) + } + if (!(obj instanceof MessageTypeKey)) { return false; + } MessageTypeKey other = (MessageTypeKey) obj; if (msgType == null) { - if (other.msgType != null) + if (other.msgType != null) { return false; - } else if (!msgType.equals(other.msgType)) + } + } else if (!msgType.equals(other.msgType)) { return false; - if (msgVersion != other.msgVersion) + } + if (msgVersion != other.msgVersion) { return false; + } return true; } - -} +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index db17b3b5..d7363fbb 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -39,18 +39,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (!(obj instanceof ActionDeserializerKey)) + } + if (!(obj instanceof ActionDeserializerKey)) { return false; + } ActionDeserializerKey other = (ActionDeserializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index bf1fe7dc..4e33c56c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -44,23 +44,30 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ActionSerializerKey other = (ActionSerializerKey) obj; if (actionType == null) { - if (other.actionType != null) + if (other.actionType != null) { return false; - } else if (!actionType.equals(other.actionType)) + } + } else if (!actionType.equals(other.actionType)) { return false; + } if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index 91f8977a..c2160878 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -39,18 +39,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (!(obj instanceof InstructionDeserializerKey)) + } + if (!(obj instanceof InstructionDeserializerKey)) { return false; + } InstructionDeserializerKey other = (InstructionDeserializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 899568dc..7759c0bf 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -46,23 +46,30 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (!(obj instanceof InstructionSerializerKey)) + } + if (!(obj instanceof InstructionSerializerKey)) { return false; + } InstructionSerializerKey other = (InstructionSerializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } if (instructionType == null) { - if (other.instructionType != null) + if (other.instructionType != null) { return false; - } else if (!instructionType.equals(other.instructionType)) + } + } else if (!instructionType.equals(other.instructionType)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index 593ca8d6..d50d9fb1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -51,20 +51,26 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; - if (oxmField != other.oxmField) + } + if (oxmField != other.oxmField) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index c7f07f62..55d67e56 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -58,28 +58,37 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } if (oxmClass == null) { - if (other.oxmClass != null) + if (other.oxmClass != null) { return false; - } else if (!oxmClass.equals(other.oxmClass)) + } + } else if (!oxmClass.equals(other.oxmClass)) { return false; + } if (oxmField == null) { - if (other.oxmField != null) + if (other.oxmField != null) { return false; - } else if (!oxmField.equals(other.oxmField)) + } + } else if (!oxmField.equals(other.oxmField)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index f9f3cb11..45b2d02a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -40,19 +40,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; if (actionSubType == null) { - if (other.actionSubType != null) + if (other.actionSubType != null) { return false; - } else if (!actionSubType.equals(other.actionSubType)) + } + } else if (!actionSubType.equals(other.actionSubType)) { return false; + } return true; } - } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java index d4841f20..1682d6d3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -43,18 +43,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (!(obj instanceof ExperimenterIdDeserializerKey)) + } + if (!(obj instanceof ExperimenterIdDeserializerKey)) { return false; + } ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } return true; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java index 47d3608a..2336e9a8 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -41,18 +41,23 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (!(obj instanceof ExperimenterIdSerializerKey)) + } + if (!(obj instanceof ExperimenterIdSerializerKey)) { return false; + } ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; if (experimenterId == null) { - if (other.experimenterId != null) + if (other.experimenterId != null) { return false; - } else if (!experimenterId.equals(other.experimenterId)) + } + } else if (!experimenterId.equals(other.experimenterId)) { return false; + } return true; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java index a01098d4..5ec0c0b1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java @@ -52,20 +52,25 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } RpcResponseKey other = (RpcResponseKey) obj; if (outputClazz == null) { - if (other.outputClazz != null) + if (other.outputClazz != null) { return false; - } else if (!outputClazz.equals(other.outputClazz)) + } + } else if (!outputClazz.equals(other.outputClazz)) { return false; // if (xid != other.xid) // return false; + } return true; } @@ -74,5 +79,4 @@ public String toString() { return "RpcResultKey [xid=" + xid + ", outputClazz=" + outputClazz + "]"; } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java index bb4368ab..d623297e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java @@ -53,18 +53,22 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } MessageTypeCodeKey other = (MessageTypeCodeKey) obj; - if (msgType != other.msgType) + if (msgType != other.msgType) { return false; - if (msgVersion != other.msgVersion) + } + if (msgVersion != other.msgVersion) { return false; + } return true; } - -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java index 8be2df3e..7774937b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java @@ -36,17 +36,22 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } TypeToClassKey other = (TypeToClassKey) obj; - if (type != other.type) + if (type != other.type) { return false; - if (version != other.version) + } + if (version != other.version) { return false; + } return true; } -} +} \ No newline at end of file From 249aff59137050edd77d55f5aa0e769c6414d3b0 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 22 Oct 2014 16:31:08 +0200 Subject: [PATCH 080/285] Created unit tests for OFDatagramPacketDecoder, OFDatagramPacketHandler Change-Id: I4984189ebc2e93fb186a718bce6e8d787095ed76 Signed-off-by: Marian Adamjak --- .../core/OFDatagramPacketDecoderTest.java | 57 +++++++++++++++ .../core/OFDatagramPacketHandlerTest.java | 70 +++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java new file mode 100644 index 00000000..4175647d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; + +/** + * @author madamjak + * + */ +public class OFDatagramPacketDecoderTest { + @Mock DeserializationFactory deserializationFactory; + @Mock ChannelHandlerContext ctx; + @Mock ByteBuf messageBufferMock; + + private VersionMessageUdpWrapper msgWrapper; + private List out; + + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + out = new ArrayList<>(); + } + + @Test + public void test() { + OFDatagramPacketDecoder decoder = new OFDatagramPacketDecoder(); + decoder.setDeserializationFactory(deserializationFactory); + msgWrapper = new VersionMessageUdpWrapper(EncodeConstants.OF13_VERSION_ID, messageBufferMock, new InetSocketAddress("10.0.0.1", 6653)); + try { + decoder.decode(ctx, msgWrapper, out); + } catch (Exception e) { + Assert.fail("Exception occured"); + } + verify(messageBufferMock, times(1)).release(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java new file mode 100644 index 00000000..9deef145 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.util.ByteBufUtils; + +/** + * @author madamjak + * + */ +public class OFDatagramPacketHandlerTest { + @Mock ChannelHandlerContext ctxMock; + @Mock SwitchConnectionHandler switchConnHandler; + @Mock MessageConsumer consumerMock; + @Mock Channel channelMock; + + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + when(ctxMock.channel()).thenReturn(channelMock); + } + + /** + * Test {@link OFDatagramPacketHandler} + */ + @Test + public void test(){ + OFDatagramPacketHandler handler = new OFDatagramPacketHandler(switchConnHandler); + byte version = EncodeConstants.OF13_VERSION_ID; + ByteBuf messageBuffer = ByteBufUtils.hexStringToByteBuf("04 02 00 08 01 02 03 04"); + InetSocketAddress recipientISA = InetSocketAddress.createUnresolved("localhost", 9876); + InetSocketAddress senderISA = InetSocketAddress.createUnresolved("192.168.15.24", 21021); + DatagramPacket datagramPacket = new DatagramPacket(messageBuffer, recipientISA, senderISA); + UdpConnectionMap.addConnection(datagramPacket.sender(), consumerMock); + List outList = new ArrayList<>(); + try { + handler.decode(ctxMock, datagramPacket, outList); + } catch (Exception e) { + Assert.fail("Wrong - Unexcepted exception occurred"); + } + VersionMessageUdpWrapper versionUdpWrapper = (VersionMessageUdpWrapper) outList.get(0); + Assert.assertEquals("Wrong - incorrect version has been decoded",version, versionUdpWrapper.getVersion()); + Assert.assertEquals("Wrong - sender addresses are different", senderISA, versionUdpWrapper.getAddress()); + messageBuffer.readerIndex(1); + Assert.assertEquals("Wrong - undecoded part of input ByteBuff is differnt to output",0, messageBuffer.compareTo(versionUdpWrapper.getMessageBuffer())); + } +} From 1e5b182b168c869278dd5dd7dbe35d824f22da06 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 09:02:32 +0200 Subject: [PATCH 081/285] EnhancedMessageTypeKey add hash(), ChannelOutboundQueue change address to final and modify constructor Change-Id: I732e81ff1949a8f9a9c4aa42579d20287faf5e03 Signed-off-by: Marian Adamjak --- .../api/extensibility/EnhancedMessageTypeKey.java | 10 +++++++++- .../protocol/impl/connection/ChannelOutboundQueue.java | 9 +++------ .../impl/connection/ConnectionAdapterImpl.java | 3 +-- .../impl/connection/ChannelOutboundQueueTest.java | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index a2157210..d2ce5a91 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -28,6 +28,14 @@ public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgTy this.msgType2 = msgType2; } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); + return result; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -55,4 +63,4 @@ public boolean equals(Object obj) { public String toString() { return super.toString() + " msgType2: " + msgType2.getName(); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java index 6937a1fb..cc7abcae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java @@ -96,9 +96,9 @@ public void run() { private final Queue> queue; private final long maxWorkTime; private final Channel channel; - private InetSocketAddress address; + private final InetSocketAddress address; - public ChannelOutboundQueue(final Channel channel, final int queueDepth) { + public ChannelOutboundQueue(final Channel channel, final int queueDepth, final InetSocketAddress address) { Preconditions.checkArgument(queueDepth > 0, "Queue depth has to be positive"); /* @@ -110,6 +110,7 @@ public ChannelOutboundQueue(final Channel channel, final int queueDepth) { this.queue = new LinkedBlockingQueue<>(queueDepth); this.channel = Preconditions.checkNotNull(channel); this.maxWorkTime = TimeUnit.MICROSECONDS.toNanos(DEFAULT_WORKTIME_MICROS); + this.address = address; } /** @@ -276,8 +277,4 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { public String toString() { return String.format("Channel %s queue [%s messages flushing=%s]", channel, queue.size(), flushScheduled); } - - public void setAddress(InetSocketAddress address) { - this.address = address; - } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 19baa930..33b600f9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -130,8 +130,7 @@ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress addr .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); this.channel = Preconditions.checkNotNull(channel); - this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH); - output.setAddress(address); + this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); channel.pipeline().addLast(output); LOG.debug("ConnectionAdapter created"); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java index 060072d5..7017eae2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java @@ -35,7 +35,7 @@ public ChannelOutboundQueueTest() { */ @Test(expected=IllegalArgumentException.class) public void testIncorrectQueueCreation() { - new ChannelOutboundQueue(channel, 0); + new ChannelOutboundQueue(channel, 0, null); } /** @@ -43,7 +43,7 @@ public void testIncorrectQueueCreation() { */ @Test public void testEnqueue() { - ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1); + ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); boolean enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); Assert.assertTrue("Enqueue problem", enqueued); enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); From cc0ff9a6faefd0e3a863ba17a2440454433af9f5 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 09:25:43 +0200 Subject: [PATCH 082/285] Change local names of local variables in FeaturesReplyMessageFactory and OxmIpv6ExtHdrDeserializer Change-Id: Id55fae5958725e9526f9a5633f8ea7fde8ac9c5b Signed-off-by: Marian Adamjak --- .../FeaturesReplyMessageFactory.java | 18 ++++++++--------- .../match/OxmIpv6ExtHdrDeserializer.java | 20 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java index d7991eb9..b599c208 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactory.java @@ -45,15 +45,15 @@ public GetFeaturesOutput deserialize(ByteBuf rawMessage) { } private static Capabilities createCapabilities(long input) { - final Boolean FLOW_STATS = (input & (1 << 0)) != 0; - final Boolean TABLE_STATS = (input & (1 << 1)) != 0; - final Boolean PORT_STATS = (input & (1 << 2)) != 0; - final Boolean GROUP_STATS = (input & (1 << 3)) != 0; - final Boolean IP_REASM = (input & (1 << 5)) != 0; - final Boolean QUEUE_STATS = (input & (1 << 6)) != 0; - final Boolean PORT_BLOCKED = (input & (1 << 8)) != 0; - return new Capabilities(FLOW_STATS, GROUP_STATS, IP_REASM, - PORT_BLOCKED, PORT_STATS, QUEUE_STATS, TABLE_STATS); + final Boolean flowStats = (input & (1 << 0)) != 0; + final Boolean tableStats = (input & (1 << 1)) != 0; + final Boolean portStats = (input & (1 << 2)) != 0; + final Boolean groupStats = (input & (1 << 3)) != 0; + final Boolean ipReasm = (input & (1 << 5)) != 0; + final Boolean queueStats = (input & (1 << 6)) != 0; + final Boolean portBlocked = (input & (1 << 8)) != 0; + return new Capabilities(flowStats, groupStats, ipReasm, + portBlocked, portStats, queueStats, tableStats); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index e4925d47..26f7f839 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -42,16 +42,16 @@ private static void addIpv6ExtHdrAugmentation(ByteBuf input, MatchEntriesBuilder builder) { PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); int bitmap = input.readUnsignedShort(); - final Boolean NONEXT = ((bitmap) & (1<<0)) != 0; - final Boolean ESP = ((bitmap) & (1<<1)) != 0; - final Boolean AUTH = ((bitmap) & (1<<2)) != 0; - final Boolean DEST = ((bitmap) & (1<<3)) != 0; - final Boolean FRAG = ((bitmap) & (1<<4)) != 0; - final Boolean ROUTER = ((bitmap) & (1<<5)) != 0; - final Boolean HOP = ((bitmap) & (1<<6)) != 0; - final Boolean UNREP = ((bitmap) & (1<<7)) != 0; - final Boolean UNSEQ = ((bitmap) & (1<<8)) != 0; - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(AUTH, DEST, ESP, FRAG, HOP, NONEXT, ROUTER, UNREP, UNSEQ)); + final Boolean nonext = ((bitmap) & (1<<0)) != 0; + final Boolean esp = ((bitmap) & (1<<1)) != 0; + final Boolean auth = ((bitmap) & (1<<2)) != 0; + final Boolean dest = ((bitmap) & (1<<3)) != 0; + final Boolean frag = ((bitmap) & (1<<4)) != 0; + final Boolean router = ((bitmap) & (1<<5)) != 0; + final Boolean hop = ((bitmap) & (1<<6)) != 0; + final Boolean unrep = ((bitmap) & (1<<7)) != 0; + final Boolean unseq = ((bitmap) & (1<<8)) != 0; + pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); } From 2737285bf9dd37d501884a3aadce1d4ab118e8f3 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 14:31:50 +0200 Subject: [PATCH 083/285] BUG 2245 Fixed Local Variable Names Change-Id: Iae8a14c08d5a2d902a0be56bb0a1752132e0e3ab Signed-off-by: Marian Adamjak --- .../factories/FlowRemovedMessageFactory.java | 12 +++++----- .../OF10FlowRemovedMessageFactory.java | 12 +++++----- .../WriteMetadataInstructionDeserializer.java | 6 ++--- .../impl/util/OF10MatchDeserializer.java | 24 +++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java index 86a2d085..97a4390f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java @@ -48,12 +48,12 @@ public FlowRemovedMessage deserialize(ByteBuf rawMessage) { builder.setDurationNsec(rawMessage.readUnsignedInt()); builder.setIdleTimeout(rawMessage.readUnsignedShort()); builder.setHardTimeout(rawMessage.readUnsignedShort()); - byte[] packet_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(packet_count); - builder.setPacketCount(new BigInteger(1, packet_count)); - byte[] byte_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(byte_count); - builder.setByteCount(new BigInteger(1, byte_count)); + byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(packetCount); + builder.setPacketCount(new BigInteger(1, packetCount)); + byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(byteCount); + builder.setByteCount(new BigInteger(1, byteCount)); OFDeserializer matchDeserializer = registry.getDeserializer(new MessageCodeKey( EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); builder.setMatch(matchDeserializer.deserialize(rawMessage)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java index e048092d..18573f1b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java @@ -51,12 +51,12 @@ public FlowRemovedMessage deserialize(ByteBuf rawMessage) { builder.setDurationNsec(rawMessage.readUnsignedInt()); builder.setIdleTimeout(rawMessage.readUnsignedShort()); rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2); - byte[] packet_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(packet_count); - builder.setPacketCount(new BigInteger(1, packet_count)); - byte[] byte_count = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(byte_count); - builder.setByteCount(new BigInteger(1, byte_count)); + byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(packetCount); + builder.setPacketCount(new BigInteger(1, packetCount)); + byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(byteCount); + builder.setByteCount(new BigInteger(1, byteCount)); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index e92260e3..419dc974 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -35,9 +35,9 @@ public Instruction deserialize(ByteBuf input) { byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadata); metadataBuilder.setMetadata(metadata); - byte[] metadata_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadata_mask); - metadataBuilder.setMetadataMask(metadata_mask); + byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataMask); + metadataBuilder.setMetadataMask(metadataMask); builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index 93ff402d..645df95c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -69,18 +69,18 @@ public MatchV10 deserialize(final ByteBuf input) { * @return decoded FlowWildcardsV10 */ public static FlowWildcardsV10 createWildcards(final long input) { - boolean _iNPORT = (input & (1 << 0)) != 0; - boolean _dLVLAN = (input & (1 << 1)) != 0; - boolean _dLSRC = (input & (1 << 2)) != 0; - boolean _dLDST = (input & (1 << 3)) != 0; - boolean _dLTYPE = (input & (1 << 4)) != 0; - boolean _nWPROTO = (input & (1 << 5)) != 0; - boolean _tPSRC = (input & (1 << 6)) != 0; - boolean _tPDST = (input & (1 << 7)) != 0; - boolean _dLVLANPCP = (input & (1 << 20)) != 0; - boolean _nWTOS = (input & (1 << 21)) != 0; - return new FlowWildcardsV10(_dLDST, _dLSRC, _dLTYPE, _dLVLAN, - _dLVLANPCP, _iNPORT, _nWPROTO, _nWTOS, _tPDST, _tPSRC); + boolean inPort = (input & (1 << 0)) != 0; + boolean dlVLAN = (input & (1 << 1)) != 0; + boolean dlSrc = (input & (1 << 2)) != 0; + boolean dlDst = (input & (1 << 3)) != 0; + boolean dLType = (input & (1 << 4)) != 0; + boolean nwProto = (input & (1 << 5)) != 0; + boolean tpSrc = (input & (1 << 6)) != 0; + boolean tpDst = (input & (1 << 7)) != 0; + boolean dlVLANpcp = (input & (1 << 20)) != 0; + boolean nwTos = (input & (1 << 21)) != 0; + return new FlowWildcardsV10(dlDst, dlSrc, dLType, dlVLAN, + dlVLANpcp, inPort, nwProto, nwTos, tpDst, tpSrc); } /** From 1c2f495ce4f332cb348a2f13f9d128c9dc65d6f9 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 15:05:23 +0200 Subject: [PATCH 084/285] BUG 2245 - Fixed Loose coupling Change-Id: I0328d47b3817b4c8aa1f64e81b1e1aea304e97c0 Signed-off-by: Marian Adamjak --- .../openflowjava/protocol/impl/core/UdpConnectionMap.java | 3 ++- .../serialization/match/AbstractOxmIpv6AddressSerializer.java | 2 +- ...atchSerializerTest2.java => OF13MatchSerializer02Test.java} | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/{OF13MatchSerializerTest2.java => OF13MatchSerializer02Test.java} (98%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index ce6d17f0..3c048f67 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -10,6 +10,7 @@ import java.net.InetSocketAddress; import java.util.HashMap; +import java.util.Map; import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; @@ -21,7 +22,7 @@ */ public class UdpConnectionMap { - private static HashMap connectionMap = new HashMap<>(); + private static Map connectionMap = new HashMap<>(); /** * @param address sender's address diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index 63b6f42e..c83f9d90 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -44,7 +44,7 @@ public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { writeMask(entry, outBuffer, getValueLength()); } - private static List parseIpv6Address(final ArrayList addressGroups) { + private static List parseIpv6Address(final List addressGroups) { int countEmpty = 0; for (String group : addressGroups) { if (group.equals("")) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java similarity index 98% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index e7f1e8d3..6ed7c7e7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest2.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -128,7 +128,7 @@ * @author michal.polkorab * */ -public class OF13MatchSerializerTest2 { +public class OF13MatchSerializer02Test { private SerializerRegistry registry; private OFSerializer matchSerializer; From 18e5637eab1a2d99c0000de5f4a2642a8ec9a8b0 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 23 Oct 2014 12:33:30 +0200 Subject: [PATCH 085/285] Bug 2245 - Fixed 'Unused formal parameter' Change-Id: I4feaab675be5cd3459e1f0907c4dffa73da37a32 Signed-off-by: Michal Polkorab --- .../connection/ConnectionAdapterImpl.java | 10 ++----- .../MultipartRequestInputFactory.java | 30 ++++++++----------- .../OF10StatsRequestInputFactory.java | 10 +++---- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 33b600f9..62339ae8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -246,10 +246,7 @@ public Future disconnect() { responseCache.invalidateAll(); disconnectOccured = true; - String failureInfo = "switch disconnecting failed"; - ErrorSeverity errorSeverity = ErrorSeverity.ERROR; - String message = "Check the switch connection"; - return handleTransportChannelFuture(disconnectResult, failureInfo, errorSeverity, message); + return handleTransportChannelFuture(disconnectResult); } @Override @@ -376,8 +373,7 @@ private ListenableFuture handleTransportChannelFuture( - final ChannelFuture resultFuture, final String failureInfo, - final ErrorSeverity errorSeverity, final String message) { + final ChannelFuture resultFuture) { final SettableFuture transportResult = SettableFuture.create(); @@ -482,4 +478,4 @@ public InetSocketAddress getRemoteAddress() { public void setResponseCache(Cache> cache) { this.responseCache = cache; } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 2170eaf2..29dd683c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -106,13 +106,13 @@ public void serialize(final MultipartRequestInput message, final ByteBuf outBuff outBuffer.writeZero(PADDING_IN_MULTIPART_REQUEST_MESSAGE); if (message.getMultipartRequestBody() instanceof MultipartRequestDescCase){ - serializeDescBody(message.getMultipartRequestBody(), outBuffer); + serializeDescBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlowCase) { serializeFlowBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregateCase) { serializeAggregateBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestTableCase) { - serializeTableBody(message.getMultipartRequestBody(), outBuffer); + serializeTableBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStatsCase) { serializePortStatsBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueueCase) { @@ -120,19 +120,19 @@ public void serialize(final MultipartRequestInput message, final ByteBuf outBuff } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupCase) { serializeeGroupStatsBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupDescCase) { - serializeGroupDescBody(message.getMultipartRequestBody(), outBuffer); + serializeGroupDescBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestGroupFeaturesCase) { - serializeGroupFeaturesBody(message.getMultipartRequestBody(), outBuffer); + serializeGroupFeaturesBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterCase) { serializeMeterBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterConfigCase) { serializeMeterConfigBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestMeterFeaturesCase) { - serializeMeterFeaturesBody(message.getMultipartRequestBody(), outBuffer); + serializeMeterFeaturesBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestTableFeaturesCase) { serializeTableFeaturesBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortDescCase) { - serializePortDescBody(message.getMultipartRequestBody(), outBuffer); + serializePortDescBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestExperimenterCase) { serializeExperimenterBody(message, outBuffer); } @@ -159,8 +159,7 @@ private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlag * @param multipartRequestBody * @param output */ - private void serializeDescBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf output) { + private void serializeDescBody() { // The body of MultiPartRequestDesc is empty } @@ -168,8 +167,7 @@ private void serializeDescBody(final MultipartRequestBody multipartRequestBody, * @param multipartRequestBody * @param out */ - private void serializeTableBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf out) { + private void serializeTableBody() { // The body of MultiPartTable is empty } @@ -177,8 +175,7 @@ private void serializeTableBody(final MultipartRequestBody multipartRequestBody, * @param multipartRequestBody * @param out */ - private void serializeGroupDescBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf out) { + private void serializeGroupDescBody() { // The body of MultiPartRequestGroupDesc is empty } @@ -186,8 +183,7 @@ private void serializeGroupDescBody(final MultipartRequestBody multipartRequestB * @param multipartRequestBody * @param out */ - private void serializeGroupFeaturesBody( - final MultipartRequestBody multipartRequestBody, final ByteBuf out) { + private void serializeGroupFeaturesBody() { // The body of MultiPartRequestGroupFeatures is empty } @@ -195,8 +191,7 @@ private void serializeGroupFeaturesBody( * @param multipartRequestBody * @param out */ - private void serializeMeterFeaturesBody( - final MultipartRequestBody multipartRequestBody, final ByteBuf out) { + private void serializeMeterFeaturesBody() { // The body of MultiPartMeterFeatures is empty } @@ -204,8 +199,7 @@ private void serializeMeterFeaturesBody( * @param multipartRequestBody * @param out */ - private void serializePortDescBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf out) { + private void serializePortDescBody() { // The body of MultiPartPortDesc is empty } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 98f93b45..aa8fcbd2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -55,13 +55,13 @@ public void serialize(final MultipartRequestInput message, final ByteBuf outBuff outBuffer.writeShort(message.getType().getIntValue()); outBuffer.writeShort(createMultipartRequestFlagsBitmask(message.getFlags())); if (message.getMultipartRequestBody() instanceof MultipartRequestDescCase) { - serializeDescBody(message.getMultipartRequestBody(), outBuffer); + serializeDescBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestFlowCase) { serializeFlowBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestAggregateCase) { serializeAggregateBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestTableCase) { - serializeTableBody(message.getMultipartRequestBody(), outBuffer); + serializeTableBody(); } else if (message.getMultipartRequestBody() instanceof MultipartRequestPortStatsCase) { serializePortBody(message.getMultipartRequestBody(), outBuffer); } else if (message.getMultipartRequestBody() instanceof MultipartRequestQueueCase) { @@ -80,8 +80,7 @@ private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlag * @param multipartRequestBody * @param output */ - private void serializeDescBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf output) { + private void serializeDescBody() { // The body of MultiPartRequestDesc is empty } @@ -89,8 +88,7 @@ private void serializeDescBody(final MultipartRequestBody multipartRequestBody, * @param multipartRequestBody * @param out */ - private void serializeTableBody(final MultipartRequestBody multipartRequestBody, - final ByteBuf out) { + private void serializeTableBody() { // The body of MultiPartTable is empty } From 6171c2a379f5397ce23f2ec1a570d05812ae918b Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 23 Oct 2014 12:33:30 +0200 Subject: [PATCH 086/285] Bug 2245 - Fixed 'Hide Utility Class Constructor' - also fixed 'Method Type(Generic) Parameter Name' Change-Id: I4323326dba8a371c65a5d9c1bfeefe867dbcbd4e Signed-off-by: Michal Polkorab --- .../protocol/api/extensibility/DeserializerRegistry.java | 4 ++-- .../api/extensibility/SerializerExtensionProvider.java | 4 ++-- .../protocol/api/extensibility/SerializerRegistry.java | 8 ++++---- .../openflowjava/protocol/impl/core/SslKeyStore.java | 4 ++++ .../openflowjava/protocol/impl/core/UdpConnectionMap.java | 6 +++++- .../deserialization/ActionDeserializerInitializer.java | 6 +++++- .../impl/deserialization/DeserializerRegistryImpl.java | 2 +- .../InstructionDeserializerInitializer.java | 6 +++++- .../MatchEntryDeserializerInitializer.java | 6 +++++- ...itializer.java => MessageDeserializerInitializer.java} | 6 +++++- .../impl/deserialization/TypeToClassMapInitializer.java | 6 +++++- .../impl/deserialization/match/OxmMaskDeserializer.java | 6 +++++- .../protocol/impl/serialization/ActionsInitializer.java | 6 +++++- .../impl/serialization/InstructionsInitializer.java | 6 +++++- .../impl/serialization/MatchEntriesInitializer.java | 6 +++++- .../impl/serialization/MessageFactoryInitializer.java | 6 +++++- .../openflowjava/protocol/impl/util/ActionConstants.java | 5 ++++- .../protocol/impl/util/InstructionConstants.java | 6 +++++- .../openflowjava/protocol/impl/util/ListDeserializer.java | 6 +++++- .../protocol/impl/clients/ClientSslContextFactory.java | 5 ++++- .../protocol/impl/clients/ClientSslKeyStore.java | 4 ++++ .../protocol/impl/clients/ClientSslTrustStore.java | 4 ++++ .../protocol/impl/clients/ScenarioFactory.java | 6 +++++- 23 files changed, 99 insertions(+), 25 deletions(-) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/{MessageDerializerInitializer.java => MessageDeserializerInitializer.java} (96%) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 26ac8c8b..eeeac0a4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -23,8 +23,8 @@ public interface DeserializerRegistry { * @param key used for deserializer lookup * @return deserializer found */ - public - SERIALIZER_TYPE getDeserializer(MessageCodeKey key); + public + SERIALIZERTYPE getDeserializer(MessageCodeKey key); /** * Registers deserializer. diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 422a1500..9bbc85c3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -63,8 +63,8 @@ public void registerInstructionSerializer(ExperimenterInstructionSerializerKey k * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerMatchEntrySerializer( - MatchEntrySerializerKey key,OFGeneralSerializer serializer); + public void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); /** * Registers experimenter (vendor) message serializer diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 388338e2..a53faa5c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -26,8 +26,8 @@ public interface SerializerRegistry { * @param msgTypeKey lookup key * @return serializer or NullPointerException if no serializer was found */ - public SERIALIZER_TYPE - getSerializer(MessageTypeKey msgTypeKey); + public SERIALIZERTYPE + getSerializer(MessageTypeKey msgTypeKey); /** * Registers serializer @@ -40,7 +40,7 @@ public interface SerializerRegistry { * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerSerializer(MessageTypeKey key, + public void registerSerializer(MessageTypeKey key, OFGeneralSerializer serializer); /** @@ -50,5 +50,5 @@ public void registerSerializer(MessageTypeKey key, * @return true if serializer was removed, * false if no serializer was found under specified key */ - public boolean unregisterSerializer(MessageTypeKey key); + public boolean unregisterSerializer(MessageTypeKey key); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java index 25c2e0b2..983a03e9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java @@ -26,6 +26,10 @@ public final class SslKeyStore { private static final Logger LOGGER = LoggerFactory.getLogger(SslKeyStore.class); + private SslKeyStore() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + /** * InputStream instance of key - key location is on classpath * @param filename keystore location diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index 3c048f67..aeb73056 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -20,10 +20,14 @@ * @author michal.polkorab */ -public class UdpConnectionMap { +public final class UdpConnectionMap { private static Map connectionMap = new HashMap<>(); + private UdpConnectionMap() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + /** * @param address sender's address * @return corresponding MessageConsumer diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index e641ee93..cbec7394 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -44,7 +44,11 @@ * @author michal.polkorab * */ -public class ActionDeserializerInitializer { +public final class ActionDeserializerInitializer { + + private ActionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers action deserializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index f36b684f..5c7ad39c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -39,7 +39,7 @@ public class DeserializerRegistryImpl implements DeserializerRegistry { public void init() { registry = new HashMap<>(); // register message deserializers - MessageDerializerInitializer.registerMessageDeserializers(this); + MessageDeserializerInitializer.registerMessageDeserializers(this); // register common structure deserializers registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java index a09f5147..9fcfd4d6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java @@ -22,7 +22,11 @@ * @author michal.polkorab * */ -public class InstructionDeserializerInitializer { +public final class InstructionDeserializerInitializer { + + private InstructionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers instruction deserializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index fe15b917..28f87a4c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -59,7 +59,11 @@ * @author michal.polkorab * */ -public class MatchEntryDeserializerInitializer { +public final class MatchEntryDeserializerInitializer { + + private MatchEntryDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers match entry deserializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java similarity index 96% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index e45da36f..525f5297 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDerializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -55,7 +55,11 @@ * @author michal.polkorab * */ -public class MessageDerializerInitializer { +public final class MessageDeserializerInitializer { + + private MessageDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers message deserializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 017e2454..213723c1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -31,7 +31,11 @@ * @author michal.polkorab * */ -public class TypeToClassMapInitializer { +public final class TypeToClassMapInitializer { + + private TypeToClassMapInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Initializes type to class map diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java index d4246fd2..728d42fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java @@ -17,7 +17,11 @@ * @author michal.polkorab * */ -public class OxmMaskDeserializer { +public final class OxmMaskDeserializer { + + private OxmMaskDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Appends mask to match entry (match entry builder) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index 818a842b..d3e74b5c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -70,7 +70,11 @@ * Initializes serializer registry with action serializers * @author michal.polkorab */ -public class ActionsInitializer { +public final class ActionsInitializer { + + private ActionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers action serializers into provided registry diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java index 09bfe0ce..f60898ed 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java @@ -28,7 +28,11 @@ * @author michal.polkorab * */ -public class InstructionsInitializer { +public final class InstructionsInitializer { + + private InstructionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers instruction serializers into provided registry diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 50827a77..4889fcbd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -103,7 +103,11 @@ * Initializes serializer registry with match entry serializers * @author michal.polkorab */ -public class MatchEntriesInitializer { +public final class MatchEntriesInitializer { + + private MatchEntriesInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers match entry serializers into provided registry diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 094b4fde..70db90be 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -60,7 +60,11 @@ * @author michal.polkorab * */ -public class MessageFactoryInitializer { +public final class MessageFactoryInitializer { + + private MessageFactoryInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Registers message serializers into provided registry diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java index d09d2dd5..cb7b051e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java @@ -12,7 +12,7 @@ * @author michal.polkorab * */ -public class ActionConstants { +public final class ActionConstants { /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ public static final byte OUTPUT_CODE = 0; @@ -101,4 +101,7 @@ public class ActionConstants { /** Action header size */ public static final byte ACTION_IDS_LENGTH = 4; + private ActionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java index 8e0ae6ec..2476c4e9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java @@ -12,7 +12,7 @@ * @author michal.polkorab * */ -public class InstructionConstants { +public final class InstructionConstants { /** Openflow v1.3 OFPIT_GOTO_TABLE code */ public static final byte GOTO_TABLE_TYPE = 1; @@ -41,4 +41,8 @@ public class InstructionConstants { public static final byte WRITE_METADATA_LENGTH = 24; /** Openflow v1.3 header length (only type and length fields) */ public static final byte INSTRUCTION_IDS_LENGTH = 4; + + private InstructionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index 160f3be5..6e32f86f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -22,7 +22,11 @@ * @author michal.polkorab * */ -public class ListDeserializer { +public final class ListDeserializer { + + private ListDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Deserializes items into list diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java index c1199c1e..a6d93aba 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java @@ -22,7 +22,10 @@ */ public final class ClientSslContextFactory { - + private ClientSslContextFactory() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + // "TLS" - supports some version of TLS // Use "TLSv1", "TLSv1.1", "TLSv1.2" for specific TLS version private static final String PROTOCOL = "TLS"; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java index 279072fa..233b1c11 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java @@ -19,6 +19,10 @@ public final class ClientSslKeyStore { private static final String filename = "/selfSignedSwitch"; + private ClientSslKeyStore() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + /** * InputStream instance of key * diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java index 1379c8dd..c346ba1e 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java @@ -19,6 +19,10 @@ public final class ClientSslTrustStore { private static final String filename = "/selfSignedController"; + private ClientSslTrustStore() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + /** * InputStream instance of key * diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 318d7226..264bedfd 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -17,7 +17,11 @@ * * @author michal.polkorab */ -public class ScenarioFactory { +public final class ScenarioFactory { + + private ScenarioFactory() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } /** * Creates stack with handshake needed messages. From 2e1513dc13aabdfde86e71a9ddbe1352c657a0ff Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 14:03:26 +0200 Subject: [PATCH 087/285] BUG-2245 Sonar technical debt - correct Local Final Variable Name Change-Id: I4fde8e15edc8893fd9871a268465eb39da5b92b9 Signed-off-by: Marian Adamjak --- .../MultipartReplyMessageFactory.java | 144 +++++++++--------- .../OF10FeaturesReplyMessageFactory.java | 52 +++---- .../factories/PortStatusMessageFactory.java | 54 +++---- .../protocol/impl/util/OpenflowUtils.java | 62 ++++---- 4 files changed, 156 insertions(+), 156 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 20d7eda2..19f7a38e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -295,12 +295,12 @@ private MultipartReplyFlowCase setFlow(ByteBuf input) { } private static FlowModFlags createFlowModFlagsFromBitmap(int input){ - final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) != 0; - final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) != 0; - final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) != 0; - final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) != 0; - final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) != 0; - return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM); + final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0; + final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0; + final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0; + final Boolean fmfNOPKTCOUNTS = (input & (1 << 3)) != 0; + final Boolean fmfNOBYTCOUNTS = (input & (1 << 4)) != 0; + return new FlowModFlags(fmfCHECKOVERLAP, fmfNOBYTCOUNTS, fmfNOPKTCOUNTS, fmfRESETCOUNTS, fmfSENDFLOWREM); } private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { @@ -580,17 +580,17 @@ private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { } private static MeterFlags createMeterFlags(long input){ - final Boolean _oFPMFKBPS = (input & (1 << 0)) != 0; - final Boolean _oFPMFPKTPS = (input & (1 << 1)) != 0; - final Boolean _oFPMFBURST = (input & (1 << 2)) != 0; - final Boolean _oFPMFSTATS = (input & (1 << 3)) != 0; - return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS); + final Boolean mfKBPS = (input & (1 << 0)) != 0; + final Boolean mfPKTPS = (input & (1 << 1)) != 0; + final Boolean mfBURST = (input & (1 << 2)) != 0; + final Boolean mfSTATS = (input & (1 << 3)) != 0; + return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS); } private static MeterBandTypeBitmap createMeterBandsBitmap(long input) { - final Boolean _oFPMBTDROP = (input & (1 << 1)) != 0; - final Boolean _oFPMBTDSCPREMARK = (input & (1 << 2)) != 0; - return new MeterBandTypeBitmap(_oFPMBTDROP, _oFPMBTDSCPREMARK); + final Boolean mbtDROP = (input & (1 << 1)) != 0; + final Boolean mbtDSCPREMARK = (input & (1 << 2)) != 0; + return new MeterBandTypeBitmap(mbtDROP, mbtDSCPREMARK); } private static MultipartReplyMeterCase setMeter(ByteBuf input) { @@ -727,39 +727,39 @@ private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { } private static PortConfig createPortConfig(long input){ - final Boolean _portDown = ((input) & (1<<0)) != 0; - final Boolean _noRecv = ((input) & (1<<2)) != 0; - final Boolean _noFwd = ((input) & (1<<5)) != 0; - final Boolean _noPacketIn = ((input) & (1<<6)) != 0; - return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown); + final Boolean pcPortDown = ((input) & (1<<0)) != 0; + final Boolean pcNRecv = ((input) & (1<<2)) != 0; + final Boolean pcNFwd = ((input) & (1<<5)) != 0; + final Boolean pcNPacketIn = ((input) & (1<<6)) != 0; + return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } private static PortState createPortState(long input){ - final Boolean _linkDown = ((input) & (1<<0)) != 0; - final Boolean _blocked = ((input) & (1<<1)) != 0; - final Boolean _live = ((input) & (1<<2)) != 0; - return new PortState(_blocked, _linkDown, _live); + final Boolean psLinkDown = ((input) & (1<<0)) != 0; + final Boolean psBlocked = ((input) & (1<<1)) != 0; + final Boolean psLive = ((input) & (1<<2)) != 0; + return new PortState(psBlocked, psLinkDown, psLive); } private static PortFeatures createPortFeatures(long input){ - final Boolean _10mbHd = ((input) & (1<<0)) != 0; - final Boolean _10mbFd = ((input) & (1<<1)) != 0; - final Boolean _100mbHd = ((input) & (1<<2)) != 0; - final Boolean _100mbFd = ((input) & (1<<3)) != 0; - final Boolean _1gbHd = ((input) & (1<<4)) != 0; - final Boolean _1gbFd = ((input) & (1<<5)) != 0; - final Boolean _10gbFd = ((input) & (1<<6)) != 0; - final Boolean _40gbFd = ((input) & (1<<7)) != 0; - final Boolean _100gbFd = ((input) & (1<<8)) != 0; - final Boolean _1tbFd = ((input) & (1<<9)) != 0; - final Boolean _other = ((input) & (1<<10)) != 0; - final Boolean _copper = ((input) & (1<<11)) != 0; - final Boolean _fiber = ((input) & (1<<12)) != 0; - final Boolean _autoneg = ((input) & (1<<13)) != 0; - final Boolean _pause = ((input) & (1<<14)) != 0; - final Boolean _pauseAsym = ((input) & (1<<15)) != 0; - return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, - _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym); + final Boolean pf10mbHd = ((input) & (1<<0)) != 0; + final Boolean pf10mbFd = ((input) & (1<<1)) != 0; + final Boolean pf100mbHd = ((input) & (1<<2)) != 0; + final Boolean pf100mbFd = ((input) & (1<<3)) != 0; + final Boolean pf1gbHd = ((input) & (1<<4)) != 0; + final Boolean pf1gbFd = ((input) & (1<<5)) != 0; + final Boolean pf10gbFd = ((input) & (1<<6)) != 0; + final Boolean pf40gbFd = ((input) & (1<<7)) != 0; + final Boolean pf100gbFd = ((input) & (1<<8)) != 0; + final Boolean pf1tbFd = ((input) & (1<<9)) != 0; + final Boolean pfOther = ((input) & (1<<10)) != 0; + final Boolean pfCopper = ((input) & (1<<11)) != 0; + final Boolean pfFiber = ((input) & (1<<12)) != 0; + final Boolean pfAutoneg = ((input) & (1<<13)) != 0; + final Boolean pfPause = ((input) & (1<<14)) != 0; + final Boolean pfPauseAsym = ((input) & (1<<15)) != 0; + return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, + pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); } private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) { @@ -782,43 +782,43 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa } private static ActionType createActionBitmap(long input) { - final Boolean OFPAT_OUTPUT = ((input) & (1<<0)) != 0; - final Boolean OFPAT_COPY_TTL_OUT = ((input) & (1<<11)) != 0; - final Boolean OFPAT_COPY_TTL_IN = ((input) & (1<<12)) != 0; - final Boolean OFPAT_SET_MPLS_TTL = ((input) & (1<<15)) != 0; - final Boolean OFPAT_DEC_MPLS_TTL = ((input) & (1<<16)) != 0; - final Boolean OFPAT_PUSH_VLAN = ((input) & (1<<17)) != 0; - final Boolean OFPAT_POP_VLAN = ((input) & (1<<18)) != 0; - final Boolean OFPAT_PUSH_MPLS = ((input) & (1<<19)) != 0; - final Boolean OFPAT_POP_MPLS = ((input) & (1<<20)) != 0; - final Boolean OFPAT_SET_QUEUE = ((input) & (1<<21)) != 0; - final Boolean OFPAT_GROUP = ((input) & (1<<22)) != 0; - final Boolean OFPAT_SET_NW_TTL = ((input) & (1<<23)) != 0; - final Boolean OFPAT_DEC_NW_TTL = ((input) & (1<<24)) != 0; - final Boolean OFPAT_SET_FIELD = ((input) & (1<<25)) != 0; - final Boolean OFPAT_PUSH_PBB = ((input) & (1<<26)) != 0; - final Boolean OFPAT_POP_PBB = ((input) & (1<<27)) != 0; - final Boolean OFPAT_EXPERIMENTER = false; - return new ActionType(OFPAT_COPY_TTL_IN, OFPAT_COPY_TTL_OUT, OFPAT_DEC_MPLS_TTL, - OFPAT_DEC_NW_TTL, OFPAT_EXPERIMENTER, OFPAT_GROUP, OFPAT_OUTPUT, OFPAT_POP_MPLS, - OFPAT_POP_PBB, OFPAT_POP_VLAN, OFPAT_PUSH_MPLS, OFPAT_PUSH_PBB, OFPAT_PUSH_VLAN, - OFPAT_SET_FIELD, OFPAT_SET_MPLS_TTL, OFPAT_SET_NW_TTL, OFPAT_SET_QUEUE); + final Boolean atOutput = ((input) & (1<<0)) != 0; + final Boolean atCopyTTLout = ((input) & (1<<11)) != 0; + final Boolean atCopyTTLin = ((input) & (1<<12)) != 0; + final Boolean atSetMplsTTL = ((input) & (1<<15)) != 0; + final Boolean atDecMplsTTL = ((input) & (1<<16)) != 0; + final Boolean atPushVLAN = ((input) & (1<<17)) != 0; + final Boolean atPopVLAN = ((input) & (1<<18)) != 0; + final Boolean atPushMPLS = ((input) & (1<<19)) != 0; + final Boolean atPopMPLS = ((input) & (1<<20)) != 0; + final Boolean atSetQueue = ((input) & (1<<21)) != 0; + final Boolean atGroup = ((input) & (1<<22)) != 0; + final Boolean atSetNWTTL = ((input) & (1<<23)) != 0; + final Boolean atDecNWTTL = ((input) & (1<<24)) != 0; + final Boolean atSetField = ((input) & (1<<25)) != 0; + final Boolean atPushPBB = ((input) & (1<<26)) != 0; + final Boolean atPopPBB = ((input) & (1<<27)) != 0; + final Boolean atExperimenter = false; + return new ActionType(atCopyTTLin, atCopyTTLout, atDecMplsTTL, + atDecNWTTL, atExperimenter, atGroup, atOutput, atPopMPLS, + atPopPBB, atPopVLAN, atPushMPLS, atPushPBB, atPushVLAN, + atSetField, atSetMplsTTL, atSetNWTTL, atSetQueue); } private static GroupCapabilities createCapabilities(long input) { - final Boolean OFOFPGFC_SELECT_WEIGHT = ((input) & (1<<0)) != 0; - final Boolean OFPGFC_SELECT_LIVENESS = ((input) & (1<<1)) != 0; - final Boolean OFPGFC_CHAINING = ((input) & (1<<2)) != 0; - final Boolean OFPGFC_CHAINING_CHECKS = ((input) & (1<<3)) != 0; - return new GroupCapabilities(OFPGFC_CHAINING, OFPGFC_CHAINING_CHECKS, OFPGFC_SELECT_LIVENESS, OFOFPGFC_SELECT_WEIGHT); + final Boolean gcSelectWeight = ((input) & (1<<0)) != 0; + final Boolean gcSelectLiveness = ((input) & (1<<1)) != 0; + final Boolean gcChaining = ((input) & (1<<2)) != 0; + final Boolean gcChainingChecks = ((input) & (1<<3)) != 0; + return new GroupCapabilities(gcChaining, gcChainingChecks, gcSelectLiveness, gcSelectWeight); } private static GroupTypes createGroupType(long input) { - final Boolean OFPGT_ALL = ((input) & (1<<0)) != 0; - final Boolean OFPGT_SELECT = ((input) & (1<<1)) != 0; - final Boolean OFPGT_INDIRECT = ((input) & (1<<2)) != 0; - final Boolean OFPGT_FF = ((input) & (1<<3)) != 0; - return new GroupTypes(OFPGT_ALL, OFPGT_FF, OFPGT_INDIRECT, OFPGT_SELECT); + final Boolean gtAll = ((input) & (1<<0)) != 0; + final Boolean gtSelect = ((input) & (1<<1)) != 0; + final Boolean gtIndirect = ((input) & (1<<2)) != 0; + final Boolean gtFF = ((input) & (1<<3)) != 0; + return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect); } private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index 13da41f0..f8f967e4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -56,35 +56,35 @@ public GetFeaturesOutput deserialize(ByteBuf rawMessage) { } private static CapabilitiesV10 createCapabilitiesV10(long input) { - final Boolean FLOW_STATS = (input & (1 << 0)) != 0; - final Boolean TABLE_STATS = (input & (1 << 1)) != 0; - final Boolean PORT_STATS = (input & (1 << 2)) != 0; - final Boolean STP = (input & (1 << 3)) != 0; - final Boolean RESERVED = (input & (1 << 4)) != 0; - final Boolean IP_REASM = (input & (1 << 5)) != 0; - final Boolean QUEUE_STATS = (input & (1 << 6)) != 0; - final Boolean ARP_MATCH_IP = (input & (1 << 7)) != 0; - return new CapabilitiesV10(ARP_MATCH_IP, FLOW_STATS, IP_REASM, - PORT_STATS, QUEUE_STATS, RESERVED, STP, TABLE_STATS); + final Boolean flowStats = (input & (1 << 0)) != 0; + final Boolean tableStats = (input & (1 << 1)) != 0; + final Boolean portStats = (input & (1 << 2)) != 0; + final Boolean stp = (input & (1 << 3)) != 0; + final Boolean reserved = (input & (1 << 4)) != 0; + final Boolean ipReasm = (input & (1 << 5)) != 0; + final Boolean queueStats = (input & (1 << 6)) != 0; + final Boolean arpMatchIp = (input & (1 << 7)) != 0; + return new CapabilitiesV10(arpMatchIp, flowStats, ipReasm, + portStats, queueStats, reserved, stp, tableStats); } private static ActionTypeV10 createActionsV10(long input) { - final Boolean OUTPUT = (input & (1 << 0)) != 0; - final Boolean SET_VLAN_VID = (input & (1 << 1)) != 0; - final Boolean SET_VLAN_PCP = (input & (1 << 2)) != 0; - final Boolean STRIP_VLAN = (input & (1 << 3)) != 0; - final Boolean SET_DL_SRC = (input & (1 << 4)) != 0; - final Boolean SET_DL_DST = (input & (1 << 5)) != 0; - final Boolean SET_NW_SRC = (input & (1 << 6)) != 0; - final Boolean SET_NW_DST = (input & (1 << 7)) != 0; - final Boolean SET_NW_TOS = (input & (1 << 8)) != 0; - final Boolean SET_TP_SRC = (input & (1 << 9)) != 0; - final Boolean SET_TP_DST = (input & (1 << 10)) != 0; - final Boolean ENQUEUE = (input & (1 << 11)) != 0; - final Boolean VENDOR = (input & (1 << 12)) != 0; - return new ActionTypeV10(ENQUEUE, OUTPUT, SET_DL_DST, SET_DL_SRC, - SET_NW_DST, SET_NW_SRC, SET_NW_TOS, SET_TP_DST, SET_TP_SRC, - SET_VLAN_PCP, SET_VLAN_VID, STRIP_VLAN, VENDOR); + final Boolean output = (input & (1 << 0)) != 0; + final Boolean setVLANvid = (input & (1 << 1)) != 0; + final Boolean setVLANpcp = (input & (1 << 2)) != 0; + final Boolean stripVLAN = (input & (1 << 3)) != 0; + final Boolean setDLsrc = (input & (1 << 4)) != 0; + final Boolean setDLdst = (input & (1 << 5)) != 0; + final Boolean setNWsrc = (input & (1 << 6)) != 0; + final Boolean setNWdst = (input & (1 << 7)) != 0; + final Boolean setNWtos = (input & (1 << 8)) != 0; + final Boolean setTPsrc = (input & (1 << 9)) != 0; + final Boolean setTPdst = (input & (1 << 10)) != 0; + final Boolean enqueue = (input & (1 << 11)) != 0; + final Boolean vendor = (input & (1 << 12)) != 0; + return new ActionTypeV10(enqueue, output, setDLdst, setDLsrc, + setNWdst, setNWsrc, setNWtos, setTPdst, setTPsrc, + setVLANpcp, setVLANvid, stripVLAN, vendor); } private static PhyPort deserializePort(ByteBuf rawMessage) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index e204d762..5bd9cb32 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -58,38 +58,38 @@ public PortStatusMessage deserialize(ByteBuf rawMessage) { } private static PortFeatures createPortFeatures(long input){ - final Boolean _10mbHd = ((input) & (1<<0)) != 0; - final Boolean _10mbFd = ((input) & (1<<1)) != 0; - final Boolean _100mbHd = ((input) & (1<<2)) != 0; - final Boolean _100mbFd = ((input) & (1<<3)) != 0; - final Boolean _1gbHd = ((input) & (1<<4)) != 0; - final Boolean _1gbFd = ((input) & (1<<5)) != 0; - final Boolean _10gbFd = ((input) & (1<<6)) != 0; - final Boolean _40gbFd = ((input) & (1<<7)) != 0; - final Boolean _100gbFd = ((input) & (1<<8)) != 0; - final Boolean _1tbFd = ((input) & (1<<9)) != 0; - final Boolean _other = ((input) & (1<<10)) != 0; - final Boolean _copper = ((input) & (1<<11)) != 0; - final Boolean _fiber = ((input) & (1<<12)) != 0; - final Boolean _autoneg = ((input) & (1<<13)) != 0; - final Boolean _pause = ((input) & (1<<14)) != 0; - final Boolean _pauseAsym = ((input) & (1<<15)) != 0; - return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, - _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym); + final Boolean pf10mbHd = ((input) & (1<<0)) != 0; + final Boolean pf10mbFd = ((input) & (1<<1)) != 0; + final Boolean pf100mbHd = ((input) & (1<<2)) != 0; + final Boolean pf100mbFd = ((input) & (1<<3)) != 0; + final Boolean pf1gbHd = ((input) & (1<<4)) != 0; + final Boolean pf1gbFd = ((input) & (1<<5)) != 0; + final Boolean pf10gbFd = ((input) & (1<<6)) != 0; + final Boolean pf40gbFd = ((input) & (1<<7)) != 0; + final Boolean pf100gbFd = ((input) & (1<<8)) != 0; + final Boolean pf1tbFd = ((input) & (1<<9)) != 0; + final Boolean pfOther = ((input) & (1<<10)) != 0; + final Boolean pfCopper = ((input) & (1<<11)) != 0; + final Boolean pfFiber = ((input) & (1<<12)) != 0; + final Boolean pfAutoneg = ((input) & (1<<13)) != 0; + final Boolean pfPause = ((input) & (1<<14)) != 0; + final Boolean pfPauseAsym = ((input) & (1<<15)) != 0; + return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, + pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); } private static PortState createPortState(long input){ - final Boolean _linkDown = ((input) & (1<<0)) != 0; - final Boolean _blocked = ((input) & (1<<1)) != 0; - final Boolean _live = ((input) & (1<<2)) != 0; - return new PortState(_blocked, _linkDown, _live); + final Boolean psLinkDown = ((input) & (1<<0)) != 0; + final Boolean psBblocked = ((input) & (1<<1)) != 0; + final Boolean psLive = ((input) & (1<<2)) != 0; + return new PortState(psBblocked, psLinkDown, psLive); } private static PortConfig createPortConfig(long input){ - final Boolean _portDown = ((input) & (1<<0)) != 0; - final Boolean _noRecv = ((input) & (1<<2)) != 0; - final Boolean _noFwd = ((input) & (1<<5)) != 0; - final Boolean _noPacketIn = ((input) & (1<<6)) != 0; - return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown); + final Boolean pcPortDown = ((input) & (1<<0)) != 0; + final Boolean pcNoRecv = ((input) & (1<<2)) != 0; + final Boolean pcNoFwd = ((input) & (1<<5)) != 0; + final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; + return new PortConfig(pcNoFwd, pcNoPacketIn, pcNoRecv, pcPortDown); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java index 8ba8e74c..78f27eac 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -25,15 +25,15 @@ public abstract class OpenflowUtils { * @return port state */ public static PortStateV10 createPortState(long input){ - final Boolean _linkDown = ((input) & (1<<0)) != 0; - final Boolean _blocked = ((input) & (1<<1)) != 0; - final Boolean _live = ((input) & (1<<2)) != 0; - final Boolean _stpListen = ((input) & (1<<8)) == 0; - final Boolean _stpLearn = ((input) & (1<<8)) != 0; - final Boolean _stpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 - final Boolean _stpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 - final Boolean _stpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 - return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); + final Boolean psLinkDown = ((input) & (1<<0)) != 0; + final Boolean psBlocked = ((input) & (1<<1)) != 0; + final Boolean psLive = ((input) & (1<<2)) != 0; + final Boolean psStpListen = ((input) & (1<<8)) == 0; + final Boolean psStpLearn = ((input) & (1<<8)) != 0; + final Boolean psStpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 + final Boolean psStpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 + final Boolean psStpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 + return new PortStateV10(psBlocked, psLinkDown, psLive, psStpBlock, psStpForward, psStpLearn, psStpListen, psStpMask); } /** @@ -42,14 +42,14 @@ public static PortStateV10 createPortState(long input){ * @return port state */ public static PortConfigV10 createPortConfig(long input){ - final Boolean _portDown = ((input) & (1<<0)) != 0; - final Boolean _noStp = ((input) & (1<<1)) != 0; - final Boolean _noRecv = ((input) & (1<<2)) != 0; - final Boolean _noRecvStp = ((input) & (1<<3)) != 0; - final Boolean _noFlood = ((input) & (1<<4)) != 0; - final Boolean _noFwd = ((input) & (1<<5)) != 0; - final Boolean _noPacketIn = ((input) & (1<<6)) != 0; - return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); + final Boolean pcPortDown = ((input) & (1<<0)) != 0; + final Boolean pcNoStp = ((input) & (1<<1)) != 0; + final Boolean pcNoRecv = ((input) & (1<<2)) != 0; + final Boolean pcNoRecvStp = ((input) & (1<<3)) != 0; + final Boolean pcNoFlood = ((input) & (1<<4)) != 0; + final Boolean pcNoFwd = ((input) & (1<<5)) != 0; + final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; + return new PortConfigV10(pcNoFlood, pcNoFwd, pcNoPacketIn, pcNoRecv, pcNoRecvStp, pcNoStp, pcPortDown); } /** @@ -58,19 +58,19 @@ public static PortConfigV10 createPortConfig(long input){ * @return port state */ public static PortFeaturesV10 createPortFeatures(long input){ - final Boolean _10mbHd = ((input) & (1<<0)) != 0; - final Boolean _10mbFd = ((input) & (1<<1)) != 0; - final Boolean _100mbHd = ((input) & (1<<2)) != 0; - final Boolean _100mbFd = ((input) & (1<<3)) != 0; - final Boolean _1gbHd = ((input) & (1<<4)) != 0; - final Boolean _1gbFd = ((input) & (1<<5)) != 0; - final Boolean _10gbFd = ((input) & (1<<6)) != 0; - final Boolean _copper = ((input) & (1<<7)) != 0; - final Boolean _fiber = ((input) & (1<<8)) != 0; - final Boolean _autoneg = ((input) & (1<<9)) != 0; - final Boolean _pause = ((input) & (1<<10)) != 0; - final Boolean _pauseAsym = ((input) & (1<<11)) != 0; - return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, - _1gbFd, _1gbHd, _autoneg, _copper, _fiber, _pause, _pauseAsym); + final Boolean pf10mbHd = ((input) & (1<<0)) != 0; + final Boolean pf10mbFd = ((input) & (1<<1)) != 0; + final Boolean pf100mbHd = ((input) & (1<<2)) != 0; + final Boolean pf100mbFd = ((input) & (1<<3)) != 0; + final Boolean pf1gbHd = ((input) & (1<<4)) != 0; + final Boolean pf1gbFd = ((input) & (1<<5)) != 0; + final Boolean pf10gbFd = ((input) & (1<<6)) != 0; + final Boolean pfCopper = ((input) & (1<<7)) != 0; + final Boolean pfFiber = ((input) & (1<<8)) != 0; + final Boolean pfAutoneg = ((input) & (1<<9)) != 0; + final Boolean pfPause = ((input) & (1<<10)) != 0; + final Boolean pfPauseAsym = ((input) & (1<<11)) != 0; + return new PortFeaturesV10(pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, + pf1gbFd, pf1gbHd, pfAutoneg, pfCopper, pfFiber, pfPause, pfPauseAsym); } } \ No newline at end of file From a7d501920619c594d8482ead86df21e0c60bd1aa Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Thu, 23 Oct 2014 14:03:26 +0200 Subject: [PATCH 088/285] BUG-2245 - Fixed Magic Number Change-Id: I2b1ce6948edb411531ad93a3a85986d97534ae9a Signed-off-by: Marian Adamjak --- .../MultipartReplyMessageFactory.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 19f7a38e..b27712f5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -188,36 +188,36 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0)); rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER); - switch (type) { - case 0: builder.setMultipartReplyBody(setDesc(rawMessage)); + switch (MultipartType.forValue(type)) { + case OFPMPDESC: builder.setMultipartReplyBody(setDesc(rawMessage)); break; - case 1: builder.setMultipartReplyBody(setFlow(rawMessage)); + case OFPMPFLOW: builder.setMultipartReplyBody(setFlow(rawMessage)); break; - case 2: builder.setMultipartReplyBody(setAggregate(rawMessage)); + case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; - case 3: builder.setMultipartReplyBody(setTable(rawMessage)); + case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); break; - case 4: builder.setMultipartReplyBody(setPortStats(rawMessage)); + case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; - case 5: builder.setMultipartReplyBody(setQueue(rawMessage)); + case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); break; - case 6: builder.setMultipartReplyBody(setGroup(rawMessage)); + case OFPMPGROUP: builder.setMultipartReplyBody(setGroup(rawMessage)); break; - case 7: builder.setMultipartReplyBody(setGroupDesc(rawMessage)); + case OFPMPGROUPDESC: builder.setMultipartReplyBody(setGroupDesc(rawMessage)); break; - case 8: builder.setMultipartReplyBody(setGroupFeatures(rawMessage)); + case OFPMPGROUPFEATURES: builder.setMultipartReplyBody(setGroupFeatures(rawMessage)); break; - case 9: builder.setMultipartReplyBody(setMeter(rawMessage)); + case OFPMPMETER: builder.setMultipartReplyBody(setMeter(rawMessage)); break; - case 10: builder.setMultipartReplyBody(setMeterConfig(rawMessage)); + case OFPMPMETERCONFIG: builder.setMultipartReplyBody(setMeterConfig(rawMessage)); break; - case 11: builder.setMultipartReplyBody(setMeterFeatures(rawMessage)); + case OFPMPMETERFEATURES: builder.setMultipartReplyBody(setMeterFeatures(rawMessage)); break; - case 12: builder.setMultipartReplyBody(setTableFeatures(rawMessage)); + case OFPMPTABLEFEATURES: builder.setMultipartReplyBody(setTableFeatures(rawMessage)); break; - case 13: builder.setMultipartReplyBody(setPortDesc(rawMessage)); + case OFPMPPORTDESC: builder.setMultipartReplyBody(setPortDesc(rawMessage)); break; - case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage)); + case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; default: break; From 2ad270850d75831c132321a508e79a5be1b8e3aa Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 24 Oct 2014 08:37:28 +0200 Subject: [PATCH 089/285] BUG 2245 - Fixed 'Preserve Stack Trace' Change-Id: I53a451b1d2f0691a1de44f671f71b2cd8024076d Signed-off-by: Marian Adamjak --- .../openflowjava/protocol/impl/core/SslKeyStore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java index 983a03e9..589c23cd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java @@ -55,7 +55,7 @@ public static InputStream asInputStream(String filename, PathType pathType) { in = new FileInputStream(keystorefile); } catch (FileNotFoundException e) { throw new IllegalStateException("KeyStore file not found: " - + filename); + + filename,e); } break; default: From b14c2e1a92deee9dcba26632bcefda967dbe0e09 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 24 Oct 2014 13:19:40 +0200 Subject: [PATCH 090/285] BUG 2245 - Fixed Avoid cycle between Java package (TypeToClassKey only) Change-Id: I4496cd238824b1b1430805775e30665a7c199c11 Signed-off-by: Marian Adamjak --- .../protocol/impl/deserialization/DeserializationFactory.java | 1 + .../impl/deserialization/TypeToClassMapInitializer.java | 1 + .../openflowjava/protocol/impl/util/TypeToClassInitHelper.java | 2 -- .../protocol/impl/{deserialization => util}/TypeToClassKey.java | 2 +- .../protocol/impl/deserialization/TypeToClassKeyTest.java | 2 ++ .../impl/deserialization/TypeToClassMapInitializerTest.java | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{deserialization => util}/TypeToClassKey.java (91%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index 274b9740..9cc40227 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 213723c1..fa110c09 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -11,6 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index 246c4105..abf7695d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -9,8 +9,6 @@ import java.util.Map; -import org.opendaylight.openflowjava.protocol.impl.deserialization.TypeToClassKey; - /** * @author michal.polkorab * diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java similarity index 91% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java index 7774937b..098f9322 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; +package org.opendaylight.openflowjava.protocol.impl.util; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java index bf9d060f..71a56750 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java @@ -9,8 +9,10 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import junit.framework.Assert; + import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; /** * * @author madamjak diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index 84d318f3..fb65cee6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -15,6 +15,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; From af73ad7271591184bef82a9083f1df256f01b973 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 24 Oct 2014 14:20:18 +0200 Subject: [PATCH 091/285] BUG 2245 - Fixed Parameter Name Change-Id: I06b083325c4c6755ae21afd50f19b970a1a1d69a Signed-off-by: Marian Adamjak --- .../match/AbstractOxmMatchEntryDeserializer.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index 635cc757..d512b59e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -42,18 +42,18 @@ public MatchEntries deserializeHeader(ByteBuf input) { * Prepares match entry header - sets oxm_class, oxm_field, hasMask * + sets the buffer.readerIndex() to the end of match entry * - where augmentation starts - * @param oxm_class oxm class type - * @param oxm_field oxm field type + * @param oxmClass oxm class type + * @param oxmField oxm field type * @param input input bytebuf * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation */ - protected MatchEntriesBuilder processHeader(Class oxm_class, - Class oxm_field, ByteBuf input) { + protected MatchEntriesBuilder processHeader(Class oxmClass, + Class oxmField, ByteBuf input) { MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(oxm_class); + builder.setOxmClass(oxmClass); // skip oxm_class (provided) input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setOxmMatchField(oxm_field); + builder.setOxmMatchField(oxmField); boolean hasMask = (input.readUnsignedByte() & 1) != 0; builder.setHasMask(hasMask); // skip match entry length - not needed From 37493df2ce7ec4bd9a2e1117dcc594c54731e388 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 24 Oct 2014 14:49:12 +0200 Subject: [PATCH 092/285] BUG 2245 - Fix Unnecessary Local Before Return Change-Id: I6fc4762d8af5cced96e82529cf23d75bb017dffa Signed-off-by: Marian Adamjak --- .../impl/connection/SwitchConnectionProviderImpl.java | 8 +++++--- .../connection/SwitchConnectionProviderImpl02Test.java | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 75f698c4..002343d7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -97,9 +97,11 @@ public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionH @Override public ListenableFuture shutdown() { LOGGER.debug("Shutdown summoned"); - //TODO: provide exception in case of: not started, not configured (already stopped) - ListenableFuture result = serverFacade.shutdown(); - return result; + if(serverFacade == null){ + LOGGER.debug("Can not shutdown - not configured or started"); + throw new IllegalStateException("SwitchConnectionProvider is not started or not configured."); + } + return serverFacade.shutdown(); } @Override diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java index e0fecc27..c388c682 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java @@ -112,6 +112,14 @@ public void testServerFacade(){ Assert.assertNotNull("Wrong -- getServerFacade return null",serverFacade); } + /** + * Test shutdown on unconfigured provider + */ + @Test(expected = IllegalStateException.class) + public void testShutdownUnconfigured(){ + startUp(TransportProtocol.TCP); + provider.shutdown(); + } /** * Test unregister by wrong key */ From 62506a770072186715da157c11360cbd6adf7ad3 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 10:19:32 +0100 Subject: [PATCH 093/285] BUG 2245 - Fixed Redundant Modifier Change-Id: Iabdb33c37646cd3bff16c978abac73914875aeb5 Signed-off-by: Marian Adamjak --- .../api/connection/ConnectionAdapter.java | 16 ++++++++-------- .../connection/ConnectionConfiguration.java | 15 +++++++-------- .../connection/ConnectionReadyListener.java | 2 +- .../connection/SwitchConnectionHandler.java | 4 ++-- .../api/connection/ThreadConfiguration.java | 4 ++-- .../api/connection/TlsConfiguration.java | 18 +++++++++--------- .../DeserializerExtensionProvider.java | 8 ++++---- .../extensibility/DeserializerRegistry.java | 8 ++++---- .../DeserializerRegistryInjector.java | 2 +- .../api/extensibility/HeaderDeserializer.java | 2 +- .../api/extensibility/HeaderSerializer.java | 2 +- .../api/extensibility/OFDeserializer.java | 2 +- .../api/extensibility/OFSerializer.java | 2 +- .../SerializerExtensionProvider.java | 16 ++++++++-------- .../api/extensibility/SerializerRegistry.java | 6 +++--- .../SerializerRegistryInjector.java | 2 +- .../connection/ConnectionAdapterFactory.java | 2 +- .../impl/connection/MessageConsumer.java | 2 +- .../impl/connection/OnlineProvider.java | 2 +- .../protocol/impl/connection/ServerFacade.java | 2 +- .../impl/connection/ShutdownProvider.java | 2 +- .../protocol/impl/util/CodeKeyMaker.java | 2 +- .../protocol/impl/util/TypeKeyMaker.java | 2 +- .../protocol/impl/clients/ClientEvent.java | 2 +- .../protocol/impl/clients/OFClient.java | 8 ++++---- 25 files changed, 66 insertions(+), 67 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index d9d63228..50a85fbc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -26,41 +26,41 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * disconnect corresponding switch * @return future set to true, when disconnect completed */ - public Future disconnect(); + Future disconnect(); /** * @return true, if connection to switch is alive */ - public boolean isAlive(); + boolean isAlive(); /** * @return address of the remote end - address of a switch if connected */ - public InetSocketAddress getRemoteAddress(); + InetSocketAddress getRemoteAddress(); /** * @param messageListener here will be pushed all messages from switch */ - public void setMessageListener(OpenflowProtocolListener messageListener); + void setMessageListener(OpenflowProtocolListener messageListener); /** * @param systemListener here will be pushed all system messages from library */ - public void setSystemListener(SystemNotificationsListener systemListener); + void setSystemListener(SystemNotificationsListener systemListener); /** * Throws exception if any of required listeners is missing */ - public void checkListeners(); + void checkListeners(); /** * notify listener about connection ready-to-use event */ - public void fireConnectionReadyNotification(); + void fireConnectionReadyNotification(); /** * set listener for connection became ready-to-use event * @param connectionReadyListener */ - public void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener); + void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index 8b344769..6a61b585 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -6,7 +6,6 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.api.connection; import java.net.InetAddress; @@ -24,35 +23,35 @@ public interface ConnectionConfiguration { /** * @return address to bind, if null, all available interfaces will be used */ - public InetAddress getAddress(); + InetAddress getAddress(); /** * @return port to bind */ - public int getPort(); + int getPort(); /** * @return transport protocol to use */ - public Object getTransferProtocol(); + Object getTransferProtocol(); /** * @return TLS configuration object */ - public TlsConfiguration getTlsConfiguration(); + TlsConfiguration getTlsConfiguration(); /** * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream */ - public long getSwitchIdleTimeout(); + long getSwitchIdleTimeout(); /** * @return seed for {@link SSLEngine} */ - public Object getSslContext(); + Object getSslContext(); /** * @return thread numbers for TcpHandler's eventloopGroups */ - public ThreadConfiguration getThreadConfiguration(); + ThreadConfiguration getThreadConfiguration(); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionReadyListener.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionReadyListener.java index 55152fb7..0c7e026d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionReadyListener.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionReadyListener.java @@ -17,5 +17,5 @@ public interface ConnectionReadyListener { /** * fired when connection becomes ready-to-use */ - public void onConnectionReady(); + void onConnectionReady(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java index 82dd0f0e..c5f26fc1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java @@ -21,12 +21,12 @@ public interface SwitchConnectionHandler { /** * @param connection to switch proving message sending/receiving, connection management */ - public void onSwitchConnected(ConnectionAdapter connection); + void onSwitchConnected(ConnectionAdapter connection); /** * @param switchAddress * @return true, if connection from switch having given address shell be accepted; false otherwise */ - public boolean accept(InetAddress switchAddress); + boolean accept(InetAddress switchAddress); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java index 6ce39ee3..89dae4a2 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java @@ -17,10 +17,10 @@ public interface ThreadConfiguration { /** * @return desired number of workerThreads processing the Openflow I/O */ - public int getWorkerThreadCount(); + int getWorkerThreadCount(); /** * @return desired number of bossThreads registering incomming Openflow connections */ - public int getBossThreadCount(); + int getBossThreadCount(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index 00e1a410..fde44efb 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -21,45 +21,45 @@ public interface TlsConfiguration { /** * @return keystore location */ - public String getTlsKeystore(); + String getTlsKeystore(); /** * @return keystore type */ - public KeystoreType getTlsKeystoreType(); + KeystoreType getTlsKeystoreType(); /** * @return truststore location */ - public String getTlsTruststore(); + String getTlsTruststore(); /** * @return truststore type */ - public KeystoreType getTlsTruststoreType(); + KeystoreType getTlsTruststoreType(); /** * @return keystore path type (CLASSPATH or PATH) */ - public PathType getTlsKeystorePathType(); + PathType getTlsKeystorePathType(); /** * @return truststore path type (CLASSPATH or PATH) */ - public PathType getTlsTruststorePathType(); + PathType getTlsTruststorePathType(); /** * @return password protecting specified keystore */ - public String getKeystorePassword(); + String getKeystorePassword(); /** * @return password protecting certificate */ - public String getCertificatePassword(); + String getCertificatePassword(); /** * @return password protecting specified truststore */ - public String getTruststorePassword(); + String getTruststorePassword(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 30da38c6..0fd529db 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -40,14 +40,14 @@ public interface DeserializerExtensionProvider { * @return true if deserializer was removed, * false if no deserializer was found under specified key */ - public boolean unregisterDeserializer(ExperimenterDeserializerKey key); + boolean unregisterDeserializer(ExperimenterDeserializerKey key); /** * Registers action deserializer * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerActionDeserializer(ExperimenterActionDeserializerKey key, + void registerActionDeserializer(ExperimenterActionDeserializerKey key, OFGeneralDeserializer deserializer); /** @@ -55,7 +55,7 @@ public void registerActionDeserializer(ExperimenterActionDeserializerKey key, * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, OFGeneralDeserializer deserializer); /** @@ -63,7 +63,7 @@ public void registerInstructionDeserializer(ExperimenterInstructionDeserializerK * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, OFGeneralDeserializer deserializer); /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index eeeac0a4..646f4e08 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -17,13 +17,13 @@ public interface DeserializerRegistry { /** * Initializes deserializers */ - public void init(); + void init(); /** * @param key used for deserializer lookup * @return deserializer found */ - public + SERIALIZERTYPE getDeserializer(MessageCodeKey key); /** @@ -37,7 +37,7 @@ public interface DeserializerRegistry { * @param key used for deserializer lookup * @param deserializer deserializer instance */ - public void registerDeserializer(MessageCodeKey key, + void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer); /** @@ -47,5 +47,5 @@ public void registerDeserializer(MessageCodeKey key, * @return true if deserializer was removed, * false if no deserializer was found under specified key */ - public boolean unregisterDeserializer(MessageCodeKey key); + boolean unregisterDeserializer(MessageCodeKey key); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java index 5f029a2d..662ac802 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java @@ -17,5 +17,5 @@ public interface DeserializerRegistryInjector { * Injects deserializer registry into deserializer * @param deserializerRegistry */ - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); + void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index 205c7692..594f3d02 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -23,5 +23,5 @@ public interface HeaderDeserializer extends OFGeneralDeser * @param rawMessage message as bytes in ByteBuf * @return POJO/DTO */ - public E deserializeHeader(ByteBuf rawMessage); + E deserializeHeader(ByteBuf rawMessage); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index 3392f817..cd8cf038 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -23,5 +23,5 @@ public interface HeaderSerializer extends OF * @param input object whose headers should be serialized * @param outBuffer output buffer */ - public void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); + void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java index a514e00f..25a04ac3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java @@ -26,5 +26,5 @@ public interface OFDeserializer extends OFGeneralDeseriali * @param message message as bytes in ByteBuf * @return POJO/DTO */ - public E deserialize(ByteBuf message); + E deserialize(ByteBuf message); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java index 2572a6f2..ad463f45 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java @@ -25,6 +25,6 @@ public interface OFSerializer extends OFGen * @param input object to be serialized * @param outBuffer output buffer */ - public void serialize(SERIALIZER_TYPE input, ByteBuf outBuffer); + void serialize(SERIALIZER_TYPE input, ByteBuf outBuffer); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 9bbc85c3..f658f5f1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -40,14 +40,14 @@ public interface SerializerExtensionProvider { * @return true if serializer was removed, * false if no serializer was found under specified key */ - public boolean unregisterSerializer(ExperimenterSerializerKey key); + boolean unregisterSerializer(ExperimenterSerializerKey key); /** * Registers action serializer * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerActionSerializer(ExperimenterActionSerializerKey key, + void registerActionSerializer(ExperimenterActionSerializerKey key, OFGeneralSerializer serializer); /** @@ -55,7 +55,7 @@ public void registerActionSerializer(ExperimenterActionSerializerKey key, * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, OFGeneralSerializer serializer); /** @@ -63,7 +63,7 @@ public void registerInstructionSerializer(ExperimenterInstructionSerializerKey k * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerMatchEntrySerializer( + void registerMatchEntrySerializer( MatchEntrySerializerKey key,OFGeneralSerializer serializer); /** @@ -71,7 +71,7 @@ public void register * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, OFSerializer serializer); /** @@ -79,7 +79,7 @@ public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, OFSerializer serializer); /** @@ -87,7 +87,7 @@ public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, OFGeneralSerializer serializer); /** @@ -95,6 +95,6 @@ public void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, + void registerMeterBandSerializer(ExperimenterIdSerializerKey key, OFSerializer serializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index a53faa5c..c0590140 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -26,7 +26,7 @@ public interface SerializerRegistry { * @param msgTypeKey lookup key * @return serializer or NullPointerException if no serializer was found */ - public SERIALIZERTYPE + SERIALIZERTYPE getSerializer(MessageTypeKey msgTypeKey); /** @@ -40,7 +40,7 @@ public interface SerializerRegistry { * @param key used for serializer lookup * @param serializer serializer implementation */ - public void registerSerializer(MessageTypeKey key, + void registerSerializer(MessageTypeKey key, OFGeneralSerializer serializer); /** @@ -50,5 +50,5 @@ public void registerSerializer(MessageTypeKey key, * @return true if serializer was removed, * false if no serializer was found under specified key */ - public boolean unregisterSerializer(MessageTypeKey key); + boolean unregisterSerializer(MessageTypeKey key); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java index 260c2cc4..1204055e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java @@ -17,6 +17,6 @@ public interface SerializerRegistryInjector { * Injects serializer registry * @param serializerRegistry registry instance */ - public void injectSerializerRegistry(SerializerRegistry serializerRegistry); + void injectSerializerRegistry(SerializerRegistry serializerRegistry); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java index dba298b7..cf4e83f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java @@ -23,6 +23,6 @@ public interface ConnectionAdapterFactory { * @param ch * @return connection adapter tcp-implementation */ - public ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) ; + ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) ; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java index fe833311..81c1796e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java @@ -19,6 +19,6 @@ public interface MessageConsumer { /** * @param message to process */ - public void consume(DataObject message); + void consume(DataObject message); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java index e828d9ae..01207ec6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java @@ -19,6 +19,6 @@ public interface OnlineProvider { /** * @return the isOnlineFuture */ - public ListenableFuture getIsOnlineFuture(); + ListenableFuture getIsOnlineFuture(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java index 39a6eb7e..4759b657 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java @@ -20,5 +20,5 @@ public interface ServerFacade extends ShutdownProvider, OnlineProvider, Runnable * Sets thread configuration * @param threadConfig desired thread configuration */ - public void setThreadConfig(ThreadConfiguration threadConfig); + void setThreadConfig(ThreadConfiguration threadConfig); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java index 21870cc4..facecb9f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java @@ -20,6 +20,6 @@ public interface ShutdownProvider { /** * @return shutdown future */ - public ListenableFuture shutdown(); + ListenableFuture shutdown(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java index bd5fff2a..52c2a4de 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java @@ -21,6 +21,6 @@ public interface CodeKeyMaker { * @param input buffer that will be the needed data gathered from * @return key for deserializer lookup */ - public abstract MessageCodeKey make(ByteBuf input); + abstract MessageCodeKey make(ByteBuf input); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index 4e17dfcd..a9dab19e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -21,6 +21,6 @@ public interface TypeKeyMaker { * @return key that will be used for serializer lookup in * the serializer registry */ - public abstract MessageTypeKey make(T entry); + abstract MessageTypeKey make(T entry); } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java index 39b86460..8538d7ba 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java @@ -19,5 +19,5 @@ public interface ClientEvent { * Common method for triggering events * @return true if event executed successfully */ - public boolean eventExecuted(); + boolean eventExecuted(); } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java index f7b4bafa..0d4046ef 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java @@ -20,21 +20,21 @@ public interface OFClient extends Runnable { /** * @return the isOnlineFuture which is set when client is started */ - public SettableFuture getIsOnlineFuture(); + SettableFuture getIsOnlineFuture(); /** * @return the scenarioDone when scenario is successfully finished */ - public SettableFuture getScenarioDone(); + SettableFuture getScenarioDone(); /** * @param scenario list of desired actions */ - public void setScenarioHandler(ScenarioHandler scenario); + void setScenarioHandler(ScenarioHandler scenario); /** * @param securedClient true is client should use encrypted communication, * false otherwise */ - public void setSecuredClient(boolean securedClient); + void setSecuredClient(boolean securedClient); } \ No newline at end of file From b94a3a0cfa9d28d74d87ade59f36c0ed20dd2e24 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 10:33:24 +0100 Subject: [PATCH 094/285] BUG 2245 - Fixed Constant Name Change-Id: I2401601e84f1255212cad3b09f4eaba65df430e9 Signed-off-by: Marian Adamjak --- .../protocol/impl/core/SslTrustManagerFactory.java | 6 +++--- .../protocol/impl/clients/ClientSslKeyStore.java | 6 +++--- .../protocol/impl/clients/ClientSslTrustStore.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java index 69f2db68..6890234c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java @@ -28,7 +28,7 @@ public class SslTrustManagerFactory extends TrustManagerFactorySpi { /** * Logger for SslTrustManagerFactory */ - public static final Logger logger = LoggerFactory.getLogger(SslTrustManagerFactory.class); + public static final Logger LOGGER = LoggerFactory.getLogger(SslTrustManagerFactory.class); private static final TrustManager DUMMY_TRUST_MANAGER = new X509TrustManager() { @Override public X509Certificate[] getAcceptedIssuers() { @@ -37,12 +37,12 @@ public X509Certificate[] getAcceptedIssuers() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType) { - logger.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN()); + LOGGER.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN()); } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) { - logger.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN()); + LOGGER.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN()); } }; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java index 233b1c11..e3e60697 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java @@ -17,7 +17,7 @@ */ public final class ClientSslKeyStore { - private static final String filename = "/selfSignedSwitch"; + private static final String KEY_STORE_FILENAME = "/selfSignedSwitch"; private ClientSslKeyStore() { throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); @@ -29,9 +29,9 @@ private ClientSslKeyStore() { * @return key as InputStream */ public static InputStream asInputStream() { - InputStream in = ClientSslKeyStore.class.getResourceAsStream(filename); + InputStream in = ClientSslKeyStore.class.getResourceAsStream(KEY_STORE_FILENAME); if (in == null) { - throw new IllegalStateException("KeyStore file not found: " + filename); + throw new IllegalStateException("KeyStore file not found: " + KEY_STORE_FILENAME); } return in; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java index c346ba1e..5f7929f6 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java @@ -17,7 +17,7 @@ */ public final class ClientSslTrustStore { - private static final String filename = "/selfSignedController"; + private static final String KEY_STORE_FILENAME = "/selfSignedController"; private ClientSslTrustStore() { throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); @@ -29,9 +29,9 @@ private ClientSslTrustStore() { * @return key as InputStream */ public static InputStream asInputStream() { - InputStream in = ClientSslTrustStore.class.getResourceAsStream(filename); + InputStream in = ClientSslTrustStore.class.getResourceAsStream(KEY_STORE_FILENAME); if (in == null) { - throw new IllegalStateException("KeyStore file not found: " + filename); + throw new IllegalStateException("KeyStore file not found: " + KEY_STORE_FILENAME); } return in; } From 03de42f0b69b93597dc2a0d81351c251e5bb4da9 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 10:57:38 +0100 Subject: [PATCH 095/285] BUG 2245 - Fixed Singular Field Change-Id: I9489b5e8c9cb221cf7a29e7e41d4c909204ed9c7 Signed-off-by: Marian Adamjak --- .../openflowjava/protocol/impl/core/UdpHandler.java | 3 +-- .../openflowjava/protocol/impl/clients/SimpleClient.java | 3 +-- .../openflowjava/protocol/impl/clients/UdpSimpleClient.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index c0f958d2..8a04efa4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -37,7 +37,6 @@ public final class UdpHandler implements ServerFacade { private static final Logger LOGGER = LoggerFactory .getLogger(UdpHandler.class); private int port; - private String address; private EventLoopGroup group; private final InetAddress startupAddress; private final SettableFuture isOnlineFuture; @@ -91,7 +90,7 @@ public void run() { try { InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); - this.address = isa.getHostString(); + String address = isa.getHostString(); // Update port, as it may have been specified as 0 this.port = isa.getPort(); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index e31c3674..fee80aa4 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -36,7 +36,6 @@ public class SimpleClient implements OFClient { private EventLoopGroup group; private SettableFuture isOnlineFuture; private SettableFuture scenarioDone; - private SimpleClientInitializer clientInitializer; private ScenarioHandler scenarioHandler; /** @@ -62,7 +61,7 @@ private void init() { @Override public void run() { group = new NioEventLoopGroup(); - clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient); + SimpleClientInitializer clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient); clientInitializer.setScenario(scenarioHandler); try { Bootstrap b = new Bootstrap(); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java index 685dbd2a..52dcb425 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -36,7 +36,6 @@ public class UdpSimpleClient implements OFClient { private EventLoopGroup group; private SettableFuture isOnlineFuture; private SettableFuture scenarioDone; - private UdpSimpleClientInitializer clientInitializer; private ScenarioHandler scenarioHandler; /** @@ -62,7 +61,7 @@ private void init() { @Override public void run() { group = new NioEventLoopGroup(); - clientInitializer = new UdpSimpleClientInitializer(isOnlineFuture); + UdpSimpleClientInitializer clientInitializer = new UdpSimpleClientInitializer(isOnlineFuture); clientInitializer.setScenario(scenarioHandler); try { Bootstrap b = new Bootstrap(); From f02f2594ce9155a2d7354f37ecd06cdf9475c887 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 11:02:05 +0100 Subject: [PATCH 096/285] BUG 2245 - Fixed Modifier Order Change-Id: Iba652fb7afe982613c5c5519160c8714de00d1ba Signed-off-by: Marian Adamjak --- .../protocol/impl/connection/AbstractRpcListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java index 17002714..42f8c66e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java @@ -67,7 +67,7 @@ public final GenericFutureListener> takeListener() { return this; } - abstract protected void operationSuccessful(); + protected abstract void operationSuccessful(); protected final void failedRpc(final Throwable cause) { final RpcError rpcError = ConnectionAdapterImpl.buildRpcError( From 9c53c124ccdae337810256286097d3f4adf55f7f Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 11:11:06 +0100 Subject: [PATCH 097/285] BUG 2245 - Fixed Collapsible If Statements Change-Id: Idee4d65869ed7041fde16706b4fb8bea2f77bfdd Signed-off-by: Marian Adamjak --- .../protocol/impl/connection/ChannelOutboundQueue.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java index cc7abcae..2d50ff2b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java @@ -202,12 +202,10 @@ private synchronized void flush() { * should be able to perform dynamic adjustments here. * is that additional complexity needed, though? */ - if ((messages % WORKTIME_RECHECK_MSGS) == 0) { - if (System.nanoTime() >= deadline) { - LOG.trace("Exceeded allotted work time {}us", - TimeUnit.NANOSECONDS.toMicros(maxWorkTime)); - break; - } + if ((messages % WORKTIME_RECHECK_MSGS) == 0 && System.nanoTime() >= deadline) { + LOG.trace("Exceeded allotted work time {}us", + TimeUnit.NANOSECONDS.toMicros(maxWorkTime)); + break; } } From 5aec24f34cd665e1d70d1f092531bb61c84ad175 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Mon, 27 Oct 2014 15:38:02 +0100 Subject: [PATCH 098/285] BUG 2245 - Fixed Magic Number Change-Id: Ic725d3604d8901c8fd43e31a2f59544df71fe724 Signed-off-by: Marian Adamjak --- .../factories/OF10StatsReplyMessageFactory.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index f1370acd..df7f6940 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -87,20 +87,20 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { int type = rawMessage.readUnsignedShort(); builder.setType(MultipartType.forValue(type)); builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0)); - switch (type) { - case 0: builder.setMultipartReplyBody(setDesc(rawMessage)); + switch (MultipartType.forValue(type)) { + case OFPMPDESC: builder.setMultipartReplyBody(setDesc(rawMessage)); break; - case 1: builder.setMultipartReplyBody(setFlow(rawMessage)); + case OFPMPFLOW: builder.setMultipartReplyBody(setFlow(rawMessage)); break; - case 2: builder.setMultipartReplyBody(setAggregate(rawMessage)); + case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; - case 3: builder.setMultipartReplyBody(setTable(rawMessage)); + case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); break; - case 4: builder.setMultipartReplyBody(setPortStats(rawMessage)); + case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; - case 5: builder.setMultipartReplyBody(setQueue(rawMessage)); + case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); break; - case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage)); + case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; default: break; From 84467d5ec8c0d5a6dc4d712bc80621dc5ca36e8d Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 23 Oct 2014 16:56:10 +0200 Subject: [PATCH 099/285] Fixed cache logging - successful rpc is no more logged as discarded - rpc is discarded only when it exceeds specified timeout Change-Id: I60b334958e76a428c7fa1eebe9a4910c90ef5a8d Signed-off-by: Michal Polkorab --- .../protocol/impl/connection/ConnectionAdapterImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index 62339ae8..c24899fd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -71,6 +71,7 @@ import com.google.common.base.Preconditions; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalCause; import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalNotification; import com.google.common.util.concurrent.ListenableFuture; @@ -103,7 +104,9 @@ public class ConnectionAdapterImpl implements ConnectionFacade { @Override public void onRemoval( final RemovalNotification> notification) { - notification.getValue().discard(); + if (! notification.getCause().equals(RemovalCause.EXPLICIT)) { + notification.getValue().discard(); + } } }; From dd69581cdec16160f4b9461ff0212737ce111db5 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 27 Oct 2014 17:59:11 +0100 Subject: [PATCH 100/285] Bug 2245 - Fixed critical issues - Array is stored directly - Wait not in loop - Naked notify Change-Id: Ifa9f431b84298d724351c89e8c330a69b8ab1ff3 Signed-off-by: Michal Polkorab --- .../protocol/impl/clients/ScenarioHandler.java | 9 +++++++++ .../protocol/impl/clients/SendEvent.java | 5 ++++- .../protocol/impl/clients/SimpleClient.java | 4 +++- .../protocol/impl/clients/UdpSimpleClient.java | 4 +++- .../protocol/impl/clients/WaitForMessageEvent.java | 12 ++++++++---- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 71f7be90..61333f87 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -30,6 +30,7 @@ public class ScenarioHandler extends Thread { private BlockingQueue ofMsg; private ChannelHandlerContext ctx; private int eventNumber; + private boolean scenarioFinished = false; /** * @@ -79,6 +80,7 @@ public void run() { } LOGGER.debug("Scenario finished"); synchronized (this) { + scenarioFinished = true; this.notify(); } } @@ -117,4 +119,11 @@ public void setCtx(ChannelHandlerContext ctx) { public void addOfMsg(byte[] message) { ofMsg.add(message); } + + /** + * @return true is scenario is finished + */ + public boolean isScenarioFinished() { + return scenarioFinished; + } } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index 5df57844..db339eb2 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -30,7 +30,10 @@ public class SendEvent implements ClientEvent { * @param msgToSend message to be sent */ public SendEvent(byte[] msgToSend) { - this.msgToSend = msgToSend; + this.msgToSend = new byte[msgToSend.length]; + for (int i = 0; i < msgToSend.length; i++) { + this.msgToSend[i] = msgToSend[i]; + } } @Override diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index fee80aa4..89854c7e 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -73,7 +73,9 @@ public void run() { synchronized (scenarioHandler) { LOGGER.debug("WAITING FOR SCENARIO"); - scenarioHandler.wait(); + while (! scenarioHandler.isScenarioFinished()) { + scenarioHandler.wait(); + } } } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java index 52dcb425..92e88672 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -74,7 +74,9 @@ public void run() { synchronized (scenarioHandler) { LOGGER.debug("WAITING FOR SCENARIO"); - scenarioHandler.wait(); + while (! scenarioHandler.isScenarioFinished()) { + scenarioHandler.wait(); + } } } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index 42ef75ab..c4c786c6 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -28,7 +28,10 @@ public class WaitForMessageEvent implements ClientEvent { * @param headerExpected header (first 8 bytes) of expected message */ public WaitForMessageEvent(byte[] headerExpected) { - this.headerExpected = headerExpected; + this.headerExpected = new byte[headerExpected.length]; + for (int i = 0; i < headerExpected.length; i++) { + this.headerExpected[i] = headerExpected[i]; + } } @Override @@ -49,8 +52,9 @@ public boolean eventExecuted() { * @param headerReceived header (first 8 bytes) of expected message */ public void setHeaderReceived(byte[] headerReceived) { - this.headerReceived = headerReceived; + this.headerReceived = new byte[headerReceived.length]; + for (int i = 0; i < headerReceived.length; i++) { + this.headerReceived[i] = headerReceived[i]; + } } - - } From 14377db367bd00e88296bf784c44cb41c2d1d214 Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Tue, 28 Oct 2014 10:02:15 +0100 Subject: [PATCH 101/285] Maintainig code - OFDatagramPacketDecoder, UdpConnectionMap Change-Id: I7485108109145b48f605d8f9dce1fee87fad9688 Signed-off-by: Marian Adamjak --- .../impl/core/OFDatagramPacketDecoder.java | 19 ++--- .../protocol/impl/core/UdpConnectionMap.java | 13 +++- .../core/OFDatagramPacketDecoderTest.java | 6 +- .../impl/core/UdpConnectionMapTest.java | 75 +++++++++++++++++++ 4 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index 7b4c3186..d2d228bf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -9,9 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.core; import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageDecoder; - -import java.util.List; +import io.netty.channel.SimpleChannelInboundHandler; import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; @@ -24,23 +22,21 @@ * @author michal.polkorab * */ -public class OFDatagramPacketDecoder extends MessageToMessageDecoder{ +public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); private DeserializationFactory deserializationFactory; @Override - protected void decode(ChannelHandlerContext ctx, - VersionMessageUdpWrapper msg, List out) throws Exception { + public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg) + throws Exception { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("UdpVersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + LOGGER.debug("UdpVersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); } - DataObject dataObject = null; try { - dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), - msg.getVersion()); + dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); if (dataObject == null) { LOGGER.warn("Translated POJO is null"); } else { @@ -55,7 +51,6 @@ protected void decode(ChannelHandlerContext ctx, } finally { msg.getMessageBuffer().release(); } - } /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index aeb73056..2eeaa3ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.core; import java.net.InetSocketAddress; -import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; @@ -22,7 +22,7 @@ */ public final class UdpConnectionMap { - private static Map connectionMap = new HashMap<>(); + private static Map connectionMap = new ConcurrentHashMap<>(); private UdpConnectionMap() { throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); @@ -33,6 +33,9 @@ private UdpConnectionMap() { * @return corresponding MessageConsumer */ public static MessageConsumer getMessageConsumer(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } return connectionMap.get(address); } @@ -41,6 +44,9 @@ public static MessageConsumer getMessageConsumer(InetSocketAddress address) { * @param consumer MessageConsumer to be added / paired with specified address */ public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } connectionMap.put(address, consumer); } @@ -48,6 +54,9 @@ public static void addConnection(InetSocketAddress address, MessageConsumer cons * @param address sender's address */ public static void removeConnection(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } connectionMap.remove(address); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java index 4175647d..683a89ab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoderTest.java @@ -13,8 +13,6 @@ import io.netty.channel.ChannelHandlerContext; import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; import org.junit.Assert; import org.junit.Before; @@ -34,12 +32,10 @@ public class OFDatagramPacketDecoderTest { @Mock ByteBuf messageBufferMock; private VersionMessageUdpWrapper msgWrapper; - private List out; @Before public void startUp(){ MockitoAnnotations.initMocks(this); - out = new ArrayList<>(); } @Test @@ -48,7 +44,7 @@ public void test() { decoder.setDeserializationFactory(deserializationFactory); msgWrapper = new VersionMessageUdpWrapper(EncodeConstants.OF13_VERSION_ID, messageBufferMock, new InetSocketAddress("10.0.0.1", 6653)); try { - decoder.decode(ctx, msgWrapper, out); + decoder.channelRead0(ctx, msgWrapper); } catch (Exception e) { Assert.fail("Exception occured"); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java new file mode 100644 index 00000000..990ce784 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.socket.DatagramPacket; + +import java.net.InetSocketAddress; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; + +/** + * @author madamjak + * + */ +public class UdpConnectionMapTest { + + @Mock MessageConsumer consumerMock; + @Mock ByteBuf messageBuffer; + + @Before + public void startUp(){ + MockitoAnnotations.initMocks(this); + } + + /** + * Test {@link UdpConnectionMap} - sender address is not null + */ + @Test + public void testWithSenderAddress(){ + InetSocketAddress recipientISA = InetSocketAddress.createUnresolved("localhost", 9876); + InetSocketAddress senderISA = InetSocketAddress.createUnresolved("192.168.15.2", 21021); + DatagramPacket datagramPacket = new DatagramPacket(messageBuffer, recipientISA, senderISA); + UdpConnectionMap.addConnection(datagramPacket.sender(), consumerMock); + Assert.assertEquals("Wrong - different object has been returned", + consumerMock, UdpConnectionMap.getMessageConsumer(datagramPacket.sender())); + UdpConnectionMap.removeConnection(datagramPacket.sender()); + Assert.assertNull("Wrong - object has been returned after remove key-value pair", + UdpConnectionMap.getMessageConsumer(datagramPacket.sender())); + } + + /** + * Test {@link UdpConnectionMap} - sender address is null to add connection + */ + @Test(expected = IllegalArgumentException.class) + public void testWithoutSenderAddressOnAdd(){ + UdpConnectionMap.addConnection(null, consumerMock); + } + + /** + * Test {@link UdpConnectionMap} - sender address is not null to get message consumer + */ + @Test(expected = IllegalArgumentException.class) + public void testWithoutSenderAddressOnGet(){ + UdpConnectionMap.getMessageConsumer(null); + } + + /** + * Test {@link UdpConnectionMap} - sender address is not null to remove connection + */ + @Test(expected = IllegalArgumentException.class) + public void testWithoutSenderAddressOnRemove(){ + UdpConnectionMap.removeConnection(null); + } +} From 0a7d615e65c392f884ceb53fd6b3303c2bc67f8d Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 29 Oct 2014 09:22:47 +0100 Subject: [PATCH 102/285] Maintaining code - review log levels Change-Id: Ic43628ee1067e112e8c6e1cf21ff9f9a32b0e000 Signed-off-by: Marian Adamjak --- .../impl/connection/SwitchConnectionProviderImpl.java | 2 +- .../protocol/impl/core/OFDatagramPacketDecoder.java | 4 ++-- .../openflowjava/protocol/impl/core/OFDecoder.java | 4 ++-- .../protocol/impl/core/SslTrustManagerFactory.java | 4 ++-- .../protocol/impl/core/TcpChannelInitializer.java | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java index 002343d7..aadddd6b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java @@ -98,7 +98,7 @@ public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionH public ListenableFuture shutdown() { LOGGER.debug("Shutdown summoned"); if(serverFacade == null){ - LOGGER.debug("Can not shutdown - not configured or started"); + LOGGER.warn("Can not shutdown - not configured or started"); throw new IllegalStateException("SwitchConnectionProvider is not started or not configured."); } return serverFacade.shutdown(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index d2d228bf..5dea0bc6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -44,8 +44,8 @@ public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg consumer.consume(dataObject); } } catch(Exception e) { - LOGGER.error("Message deserialization failed"); - LOGGER.error(e.getMessage(), e); + LOGGER.warn("Message deserialization failed"); + LOGGER.warn(e.getMessage(), e); // TODO: delegate exception to allow easier deserialization // debugging / deserialization problem awareness } finally { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index 450eb4bb..6cf14050 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -53,8 +53,8 @@ protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, out.add(dataObject); } } catch(Exception e) { - LOGGER.error("Message deserialization failed"); - LOGGER.error(e.getMessage(), e); + LOGGER.warn("Message deserialization failed"); + LOGGER.warn(e.getMessage(), e); // TODO: delegate exception to allow easier deserialization // debugging / deserialization problem awareness } finally { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java index 6890234c..14f970cc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java @@ -37,12 +37,12 @@ public X509Certificate[] getAcceptedIssuers() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType) { - LOGGER.error("UNKNOWN CLIENT CERTIFICATE: " + chain[0].getSubjectDN()); + LOGGER.warn("UNKNOWN CLIENT CERTIFICATE: {}", chain[0].getSubjectDN()); } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) { - LOGGER.error("UNKNOWN SERVER CERTIFICATE: " + chain[0].getSubjectDN()); + LOGGER.warn("UNKNOWN SERVER CERTIFICATE: {}", chain[0].getSubjectDN()); } }; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index c1a9c43c..b93a641d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -57,14 +57,14 @@ protected void initChannel(final SocketChannel ch) { InetAddress switchAddress = ch.remoteAddress().getAddress(); int port = ch.localAddress().getPort(); int remotePort = ch.remoteAddress().getPort(); - LOGGER.info("Incoming connection from (remote address): " + switchAddress.toString() + LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString() + ":" + remotePort + " --> :" + port); if (!getSwitchConnectionHandler().accept(switchAddress)) { ch.disconnect(); - LOGGER.info("Incoming connection rejected"); + LOGGER.debug("Incoming connection rejected"); return; } - LOGGER.info("Incoming connection accepted - building pipeline"); + LOGGER.debug("Incoming connection accepted - building pipeline"); allChannels.add(ch); ConnectionFacade connectionFacade = null; connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null); @@ -98,7 +98,7 @@ protected void initChannel(final SocketChannel ch) { connectionFacade.fireConnectionReadyNotification(); } } catch (Exception e) { - LOGGER.error("Failed to initialize channel", e); + LOGGER.warn("Failed to initialize channel", e); ch.close(); } } From f864f45157b43242cfaeb4ec53a2e81f9f3b6c5b Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 29 Oct 2014 09:45:55 +0100 Subject: [PATCH 103/285] Maintaining code - remove unused class SslTrustManagerFactory Change-Id: I24a35c5c3ad6a06a27599f689f3de72ab1a47cc1 Signed-off-by: Marian Adamjak --- .../impl/core/SslTrustManagerFactory.java | 72 ------------------- .../impl/core/SslTrustManagerFactoryTest.java | 70 ------------------ 2 files changed, 142 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java deleted file mode 100644 index 14f970cc..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.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.warn("UNKNOWN CLIENT CERTIFICATE: {}", chain[0].getSubjectDN()); - } - - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) { - LOGGER.warn("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/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java deleted file mode 100644 index 23362840..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslTrustManagerFactoryTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.security.cert.X509Certificate; - -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.MockitoAnnotations; - -/** - * - * @author jameshall - */ -public class SslTrustManagerFactoryTest { - - /** - * Sets up test environment - */ - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * - */ - @Test - public void testGetTrustManagers() throws Exception { - TrustManager[] tmArray = SslTrustManagerFactory.getTrustManagers() ; - - assertNotNull( tmArray ); - for ( TrustManager tm : tmArray ) { - if ( tm.getClass() == X509TrustManager.class ) { - X509Certificate[] certsArray = ((X509TrustManager)tm).getAcceptedIssuers() ; - assertTrue( certsArray.length > 0 ) ; - - // Boolean caught = false; - // try { - // ((X509TrustManager)tm).checkClientTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; - // } catch (CertificateException ce) { - // caught = true ; - // } - // assertTrue( caught ) ; - // - // caught = false; - // try { - // ((X509TrustManager)tm).checkServerTrusted( certsArray, TrustManagerFactory.getDefaultAlgorithm()) ; - // } catch (CertificateException ce) { - // caught = true ; - // } - // assertTrue( caught ) ; - // } - } - } - } -} - From 1543cf94a492d565576d0001fabd479861a5d87b Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 29 Oct 2014 13:06:57 +0100 Subject: [PATCH 104/285] Maintaining code - Move buildRpcError method into AbstractRpcListener - remove unused method from ConnectionAdapterImpl Change-Id: I4d25b566fafd28a307345ebdffadcd14e844f2ee Signed-off-by: Marian Adamjak --- .../impl/connection/AbstractRpcListener.java | 21 ++++++++++++++- .../connection/ConnectionAdapterImpl.java | 26 ------------------- .../ResponseExpectedRpcListenerTest.java | 3 +-- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java index 42f8c66e..891dc17b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java @@ -12,9 +12,11 @@ import java.util.Collections; +import org.opendaylight.controller.sal.common.util.RpcErrors; import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,10 +32,27 @@ */ abstract class AbstractRpcListener implements GenericFutureListener>, ChannelOutboundQueue.MessageHolder { private static final Logger LOG = LoggerFactory.getLogger(AbstractRpcListener.class); + private static final String APPLICATION_TAG = "OPENFLOW_LIBRARY"; + private static final String TAG = "OPENFLOW"; private final SettableFuture> result = SettableFuture.create(); private final String failureInfo; private Object message; + /** + * Create RcpError object + * @param info + * @param severity - error severity + * @param message + * @param cause - details of reason + * @return + */ + static RpcError buildRpcError(final String info, final ErrorSeverity severity, final String message, + final Throwable cause) { + RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message, + ErrorType.RPC, cause); + return error; + } + AbstractRpcListener(final Object message, final String failureInfo) { this.failureInfo = Preconditions.checkNotNull(failureInfo); this.message = Preconditions.checkNotNull(message); @@ -70,7 +89,7 @@ public final GenericFutureListener> takeListener() { protected abstract void operationSuccessful(); protected final void failedRpc(final Throwable cause) { - final RpcError rpcError = ConnectionAdapterImpl.buildRpcError( + final RpcError rpcError = buildRpcError( failureInfo, ErrorSeverity.ERROR, "check switch connection", cause); result.set(Rpcs.getRpcResult( false, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java index c24899fd..5ebffd8f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java @@ -18,7 +18,6 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.sal.common.util.RpcErrors; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; @@ -61,9 +60,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -395,28 +391,6 @@ public void operationComplete( return transportResult; } - /** - * @param cause - * @return - */ - static RpcError buildRpcError(final String info, final ErrorSeverity severity, final String message, - final Throwable cause) { - RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message, - ErrorType.RPC, cause); - return error; - } - - /** - * @param cause - * @return - */ - protected static RpcError buildTransportError(final String info, final ErrorSeverity severity, final String message, - final Throwable cause) { - RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message, - ErrorType.TRANSPORT, cause); - return error; - } - /** * @param message * @return diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java index a535c085..aa33498f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java @@ -66,7 +66,6 @@ public void testCreation() { */ @Test(expected=NullPointerException.class) public void testCreation2() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); } @@ -79,7 +78,7 @@ public void testDiscard() { ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); listener.discard(); - RpcError rpcError = ConnectionAdapterImpl.buildRpcError("Failed to send message", + RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); SettableFuture> result = SettableFuture.create(); result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); From 784257605cac5bb1d780039ceb48ae1c9405233c Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 29 Oct 2014 14:59:47 +0100 Subject: [PATCH 105/285] Bug 2245 - Fixed Avoid cycle between java packages - between protocol.impl.core and protocol.impl.connection Change-Id: Ieb3a5a495fffc679852245b0a70e17c57023d3b1 Signed-off-by: Marian Adamjak --- .../protocol/impl/core/DelegatingInboundHandler.java | 4 ++-- .../protocol/impl/core/OFDatagramPacketDecoder.java | 2 +- .../protocol/impl/core/OFDatagramPacketEncoder.java | 2 +- .../protocol/impl/core/OFDatagramPacketHandler.java | 8 ++++---- .../openflowjava/protocol/impl/core/OFEncoder.java | 2 +- .../protocol/impl/core/OFFrameDecoder.java | 2 +- .../impl/{connection => core}/OnlineProvider.java | 2 +- .../impl/{connection => core}/ServerFacade.java | 2 +- .../impl/{connection => core}/ShutdownProvider.java | 2 +- .../SwitchConnectionProviderImpl.java | 5 +---- .../protocol/impl/core/TcpChannelInitializer.java | 6 +++--- .../openflowjava/protocol/impl/core/TcpHandler.java | 1 - .../protocol/impl/core/UdpConnectionMap.java | 2 +- .../openflowjava/protocol/impl/core/UdpHandler.java | 1 - .../{ => core}/connection/AbstractRpcListener.java | 2 +- .../{ => core}/connection/ChannelOutboundQueue.java | 2 +- .../connection/ConnectionAdapterFactory.java | 2 +- .../connection/ConnectionAdapterFactoryImpl.java | 2 +- .../{ => core}/connection/ConnectionAdapterImpl.java | 2 +- .../impl/{ => core}/connection/ConnectionFacade.java | 2 +- .../impl/{ => core}/connection/MessageConsumer.java | 2 +- .../{ => core}/connection/MessageListenerWrapper.java | 2 +- .../connection/ResponseExpectedRpcListener.java | 2 +- .../impl/{ => core}/connection/RpcResponseKey.java | 2 +- .../impl/{ => core}/connection/SimpleRpcListener.java | 2 +- .../connection/UdpMessageListenerWrapper.java | 2 +- .../impl/rev140328/SwitchConnectionProviderModule.java | 2 +- .../impl/core/DelegatingInboundHandlerTest.java | 2 +- .../impl/core/OFDatagramPacketEncoderTest.java | 2 +- .../impl/core/OFDatagramPacketHandlerTest.java | 2 +- .../openflowjava/protocol/impl/core/OFEncoderTest.java | 2 +- .../protocol/impl/core/OFFrameDecoderTest.java | 2 +- .../impl/core/PublishingChannelInitializerTest.java | 4 ++-- .../protocol/impl/core/UdpConnectionMapTest.java | 2 +- .../connection/ChannelOutboundQueue02Test.java | 7 ++++++- .../connection/ChannelOutboundQueueTest.java | 4 +++- .../connection/ConnectionAdapterFactoryImplTest.java | 4 +++- .../connection/ConnectionAdapterImp02lTest.java | 10 +++++++++- .../connection/ConnectionAdapterImplTest.java | 5 ++++- .../connection/ConnectionConfigurationImpl.java | 2 +- .../connection/MessageListenerWrapperTest.java | 4 +++- .../connection/ResponseExpectedRpcListenerTest.java | 5 ++++- .../impl/{ => core}/connection/RpcResponseKeyTest.java | 3 ++- .../{ => core}/connection/SimpleRpcListenerTest.java | 3 ++- .../connection/SwitchConnectionProviderImpl02Test.java | 4 +++- .../connection/SwitchConnectionProviderImplTest.java | 3 ++- .../impl/{ => core}/connection/UdpHandlerTest.java | 2 +- .../connection/UdpMessageListenerWrapperTest.java | 5 ++++- .../protocol/it/integration/IntegrationTest.java | 4 ++-- 49 files changed, 88 insertions(+), 60 deletions(-) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{connection => core}/OnlineProvider.java (89%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{connection => core}/ServerFacade.java (91%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{connection => core}/ShutdownProvider.java (89%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{connection => core}/SwitchConnectionProviderImpl.java (97%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/AbstractRpcListener.java (98%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ChannelOutboundQueue.java (99%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterFactory.java (90%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterFactoryImpl.java (91%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterImpl.java (99%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionFacade.java (88%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/MessageConsumer.java (88%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/MessageListenerWrapper.java (92%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ResponseExpectedRpcListener.java (96%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/RpcResponseKey.java (96%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/SimpleRpcListener.java (89%) rename openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/UdpMessageListenerWrapper.java (92%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ChannelOutboundQueue02Test.java (91%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ChannelOutboundQueueTest.java (82%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterFactoryImplTest.java (84%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterImp02lTest.java (95%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionAdapterImplTest.java (95%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ConnectionConfigurationImpl.java (97%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/MessageListenerWrapperTest.java (80%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/ResponseExpectedRpcListenerTest.java (92%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/RpcResponseKeyTest.java (92%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/SimpleRpcListenerTest.java (93%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/SwitchConnectionProviderImpl02Test.java (98%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/SwitchConnectionProviderImplTest.java (95%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/UdpHandlerTest.java (98%) rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/{ => core}/connection/UdpMessageListenerWrapperTest.java (90%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java index babb52f0..e0a013c1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java @@ -11,8 +11,8 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index 5dea0bc6..f4240bcc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -11,7 +11,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java index 631509d0..ab455f37 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -10,7 +10,7 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.impl.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index 0f1b8236..3bda7b21 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -17,10 +17,10 @@ import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 493fa007..f5b6e60d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -13,7 +13,7 @@ import io.netty.handler.codec.MessageToByteEncoder; import io.netty.util.concurrent.Future; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 9aa9863a..4bc5ce87 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -15,7 +15,7 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java similarity index 89% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java index 01207ec6..93b39d4f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/OnlineProvider.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core; import com.google.common.util.concurrent.ListenableFuture; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ServerFacade.java similarity index 91% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ServerFacade.java index 4759b657..560e910e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ServerFacade.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ServerFacade.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java similarity index 89% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java index facecb9f..a3372ef8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ShutdownProvider.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core; import com.google.common.util.concurrent.ListenableFuture; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java similarity index 97% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index aadddd6b..c016aee3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; @@ -29,9 +29,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.openflowjava.protocol.impl.core.ChannelInitializerFactory; -import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; -import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index b93a641d..6b974825 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -19,9 +19,9 @@ import javax.net.ssl.SSLEngine; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 59675b27..0c26354e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -22,7 +22,6 @@ import java.net.InetSocketAddress; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; -import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index 2eeaa3ec..d33f3a0b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; /** * As UDP communication is handled only by one channel, it is needed diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 8a04efa4..2ebeec76 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -20,7 +20,6 @@ import java.net.InetSocketAddress; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; -import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java similarity index 98% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java index 891dc17b..79708f65 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java similarity index 99% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index 2d50ff2b..47d694d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java similarity index 90% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java index cf4e83f0..046e2917 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetSocketAddress; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java similarity index 91% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java index 259dd6f5..5a67da8a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetSocketAddress; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java similarity index 99% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 5ebffd8f..c3f04c55 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionFacade.java similarity index 88% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionFacade.java index fc6d9e92..c56ab484 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionFacade.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionFacade.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageConsumer.java similarity index 88% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageConsumer.java index 81c1796e..84c45cee 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageConsumer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageConsumer.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java similarity index 92% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java index 68311d23..51ab4b82 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListener.java similarity index 96% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListener.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListener.java index a5bf896b..15df265d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListener.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.util.concurrent.TimeoutException; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java similarity index 96% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java index 5ec0c0b1..067c5603 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java @@ -7,7 +7,7 @@ */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListener.java similarity index 89% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListener.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListener.java index fa675bc5..fc738632 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListener.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; final class SimpleRpcListener extends AbstractRpcListener { public SimpleRpcListener(final Object message, final String failureInfo) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java similarity index 92% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java rename to openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java index 84bf0b19..56d004bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index b3cbeb29..95674fec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java index cc3d30c7..5e365b86 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java index ac063686..3baeb944 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java @@ -23,7 +23,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java index 9deef145..a3f5befc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandlerTest.java @@ -24,7 +24,7 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.openflowjava.util.ByteBufUtils; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java index 9cb7dca0..e05fbd98 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderTest.java @@ -25,7 +25,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java index 23b29460..69fc393e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java @@ -22,7 +22,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.opendaylight.openflowjava.util.ByteBufUtils; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index 2a503dd2..aa7a6e4a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -34,8 +34,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java index 990ce784..624aef08 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMapTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; /** * @author madamjak diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java similarity index 91% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java index c21f1cb8..3719d3dc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueue02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -23,6 +23,11 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java similarity index 82% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java index 7017eae2..dd9f4043 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ChannelOutboundQueueTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.channel.Channel; @@ -14,6 +14,8 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java similarity index 84% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java index 010953b3..cf5796e7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterFactoryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.mockito.Mockito.when; import io.netty.channel.Channel; @@ -15,6 +15,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java similarity index 95% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java index e9645cf8..bc9e93ba 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImp02lTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java @@ -5,20 +5,27 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; + import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; + import junit.framework.Assert; + import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -39,6 +46,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.RemovalListener; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java similarity index 95% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java index 80d53dd4..77d9e912 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.mockito.Matchers.any; import static org.mockito.Mockito.times; @@ -26,6 +26,9 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java similarity index 97% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java index 21aa55ab..a66e9768 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java similarity index 80% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java index e34a48a9..18992b62 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/MessageListenerWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java @@ -6,10 +6,12 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java similarity index 92% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java index aa33498f..32b6b931 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.junit.Assert.fail; @@ -18,6 +18,9 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java similarity index 92% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java index 6125db89..62b4613d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/RpcResponseKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java @@ -6,10 +6,11 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import org.junit.Test; import org.junit.Assert; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; /** * diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java similarity index 93% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java index 3f49196e..d5a7499c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SimpleRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.junit.Assert.fail; import static org.mockito.Mockito.times; @@ -23,6 +23,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java similarity index 98% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index c388c682..282087c4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetAddress; import java.net.UnknownHostException; @@ -30,6 +30,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.ServerFacade; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java similarity index 95% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 7a70f757..0c792fa2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetAddress; import java.net.UnknownHostException; @@ -21,6 +21,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java similarity index 98% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java index e6922c9a..0dd9ce3b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.io.IOException; import java.net.InetAddress; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java similarity index 90% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java index ae8a1035..0bf79017 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/UdpMessageListenerWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java @@ -6,16 +6,19 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.connection; +package org.opendaylight.openflowjava.protocol.impl.core.connection; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; + import java.net.InetSocketAddress; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; /** diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 89d5677a..a1440961 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -28,10 +28,10 @@ import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent; import org.opendaylight.openflowjava.protocol.impl.clients.UdpSimpleClient; import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent; -import org.opendaylight.openflowjava.protocol.impl.connection.ConnectionConfigurationImpl; -import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.impl.core.TcpHandler; import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionConfigurationImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; From 18eeba4cf7aa2cb2a3156ad0560ba44d03cd381e Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 5 Nov 2014 07:51:27 +0100 Subject: [PATCH 106/285] Statistics collection - initial change Change-Id: I0f252a08a40b93c5ee280d289b28bdd9c88d8419 Signed-off-by: Marian Adamjak Signed-off-by: Michal Polkorab --- .../protocol/impl/core/OFDecoder.java | 10 +- .../protocol/impl/core/OFEncoder.java | 8 +- .../connection/ConnectionAdapterImpl.java | 21 +- .../openflowjava/statistics/Counter.java | 79 ++++++ .../statistics/CounterEventTypes.java | 23 ++ .../statistics/StatisticsCounters.java | 120 ++++++++ .../src/main/resources/log4j.xml | 4 + .../impl/core/OFDecoderStatisticsTest.java | 110 ++++++++ .../impl/core/OFEncoderStatisticsTest.java | 102 +++++++ .../ConnectionAdapterImplStatisticsTest.java | 260 ++++++++++++++++++ .../statistics/StatisticsCountersTest.java | 86 ++++++ 11 files changed, 816 insertions(+), 7 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index 6cf14050..0ccd2955 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -14,6 +14,8 @@ import java.util.List; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; @@ -27,12 +29,13 @@ public class OFDecoder extends MessageToMessageDecoder { private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class); private DeserializationFactory deserializationFactory; - + private StatisticsCounters statisticsCounter; /** * Constructor of class */ public OFDecoder() { LOGGER.trace("Creating OF 1.3 Decoder"); + statisticsCounter = StatisticsCounters.getInstance(); } @Override @@ -49,14 +52,15 @@ protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, msg.getVersion()); if (dataObject == null) { LOGGER.warn("Translated POJO is null"); + statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } else { out.add(dataObject); + statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS); } } catch(Exception e) { LOGGER.warn("Message deserialization failed"); LOGGER.warn(e.getMessage(), e); - // TODO: delegate exception to allow easier deserialization - // debugging / deserialization problem awareness + statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } finally { msg.getMessageBuffer().release(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index f5b6e60d..6caf1bdf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -15,6 +15,8 @@ import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,9 +29,11 @@ public class OFEncoder extends MessageToByteEncoder { private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class); private SerializationFactory serializationFactory; - + private StatisticsCounters statisticsCounters; + /** Constructor of class */ public OFEncoder() { + statisticsCounters = StatisticsCounters.getInstance(); LOGGER.trace("Creating OF13Encoder"); } @@ -39,8 +43,10 @@ protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, LOGGER.trace("Encoding"); try { serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS); } catch(Exception e) { LOGGER.warn("Message serialization failed ", e); + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_FAIL); Future newFailedFuture = ctx.newFailedFuture(e); wrapper.getListener().operationComplete(newFailedFuture); out.clear(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index c3f04c55..e35c6064 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -19,6 +19,8 @@ import java.util.concurrent.TimeUnit; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; @@ -116,6 +118,7 @@ public void onRemoval( private OpenflowProtocolListener messageListener; private SystemNotificationsListener systemListener; private boolean disconnectOccured = false; + private StatisticsCounters statisticsCounters; /** * default ctor @@ -131,6 +134,7 @@ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress addr this.channel = Preconditions.checkNotNull(channel); this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); channel.pipeline().addLast(output); + statisticsCounters = StatisticsCounters.getInstance(); LOG.debug("ConnectionAdapter created"); } @@ -265,6 +269,7 @@ public void consume(final DataObject message) { return; } if (message instanceof Notification) { + // System events if (message instanceof DisconnectEvent) { systemListener.onDisconnectEvent((DisconnectEvent) message); @@ -272,25 +277,32 @@ public void consume(final DataObject message) { disconnectOccured = true; } else if (message instanceof SwitchIdleEvent) { systemListener.onSwitchIdleEvent((SwitchIdleEvent) message); - } - // OpenFlow messages - else if (message instanceof EchoRequestMessage) { + // OpenFlow messages + } else if (message instanceof EchoRequestMessage) { messageListener.onEchoRequestMessage((EchoRequestMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ErrorMessage) { messageListener.onErrorMessage((ErrorMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ExperimenterMessage) { messageListener.onExperimenterMessage((ExperimenterMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof FlowRemovedMessage) { messageListener.onFlowRemovedMessage((FlowRemovedMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof HelloMessage) { LOG.info("Hello received / branch"); messageListener.onHelloMessage((HelloMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof MultipartReplyMessage) { messageListener.onMultipartReplyMessage((MultipartReplyMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PacketInMessage) { messageListener.onPacketInMessage((PacketInMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PortStatusMessage) { messageListener.onPortStatusMessage((PortStatusMessage) message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else { LOG.warn("message listening not supported for type: {}", message.getClass()); } @@ -302,6 +314,7 @@ else if (message instanceof EchoRequestMessage) { if (listener != null) { LOG.debug("corresponding rpcFuture found"); listener.completed((OfHeader)message); + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); LOG.debug("after setting rpcFuture"); responseCache.invalidate(key); } else { @@ -338,6 +351,7 @@ private ListenableFuture> enqueueMessage(final AbstractRpcListe */ private ListenableFuture> sendToSwitchFuture( final DataObject input, final String failureInfo) { + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); return enqueueMessage(new SimpleRpcListener(input, failureInfo)); } @@ -361,6 +375,7 @@ private ListenableFuture listener = new ResponseExpectedRpcListener<>(input, failureInfo, responseCache, key); + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); return enqueueMessage(listener); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java new file mode 100644 index 00000000..7c539eff --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.statistics; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Counts statistics + * + * @author madamjak + */ +public class Counter { + + private AtomicLong counterValue; + private AtomicLong counterLastReadValue; + + /** + * Default constructor + */ + public Counter() { + counterValue = new AtomicLong(0L); + counterLastReadValue = new AtomicLong(0L); + } + + /** + * Increment current counter value + */ + public void incrementCounter(){ + counterValue.incrementAndGet(); + } + + /** + * @return the counterLastReadValue + */ + public long getCounterLastReadValue() { + return counterLastReadValue.get(); + } + + /** + * get current counter value and rewrite CounterLastReadValue by current value + * @return + */ + public long getCounterValue() { + return getCounterValue(true); + } + + /** + * get current counter value + * @param modifyLastReadValue + * true - CounterLastReadValue will be rewritten by current CounterValue + * false - no change CounterLastReadValue + * @return + */ + public long getCounterValue(boolean modifyLastReadValue) { + if(modifyLastReadValue){ + counterLastReadValue.set(counterValue.get()); + } + return counterValue.get(); + } + + /** + * set current counter value and CounterLastReadValue to 0 (zero) + */ + public void reset(){ + counterValue.set(0l); + counterLastReadValue.set(0l); + } + + @Override + public String toString() { + return "Current value: " + counterValue + " Previous read value: " + counterLastReadValue; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java new file mode 100644 index 00000000..be39a7bb --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.statistics; + +/** + * @author madamjak + * + */ +public enum CounterEventTypes { + DS_ENTERED_OFJAVA, + DS_ENCODE_SUCCESS, + DS_ENCODE_FAIL, + US_RECEIVED_IN_OFJAVA, + US_DECODE_SUCCESS, + US_DECODE_FAIL, + US_MESSAGE_PASS; +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java new file mode 100644 index 00000000..5b666e99 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.statistics; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author madamjak + * + */ +public final class StatisticsCounters { + + private static StatisticsCounters instanceHolder; + private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); + + private final Counter cntDSEncodeFail; + private final Counter cntDSEncodeSuccess; + private final Counter cntDSEnteredOFJava; + private final Counter cntUSDecodeFail; + private final Counter cntUSDecodeSuccess; + private final Counter cntUSMessagePass; + private final Counter cntUSReceivedOFJava; + //private Map countersMap; + + public static StatisticsCounters getInstance(){ + if (instanceHolder == null){ + instanceHolder = new StatisticsCounters(); + } + return instanceHolder; + } + + private StatisticsCounters() { + cntDSEncodeFail = new Counter(); + cntDSEncodeSuccess = new Counter(); + cntDSEnteredOFJava = new Counter(); + cntUSDecodeFail = new Counter(); + cntUSDecodeSuccess = new Counter(); + cntUSMessagePass = new Counter(); + cntUSReceivedOFJava = new Counter(); + LOGGER.debug("StaticsCounters (without Map) has been created"); +// countersMap = new ConcurrentHashMap<>(); +// countersMap.put(CounterEventTypes.DS_ENCODE_FAIL, new Counter()); +// countersMap.put(CounterEventTypes.DS_ENCODE_SUCCESS, new Counter()); +// countersMap.put(CounterEventTypes.DS_ENTERED_OFJAVA, new Counter()); +// countersMap.put(CounterEventTypes.US_DECODE_FAIL, new Counter()); +// countersMap.put(CounterEventTypes.US_DECODE_SUCCESS, new Counter()); +// countersMap.put(CounterEventTypes.US_MESSAGE_PASS, new Counter()); +// countersMap.put(CounterEventTypes.US_RECEIVED_IN_OFJAVA, new Counter()); +// LOGGER.debug("StaticsCounters (with Map) has been created"); + } + + /** + * Get given counter + * @param counterEventKey - key to identify counter + * @return + */ + public Counter getCounter(CounterEventTypes counterEventKey){ + if(counterEventKey == null){ + throw new IllegalArgumentException("counterEventKey can not be null"); + } + switch (counterEventKey){ + case DS_ENCODE_FAIL: + return cntDSEncodeFail; + case DS_ENCODE_SUCCESS: + return cntDSEncodeSuccess; + case DS_ENTERED_OFJAVA: + return cntDSEnteredOFJava; + case US_DECODE_FAIL: + return cntUSDecodeFail; + case US_DECODE_SUCCESS: + return cntUSDecodeSuccess; + case US_MESSAGE_PASS: + return cntUSMessagePass; + case US_RECEIVED_IN_OFJAVA: + return cntUSReceivedOFJava; + default: + throw new IllegalArgumentException("unknown counterEventKey"); + } +// return countersMap.get(counterEventKey); + } + + /** + * Increment value of given counter + * @param counterEventKey - key to identify counter + * @return + */ + public void incrementCounter(CounterEventTypes counterEventKey){ + getCounter(counterEventKey).incrementCounter(); + } + + /** + * Set values of all counter to 0 (zero) + */ + public void resetCounters(){ + cntDSEncodeFail.reset(); ; + cntDSEncodeSuccess.reset(); + cntDSEnteredOFJava.reset(); + cntUSDecodeFail.reset(); + cntUSDecodeSuccess.reset(); + cntUSMessagePass.reset(); + cntUSReceivedOFJava.reset(); +// countersMap.get(CounterEventTypes.DS_ENCODE_FAIL).reset(); +// countersMap.get(CounterEventTypes.DS_ENCODE_SUCCESS).reset(); +// countersMap.get(CounterEventTypes.DS_ENTERED_OFJAVA).reset(); +// countersMap.get(CounterEventTypes.US_DECODE_FAIL).reset(); +// countersMap.get(CounterEventTypes.US_DECODE_SUCCESS).reset(); +// countersMap.get(CounterEventTypes.US_MESSAGE_PASS).reset(); +// countersMap.get(CounterEventTypes.US_RECEIVED_IN_OFJAVA).reset(); + LOGGER.debug("StaticsCounters has been reset"); + } +} diff --git a/openflow-protocol-impl/src/main/resources/log4j.xml b/openflow-protocol-impl/src/main/resources/log4j.xml index 5c5c7d9f..75e1faac 100644 --- a/openflow-protocol-impl/src/main/resources/log4j.xml +++ b/openflow-protocol-impl/src/main/resources/log4j.xml @@ -8,6 +8,10 @@ + + + + diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java new file mode 100644 index 00000000..9462de15 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyShort; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author madamjak + * + */ +public class OFDecoderStatisticsTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoderStatisticsTest.class); + + @Mock ChannelHandlerContext mockChHndlrCtx ; + @Mock DeserializationFactory mockDeserializationFactory ; + @Mock DataObject mockDataObject ; + + private OFDecoder ofDecoder ; + private ByteBuf writeObj; + private VersionMessageWrapper inMsg; + private List outList; + private StatisticsCounters statCounters; + + /** + * Sets up test environment + * + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + ofDecoder = new OFDecoder() ; + ofDecoder.setDeserializationFactory( mockDeserializationFactory ) ; + outList = new ArrayList<>(); + statCounters = StatisticsCounters.getInstance(); + statCounters.resetCounters(); + } + + @After + public void tierDown(){ + statCounters.resetCounters(); + } + + @Test + public void testDecodeSuccesfullCounter() throws InterruptedException { + int count = 4; + when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )).thenReturn(mockDataObject); + try { + for(int i = 0; i future; + @Mock GenericFutureListener> listener; + + private StatisticsCounters statCounters; + private OFEncoder ofEncoder; + + @Before + public void initTest(){ + MockitoAnnotations.initMocks(this); + ofEncoder = new OFEncoder() ; + ofEncoder.setSerializationFactory(mockSerializationFactory) ; + statCounters = StatisticsCounters.getInstance(); + statCounters.resetCounters(); + } + + @After + public void tierDown(){ + statCounters.resetCounters(); + } + + @Test + public void testEncodeSuccessCounter() throws InterruptedException{ + int count = 4; + when(mockOut.readableBytes()).thenReturn(1); + when(wrapper.getMsg()).thenReturn(mockMsg); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + try { + for(int i = 0; i< count; i++){ + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); + } + } catch (Exception e) { + Assert.fail(); + } + LOGGER.debug("Waiting to event queue process"); + Assert.assertEquals("Wrong - bad counter value for OFEncoder encode succesfully ", count, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); + } + + @Test + public void testEncodeEncodeFailCounter() throws InterruptedException { + int count = 2; + when(wrapper.getMsg()).thenReturn(mockMsg); + when(wrapper.getListener()).thenReturn(listener); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + doThrow(new IllegalArgumentException()).when(mockSerializationFactory).messageToBuffer(anyShort(),any(ByteBuf.class), any(DataObject.class)); + try { + for(int i = 0; i< count; i++){ + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); + } + } catch (Exception e) { + Assert.fail(); + } + LOGGER.debug("Waiting to event queue process"); + Assert.assertEquals("Wrong - bad counter value for OFEncoder fail encode", count, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java new file mode 100644 index 00000000..49cadf48 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import static org.mockito.Mockito.when; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.channel.socket.SocketChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author madamjak + * + */ +public class ConnectionAdapterImplStatisticsTest { + private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock SystemNotificationsListener systemListener; + @Mock ConnectionReadyListener readyListener; + //@Mock Cache> mockCache; + @Mock ChannelFuture channelFuture; + @Mock OpenflowProtocolListener messageListener; + @Mock SocketChannel channel; + @Mock ChannelPipeline pipeline; + @Mock EchoInput echoInput; + @Mock BarrierInput barrierInput; + @Mock EchoReplyInput echoReplyInput; + @Mock ExperimenterInput experimenterInput; + @Mock FlowModInput flowModInput; + @Mock GetConfigInput getConfigInput; + @Mock GetFeaturesInput getFeaturesInput; + @Mock GetQueueConfigInput getQueueConfigInput; + @Mock GroupModInput groupModInput; + @Mock HelloInput helloInput; + @Mock MeterModInput meterModInput; + @Mock PacketOutInput packetOutInput; + @Mock MultipartRequestInput multipartRequestInput; + @Mock PortModInput portModInput; + @Mock RoleRequestInput roleRequestInput; + @Mock SetConfigInput setConfigInput; + @Mock TableModInput tableModInput; + @Mock GetAsyncInput getAsyncInput; + @Mock SetAsyncInput setAsyncInput; + + private ConnectionAdapterImpl adapter; + private Cache> cache; + private StatisticsCounters statCounters; + /** + * Initialize mocks + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + statCounters = StatisticsCounters.getInstance(); + statCounters.resetCounters(); + } + /** + * Disconnect adapter + */ + @After + public void tierDown(){ + if (adapter != null && adapter.isAlive()) { + adapter.disconnect(); + } + statCounters.resetCounters(); + } + /** + * Test statistic counter for all rpc calls + * @throws InterruptedException + */ + @Test + public void testEnterOFJavaCounter() throws InterruptedException { + EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + // -- barrier + adapter.barrier(barrierInput); + embChannel.runPendingTasks(); + // -- echo + adapter.echo(echoInput); + embChannel.runPendingTasks(); + // -- echoReply + adapter.echoReply(echoReplyInput); + embChannel.runPendingTasks(); + // -- experimenter + adapter.experimenter(experimenterInput); + embChannel.runPendingTasks(); + // -- flowMod + adapter.flowMod(flowModInput); + embChannel.runPendingTasks(); + // -- getConfig + adapter.getConfig(getConfigInput); + embChannel.runPendingTasks(); + // -- getFeatures + adapter.getFeatures(getFeaturesInput); + embChannel.runPendingTasks(); + // -- getQueueConfig + adapter.getQueueConfig(getQueueConfigInput); + embChannel.runPendingTasks(); + // -- groupMod + adapter.groupMod(groupModInput); + embChannel.runPendingTasks(); + // -- hello + adapter.hello(helloInput); + embChannel.runPendingTasks(); + // -- meterMod + adapter.meterMod(meterModInput); + embChannel.runPendingTasks(); + // -- packetOut + adapter.packetOut(packetOutInput); + embChannel.runPendingTasks(); + // -- multipartRequest + adapter.multipartRequest(multipartRequestInput); + embChannel.runPendingTasks(); + // -- portMod + adapter.portMod(portModInput); + embChannel.runPendingTasks(); + // -- roleRequest + adapter.roleRequest(roleRequestInput); + embChannel.runPendingTasks(); + // -- setConfig + adapter.setConfig(setConfigInput); + embChannel.runPendingTasks(); + // -- tableMod + adapter.tableMod(tableModInput); + embChannel.runPendingTasks(); + // -- getAsync + adapter.getAsync(getAsyncInput); + embChannel.runPendingTasks(); + // -- setAsync + adapter.setAsync(setAsyncInput); + embChannel.runPendingTasks(); + LOGGER.debug("Waiting to Event Queue process"); + Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl rpc methods", 19, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + adapter.disconnect(); + } + + @Test + public void testMessagePassCounter() throws InterruptedException { + when(channel.pipeline()).thenReturn(pipeline); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter.setMessageListener(messageListener); + adapter.setSystemListener(systemListener); + adapter.setConnectionReadyListener(readyListener); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + when(channel.disconnect()).thenReturn(channelFuture); + DataObject message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + message = new ErrorMessageBuilder().build(); + adapter.consume(message); + message = new ExperimenterMessageBuilder().build(); + adapter.consume(message); + message = new FlowRemovedMessageBuilder().build(); + adapter.consume(message); + message = new HelloMessageBuilder().build(); + adapter.consume(message); + message = new MultipartReplyMessageBuilder().build(); + adapter.consume(message); + message = new PacketInMessageBuilder().build(); + adapter.consume(message); + message = new PortStatusMessageBuilder().build(); + adapter.consume(message); + message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + LOGGER.debug("Waiting to Event Queue process"); + Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); + adapter.disconnect(); + } + + /** + * Channel Handler for testing + * @author madamjak + * + */ + private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, + ChannelPromise promise) throws Exception { + OfHeader responseOfCall = null; + if(msg instanceof MessageListenerWrapper){ + MessageListenerWrapper listener = (MessageListenerWrapper) msg; + OfHeader ofHeader = listener.getMsg(); + responseOfCall = ofHeader; + } + } + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java new file mode 100644 index 00000000..9f064d5f --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.statistics; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author madamjak + * + */ +public class StatisticsCountersTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); + private StatisticsCounters statCounters; + + @Before + public void initTest(){ + statCounters = StatisticsCounters.getInstance(); + statCounters.resetCounters(); + } + + @After + public void tierDown(){ + statCounters.resetCounters(); + } + + @Test + public void testCounterAll() throws InterruptedException{ + int testCount = 4; + incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); + incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS,testCount); + incrementCounter(CounterEventTypes.DS_ENCODE_FAIL,testCount); + incrementCounter(CounterEventTypes.US_DECODE_FAIL,testCount); + incrementCounter(CounterEventTypes.US_DECODE_SUCCESS,testCount); + incrementCounter(CounterEventTypes.US_MESSAGE_PASS,testCount); + incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA,testCount); + LOGGER.debug("Waiting to process event queue"); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENTERED_OFJAVA, testCount, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENCODE_SUCCESS, testCount, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENCODE_FAIL, testCount, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_DECODE_FAIL, testCount, statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_DECODE_SUCCESS, testCount, statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_MESSAGE_PASS, testCount, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_RECEIVED_IN_OFJAVA, testCount, statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue()); + statCounters.resetCounters(); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENTERED_OFJAVA, 0, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENCODE_SUCCESS, 0, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENCODE_FAIL, 0, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_DECODE_FAIL, 0, statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_DECODE_SUCCESS, 0, statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_MESSAGE_PASS, 0, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_RECEIVED_IN_OFJAVA, 0, statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue()); + } + + @Test + public void testCounterLastRead() throws InterruptedException{ + int testCount = 4; + incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); + LOGGER.debug("Waiting to process event queue"); + Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad value", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue(false)); + Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); + incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); + LOGGER.debug("Waiting to process event queue"); + Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad last read value.", 8,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + } + + private void incrementCounter(CounterEventTypes cet, int count){ + for(int i = 0; i< count; i++){ + statCounters.incrementCounter(cet); + } + } +} From 7421480539c71baf944f52114987aa3c0db2cfba Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Fri, 7 Nov 2014 14:17:10 +0100 Subject: [PATCH 107/285] Statistics collection added - added statistics counters and tests - collection configurable through configSubsystem Change-Id: I0b292174789fbb39ff7abd25fec9b53b35ff7927 Signed-off-by: Marian Adamjak Signed-off-by: Michal Polkorab --- .../connection/ConnectionConfiguration.java | 5 +- .../connection/StatisticsConfiguration.java | 17 + .../protocol/impl/core/OFDecoder.java | 1 + .../protocol/impl/core/OFEncoder.java | 4 + .../core/connection/ChannelOutboundQueue.java | 3 +- .../connection/ConnectionAdapterImpl.java | 1 + .../openflowjava/statistics/Counter.java | 13 +- .../statistics/CounterEventTypes.java | 30 ++ .../statistics/StatisticsCounters.java | 304 +++++++++++++----- .../SwitchConnectionProviderModule.java | 62 ++++ ...nflow-switch-connection-provider-impl.yang | 10 + .../impl/core/OFDecoderStatisticsTest.java | 95 ++++-- .../protocol/impl/core/OFDecoderTest.java | 1 - .../impl/core/OFEncoderStatisticsTest.java | 66 +++- .../connection/ChannelOutboundQueueTest.java | 3 +- .../ConnectionAdapterImplStatisticsTest.java | 81 ++--- .../ConnectionConfigurationImpl.java | 9 + .../statistics/StatisticsCountersTest.java | 126 +++++--- 18 files changed, 616 insertions(+), 215 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index 6a61b585..0ba121cc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -11,7 +11,6 @@ import java.net.InetAddress; import javax.net.ssl.SSLEngine; - import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; /** @@ -54,4 +53,8 @@ public interface ConnectionConfiguration { * @return thread numbers for TcpHandler's eventloopGroups */ ThreadConfiguration getThreadConfiguration(); + /** + * @return Statistics configuration + */ + StatisticsConfiguration getStatisticsConfiguration(); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java new file mode 100644 index 00000000..68cfa433 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +/** + * @author madamjak + * + */ +public interface StatisticsConfiguration { + Boolean getStatisticsCollect(); + Integer getLogReportDelay(); +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index 0ccd2955..386caa34 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -41,6 +41,7 @@ public OFDecoder() { @Override protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List out) throws Exception { + statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA); if (LOGGER.isDebugEnabled()) { LOGGER.debug("VersionMessageWrapper received"); LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 6caf1bdf..5a739497 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -17,6 +17,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.statistics.CounterEventTypes; import org.opendaylight.openflowjava.statistics.StatisticsCounters; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,6 +44,9 @@ protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, LOGGER.trace("Encoding"); try { serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); + if(wrapper.getMsg() instanceof FlowModInput){ + statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_SENT); + } statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS); } catch(Exception e) { LOGGER.warn("Message serialization failed ", e); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index 47d694d3..7a43db62 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -129,7 +129,7 @@ public boolean enqueue(final MessageHolder holder) { return true; } - LOG.trace("Message queue is full"); + LOG.debug("Message queue is full"); return false; } @@ -165,6 +165,7 @@ private void conditionalFlush() { * uncontended. */ private synchronized void flush() { + final long start = System.nanoTime(); final long deadline = start + maxWorkTime; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index e35c6064..7f1c0971 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -162,6 +162,7 @@ public Future> experimenter(final ExperimenterInput input) { @Override public Future> flowMod(final FlowModInput input) { + statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_ENTERED); return sendToSwitchFuture(input, "flow-mod sending failed"); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index 7c539eff..9d7ddc77 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.statistics; import java.util.concurrent.atomic.AtomicLong; - /** * Counts statistics * @@ -36,6 +35,8 @@ public void incrementCounter(){ } /** + * return the last read value of counter. This value can be set during the reading of current counter value, + * for detail see method getCounterValue(boolean modifyLastReadValue). * @return the counterLastReadValue */ public long getCounterLastReadValue() { @@ -43,8 +44,8 @@ public long getCounterLastReadValue() { } /** - * get current counter value and rewrite CounterLastReadValue by current value - * @return + * get current value of counter and rewrite CounterLastReadValue by current value + * @return the current value of counter */ public long getCounterValue() { return getCounterValue(true); @@ -55,7 +56,7 @@ public long getCounterValue() { * @param modifyLastReadValue * true - CounterLastReadValue will be rewritten by current CounterValue * false - no change CounterLastReadValue - * @return + * @return the current value of counter */ public long getCounterValue(boolean modifyLastReadValue) { if(modifyLastReadValue){ @@ -74,6 +75,8 @@ public void reset(){ @Override public String toString() { - return "Current value: " + counterValue + " Previous read value: " + counterLastReadValue; + long cntPrevVal = getCounterLastReadValue(); + long cntCurValue = getCounterValue(); + return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java index be39a7bb..0dd7faad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -9,15 +9,45 @@ package org.opendaylight.openflowjava.statistics; /** + * Enumeration of events to be counted with StatisticsCounters * @author madamjak * */ public enum CounterEventTypes { + /** + * enter message to OFJ and pass to downstream + */ DS_ENTERED_OFJAVA, + /** + * flow-mod is entered + */ + DS_FLOW_MODS_ENTERED, + /** + * encode message successfully + */ DS_ENCODE_SUCCESS, + /** + * fail encode message + */ DS_ENCODE_FAIL, + /** + * flow-mod encoded and sent to downstream + */ + DS_FLOW_MODS_SENT, + /** + * receive message and pass to upstream + */ US_RECEIVED_IN_OFJAVA, + /** + * decode message successfully + */ US_DECODE_SUCCESS, + /** + * fail decode message + */ US_DECODE_FAIL, + /** + * pass message to consumer (end of upstream) + */ US_MESSAGE_PASS; } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 5b666e99..34f072b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -8,113 +8,267 @@ package org.opendaylight.openflowjava.statistics; import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * Singleton class to hold and process counters * @author madamjak * */ public final class StatisticsCounters { + /** + * Default delay between two writings into log (milliseconds) + */ + public static final int DEFAULT_LOG_REPORT_PERIOD = 10000; + /** + * Minimal delay between two writings into log (milliseconds) + */ + public static final int MINIMAL_LOG_REPORT_PERIOD = 500; private static StatisticsCounters instanceHolder; private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); - private final Counter cntDSEncodeFail; - private final Counter cntDSEncodeSuccess; - private final Counter cntDSEnteredOFJava; - private final Counter cntUSDecodeFail; - private final Counter cntUSDecodeSuccess; - private final Counter cntUSMessagePass; - private final Counter cntUSReceivedOFJava; - //private Map countersMap; - - public static StatisticsCounters getInstance(){ - if (instanceHolder == null){ + private Timer logReporter; + private int logReportPeriod; + private boolean runLogReport; + private Map countersMap; + private boolean runCounting; + // array to hold enabled counter types + private CounterEventTypes[] enabledCounters = { + CounterEventTypes.DS_ENCODE_FAIL, + CounterEventTypes.DS_ENCODE_SUCCESS, + CounterEventTypes.DS_ENTERED_OFJAVA, + CounterEventTypes.DS_FLOW_MODS_ENTERED, + CounterEventTypes.DS_FLOW_MODS_SENT, + CounterEventTypes.US_DECODE_FAIL, + CounterEventTypes.US_DECODE_SUCCESS, + CounterEventTypes.US_MESSAGE_PASS, + CounterEventTypes.US_RECEIVED_IN_OFJAVA}; + + /** + * Get instance of statistics counters, first created object does not start counting and log reporting + * @return an instance + */ + public synchronized static StatisticsCounters getInstance() { + if (instanceHolder == null) { instanceHolder = new StatisticsCounters(); } return instanceHolder; } private StatisticsCounters() { - cntDSEncodeFail = new Counter(); - cntDSEncodeSuccess = new Counter(); - cntDSEnteredOFJava = new Counter(); - cntUSDecodeFail = new Counter(); - cntUSDecodeSuccess = new Counter(); - cntUSMessagePass = new Counter(); - cntUSReceivedOFJava = new Counter(); - LOGGER.debug("StaticsCounters (without Map) has been created"); -// countersMap = new ConcurrentHashMap<>(); -// countersMap.put(CounterEventTypes.DS_ENCODE_FAIL, new Counter()); -// countersMap.put(CounterEventTypes.DS_ENCODE_SUCCESS, new Counter()); -// countersMap.put(CounterEventTypes.DS_ENTERED_OFJAVA, new Counter()); -// countersMap.put(CounterEventTypes.US_DECODE_FAIL, new Counter()); -// countersMap.put(CounterEventTypes.US_DECODE_SUCCESS, new Counter()); -// countersMap.put(CounterEventTypes.US_MESSAGE_PASS, new Counter()); -// countersMap.put(CounterEventTypes.US_RECEIVED_IN_OFJAVA, new Counter()); -// LOGGER.debug("StaticsCounters (with Map) has been created"); - } - - /** - * Get given counter - * @param counterEventKey - key to identify counter - * @return - */ - public Counter getCounter(CounterEventTypes counterEventKey){ - if(counterEventKey == null){ - throw new IllegalArgumentException("counterEventKey can not be null"); + countersMap = new ConcurrentHashMap<>(); + for(CounterEventTypes cet : enabledCounters){ + countersMap.put(cet, new Counter()); + } + runCounting = false; + this.logReportPeriod = -1; + this.runLogReport = false; + LOGGER.debug("StaticsCounters has been created"); + } + + /** + * Start counting + * @param resetCounters - true = statistics counters will be reset before start counting + * @param reportToLogs - true = statistics counters will periodically write to log + * @param logReportDelay - delay between two writings into logs in milliseconds (for details see startLogReport(int logReportDelay)) + */ + public void startCounting(boolean resetCounters, boolean reportToLogs, int logReportDelay){ + if (runCounting) { + return; + } + LOGGER.debug("Start counting..."); + if(reportToLogs){ + startLogReport(logReportDelay); + } + if(resetCounters){ + resetCounters(); + } + runCounting = true; + } + + /** + * Start counting (counters are set to 0 before start counting) + * @param reportToLogs - true = statistics counters will periodically write to log + * @param logReportDelay - delay between two writings into logs in milliseconds (for details see startLogReport(int logReportDelay)) + */ + public void startCounting(boolean reportToLogs, int logReportDelay){ + if (runCounting) { + return; + } + startCounting(true,reportToLogs,logReportDelay); + } + + /** + * Stop counting, values in counters are untouched, log reporter is stopped + */ + public void stopCounting(){ + runCounting = false; + LOGGER.debug("Stop counting..."); + stopLogReport(); + } + + /** + * Give an information if counting is running + * @return true, if counting is running, otherwise false + */ + public boolean isRunCounting(){ + return runCounting; + } + + /** + * Start write statistics into logs, if writing is run calling has no effect. + * If method is called without previous setting of report delay than DEFAULT_LOG_REPORT_PERIOD will be used. + */ + public void startLogReport(){ + if(runLogReport){ + return; + } + if(this.logReportPeriod <= 0){ + this.logReportPeriod = DEFAULT_LOG_REPORT_PERIOD; + } + if(this.logReportPeriod <= MINIMAL_LOG_REPORT_PERIOD){ + this.logReportPeriod = MINIMAL_LOG_REPORT_PERIOD; + } + logReporter = new Timer("SC_Timer"); + logReporter.schedule(new LogReporterTask(this), this.logReportPeriod,this.logReportPeriod); + runLogReport = true; + LOGGER.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod); + } + + /** + * Start write statistics into logs with given delay between writings, if writing is run calling has no effect. + * @param logReportDelay - delay between two writings into logs (milliseconds). + * It is mandatory if reportToLogs is true, value have to be greater than 0 (zero) + * If value is smaller than MINIMAL_LOG_REPORT_PERIOD, the value MINIMAL_LOG_REPORT_PERIOD will be used. + * @exception IllegalArgumentException if logReportDelay is not greater than 0 (zero) + */ + public void startLogReport(int logReportDelay){ + if(runLogReport){ + return; + } + if(logReportDelay <= 0){ + throw new IllegalArgumentException("logReportPeriod have to bee greater than 0 zero"); } - switch (counterEventKey){ - case DS_ENCODE_FAIL: - return cntDSEncodeFail; - case DS_ENCODE_SUCCESS: - return cntDSEncodeSuccess; - case DS_ENTERED_OFJAVA: - return cntDSEnteredOFJava; - case US_DECODE_FAIL: - return cntUSDecodeFail; - case US_DECODE_SUCCESS: - return cntUSDecodeSuccess; - case US_MESSAGE_PASS: - return cntUSMessagePass; - case US_RECEIVED_IN_OFJAVA: - return cntUSReceivedOFJava; - default: - throw new IllegalArgumentException("unknown counterEventKey"); + if(logReportDelay < MINIMAL_LOG_REPORT_PERIOD){ + this.logReportPeriod = MINIMAL_LOG_REPORT_PERIOD; + } else { + this.logReportPeriod = logReportDelay; } -// return countersMap.get(counterEventKey); + startLogReport(); + } + + /** + * Stop write statistics into logs, counting does not stop + */ + public void stopLogReport(){ + if(runLogReport){ + if(logReporter != null){ + logReporter.cancel(); + LOGGER.debug("Statistics log reporter has been canceled"); + } + runLogReport = false; + } + } + + /** + * Give an information if log reporter is running (statistics are write into logs). + * @return true if log reporter writes statistics into log, otherwise false + */ + public boolean isRunLogReport(){ + return runLogReport; + } + + /** + * @return the current delay between two writings into logs + */ + public int getLogReportPeriod() { + return logReportPeriod; + } + + /** + * @return the enabled counters + */ + protected CounterEventTypes[] getEnabledCounters() { + return enabledCounters; + } + /** + * @return the countersMap + */ + protected Map getCountersMap() { + return countersMap; + } + + /** + * Give an information if is given counter is enabled + * @param counterEventKey + * @return true if counter has been Enabled, otherwise false + */ + public boolean isCounterEnabled(CounterEventTypes counterEventKey){ + if (counterEventKey == null) { + return false; + } + return countersMap.containsKey(counterEventKey); + } + + /** + * Get counter by counter event type + * @param counterEventKey key to identify counter (can not be null) + * @return - Counter object or null if counter has not been enabled + * @exception - IllegalArgumentException if counterEventKey is null + */ + public Counter getCounter(CounterEventTypes counterEventKey) { + if (counterEventKey == null) { + throw new IllegalArgumentException("counterEventKey can not be null"); + } + return countersMap.get(counterEventKey); } /** * Increment value of given counter - * @param counterEventKey - key to identify counter - * @return + * @param counterEventKey key to identify counter */ - public void incrementCounter(CounterEventTypes counterEventKey){ - getCounter(counterEventKey).incrementCounter(); + public void incrementCounter(CounterEventTypes counterEventKey) { + if(runCounting){ + if (isCounterEnabled(counterEventKey)){ + countersMap.get(counterEventKey).incrementCounter(); + } + } } /** * Set values of all counter to 0 (zero) */ - public void resetCounters(){ - cntDSEncodeFail.reset(); ; - cntDSEncodeSuccess.reset(); - cntDSEnteredOFJava.reset(); - cntUSDecodeFail.reset(); - cntUSDecodeSuccess.reset(); - cntUSMessagePass.reset(); - cntUSReceivedOFJava.reset(); -// countersMap.get(CounterEventTypes.DS_ENCODE_FAIL).reset(); -// countersMap.get(CounterEventTypes.DS_ENCODE_SUCCESS).reset(); -// countersMap.get(CounterEventTypes.DS_ENTERED_OFJAVA).reset(); -// countersMap.get(CounterEventTypes.US_DECODE_FAIL).reset(); -// countersMap.get(CounterEventTypes.US_DECODE_SUCCESS).reset(); -// countersMap.get(CounterEventTypes.US_MESSAGE_PASS).reset(); -// countersMap.get(CounterEventTypes.US_RECEIVED_IN_OFJAVA).reset(); + public void resetCounters() { + for(CounterEventTypes cet : enabledCounters){ + countersMap.get(cet).reset(); + } LOGGER.debug("StaticsCounters has been reset"); } + + /** + * internal class to process logReporter + * @author madamjak + * + */ + private static class LogReporterTask extends TimerTask { + private static final Logger LOG = LoggerFactory.getLogger(LogReporterTask.class); + + private StatisticsCounters sc; + public LogReporterTask(StatisticsCounters sc) { + this.sc = sc; + } + + @Override + public void run() { + for(CounterEventTypes cet : sc.getEnabledCounters()){ + LOG.debug(cet.toString() + ": " + sc.getCountersMap().get(cet).toString()); + } + } + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 95674fec..d6494108 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -13,9 +13,11 @@ import java.net.UnknownHostException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.StatisticsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; @@ -61,15 +63,18 @@ protected void customValidation(){ public java.lang.AutoCloseable createInstance() { LOG.info("SwitchConnectionProvider started."); SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); + StatisticsCounters sc = StatisticsCounters.getInstance(); try { ConnectionConfiguration connConfiguration = createConnectionConfiguration(); switchConnectionProviderImpl.setConfiguration(connConfiguration); + startStatistics(sc, connConfiguration.getStatisticsConfiguration()); } catch (UnknownHostException e) { throw new IllegalArgumentException(e.getMessage(), e); } return switchConnectionProviderImpl; } + /** * @return instance configuration object * @throws UnknownHostException @@ -81,6 +86,7 @@ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHo final Tls tlsConfig = getTls(); final Threads threads = getThreads(); final TransportProtocol transportProtocol = getTransportProtocol(); + final Statistics statistics = getStatistics(); return new ConnectionConfiguration() { @Override @@ -166,6 +172,31 @@ public int getBossThreadCount() { } }; } + @Override + public StatisticsConfiguration getStatisticsConfiguration(){ + return new StatisticsConfiguration() { + @Override + public Boolean getStatisticsCollect() { + if(statistics == null){ + return false; + } + if (statistics.getStatisticsCollect() == null){ + return false; + } + return statistics.getStatisticsCollect(); + } + @Override + public Integer getLogReportDelay() { + if(statistics == null){ + return -1; + } + if(statistics.getLogReportDelay() == null){ + return -1; + }; + return statistics.getLogReportDelay(); + } + }; + } }; } @@ -191,6 +222,37 @@ private static InetAddress extractIpAddressBin(IpAddress address) throws Unknown } } + /** + * Configure and start Statistics Counters by configuration parameters. + * No operations is performed if: + * - statisticsConfig is null + * - sc is null + * - sc is not null and if counting is running + * @param sc - statistic counter to configure and start + * @param statisticsConfig - configuration parameters + */ + private static void startStatistics(StatisticsCounters sc, StatisticsConfiguration statisticsConfig){ + if(statisticsConfig == null){ + return; + } + if(sc == null || sc.isRunCounting()){ + return; + } + Boolean toCollectStats = statisticsConfig.getStatisticsCollect(); + Integer logDelay = statisticsConfig.getLogReportDelay(); + if(toCollectStats != null && toCollectStats.booleanValue()){ + int logPeriod = -1; + if(logDelay != null){ + logPeriod = logDelay.intValue(); + } + if(logPeriod >0){ + sc.startCounting(true, logPeriod); + } else { + sc.startCounting(false, 0); + } + } + } + /** * @param value * @return diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index 6afd5c60..4ca31886 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -92,6 +92,16 @@ module openflow-switch-connection-provider-impl { type uint16; } } + container statistics { + leaf statistics-collect { + description "Toggle of collecting statistics"; + type boolean; + } + leaf log-report-delay { + description "Delay between statistics logs"; + type uint16; + } + } } } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java index 9462de15..4dd3f53b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java @@ -27,84 +27,115 @@ import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** + * Test to count decoder events (counters US_DECODE_SUCCESS, US_DECODE_FAIL and + * US_RECEIVED_IN_OFJAVA have to be enabled) + * * @author madamjak * */ public class OFDecoderStatisticsTest { - private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoderStatisticsTest.class); + @Mock ChannelHandlerContext mockChHndlrCtx; + @Mock DeserializationFactory mockDeserializationFactory; + @Mock DataObject mockDataObject; - @Mock ChannelHandlerContext mockChHndlrCtx ; - @Mock DeserializationFactory mockDeserializationFactory ; - @Mock DataObject mockDataObject ; - - private OFDecoder ofDecoder ; + private OFDecoder ofDecoder; private ByteBuf writeObj; private VersionMessageWrapper inMsg; private List outList; private StatisticsCounters statCounters; /** - * Sets up test environment - * + * Sets up test environment Start counting and reset counters before each + * test */ @Before public void setUp() { MockitoAnnotations.initMocks(this); - ofDecoder = new OFDecoder() ; - ofDecoder.setDeserializationFactory( mockDeserializationFactory ) ; + ofDecoder = new OFDecoder(); + ofDecoder.setDeserializationFactory(mockDeserializationFactory); outList = new ArrayList<>(); statCounters = StatisticsCounters.getInstance(); - statCounters.resetCounters(); + statCounters.startCounting(true, false, 0); } + /** + * Stop counting after each test + */ @After - public void tierDown(){ - statCounters.resetCounters(); + public void tierDown() { + statCounters.stopCounting(); } + /** + * Test decode success counter + */ @Test - public void testDecodeSuccesfullCounter() throws InterruptedException { + public void testDecodeSuccesfullCounter() { + if (!statCounters.isCounterEnabled(CounterEventTypes.US_DECODE_SUCCESS)) { + Assert.fail("Counter " + CounterEventTypes.US_DECODE_SUCCESS + " is not enable"); + } + if (!statCounters.isCounterEnabled(CounterEventTypes.US_DECODE_FAIL)) { + Assert.fail("Counter " + CounterEventTypes.US_DECODE_FAIL + " is not enable"); + } + if (!statCounters + .isCounterEnabled(CounterEventTypes.US_RECEIVED_IN_OFJAVA)) { + Assert.fail("Counter " + CounterEventTypes.US_RECEIVED_IN_OFJAVA + " is not enable"); + } int count = 4; - when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )).thenReturn(mockDataObject); + when(mockDeserializationFactory.deserialize(any(ByteBuf.class),anyShort())).thenReturn(mockDataObject); try { - for(int i = 0; i future; @Mock GenericFutureListener> listener; + @Mock FlowModInput mockFlowModInput; private StatisticsCounters statCounters; private OFEncoder ofEncoder; + /** + * Initialize tests, start and reset counters before each test + */ @Before - public void initTest(){ + public void initTlest(){ MockitoAnnotations.initMocks(this); ofEncoder = new OFEncoder() ; ofEncoder.setSerializationFactory(mockSerializationFactory) ; statCounters = StatisticsCounters.getInstance(); - statCounters.resetCounters(); + statCounters.startCounting(true,false, 0); } + /** + * Stop counting after each test + */ @After public void tierDown(){ - statCounters.resetCounters(); + statCounters.stopCounting(); } + /** + * Test counting of success encode (counter DS_ENCODE_SUCCESS has to be enabled) + */ @Test - public void testEncodeSuccessCounter() throws InterruptedException{ + public void testEncodeSuccessCounter() { + CounterEventTypes cet = CounterEventTypes.DS_ENCODE_SUCCESS; + if(! statCounters.isCounterEnabled(cet)){ + Assert.fail("Counter " + cet + " is not enabled."); + } int count = 4; when(mockOut.readableBytes()).thenReturn(1); when(wrapper.getMsg()).thenReturn(mockMsg); @@ -78,12 +90,41 @@ public void testEncodeSuccessCounter() throws InterruptedException{ } catch (Exception e) { Assert.fail(); } - LOGGER.debug("Waiting to event queue process"); - Assert.assertEquals("Wrong - bad counter value for OFEncoder encode succesfully ", count, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value for OFEncoder encode succesfully ", count, statCounters.getCounter(cet).getCounterValue()); } + /** + * Test counting of flow-mod sent (counter DS_FLOW_MODS_SENT has to be enabled) + */ @Test - public void testEncodeEncodeFailCounter() throws InterruptedException { + public void testFlowModSentCounter() { + CounterEventTypes cet = CounterEventTypes.DS_FLOW_MODS_SENT; + if(! statCounters.isCounterEnabled(cet)){ + Assert.fail("Counter " + cet + " is not enabled."); + } + int count = 4; + when(mockOut.readableBytes()).thenReturn(1); + when(wrapper.getMsg()).thenReturn(mockFlowModInput); + when(wrapper.getMsg().getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); + try { + for(int i = 0; i< count; i++){ + ofEncoder.encode(mockChHndlrCtx, wrapper, mockOut); + } + } catch (Exception e) { + Assert.fail(); + } + Assert.assertEquals("Wrong - bad counter value for OFEncoder flow-mod sent", count, statCounters.getCounter(cet).getCounterValue()); + } + /** + * Test counting of encode fail (counter DS_ENCODE_FAIL has to be enabled) + */ + + @Test + public void testEncodeEncodeFailCounter() { + CounterEventTypes cet = CounterEventTypes.DS_ENCODE_FAIL; + if(! statCounters.isCounterEnabled(cet)){ + Assert.fail("Counter " + cet + " is not enabled."); + } int count = 2; when(wrapper.getMsg()).thenReturn(mockMsg); when(wrapper.getListener()).thenReturn(listener); @@ -96,7 +137,6 @@ public void testEncodeEncodeFailCounter() throws InterruptedException { } catch (Exception e) { Assert.fail(); } - LOGGER.debug("Waiting to event queue process"); - Assert.assertEquals("Wrong - bad counter value for OFEncoder fail encode", count, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value for OFEncoder fail encode", count, statCounters.getCounter(cet).getCounterValue()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java index dd9f4043..cf50b626 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java @@ -46,7 +46,8 @@ public void testIncorrectQueueCreation() { @Test public void testEnqueue() { ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); - boolean enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + boolean enqueued; + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); Assert.assertTrue("Enqueue problem", enqueued); enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); Assert.assertFalse("Enqueue problem", enqueued); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java index 49cadf48..8429afde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -9,19 +9,16 @@ import static org.mockito.Mockito.when; import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.socket.SocketChannel; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; - import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -48,7 +45,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; @@ -60,8 +56,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -69,11 +63,12 @@ import com.google.common.cache.RemovalNotification; /** + * Test counters in ConnectionAdapter (at least DS_ENTERED_OFJAVA, DS_FLOW_MODS_ENTERED and US_MESSAGE_PASS counters have to be enabled) * @author madamjak * */ public class ConnectionAdapterImplStatisticsTest { - private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); + private static final int RPC_RESPONSE_EXPIRATION = 1; private static final RemovalListener> REMOVAL_LISTENER = new RemovalListener>() { @@ -83,10 +78,9 @@ public void onRemoval( notification.getValue().discard(); } }; - + @Mock SystemNotificationsListener systemListener; @Mock ConnectionReadyListener readyListener; - //@Mock Cache> mockCache; @Mock ChannelFuture channelFuture; @Mock OpenflowProtocolListener messageListener; @Mock SocketChannel channel; @@ -110,104 +104,101 @@ public void onRemoval( @Mock TableModInput tableModInput; @Mock GetAsyncInput getAsyncInput; @Mock SetAsyncInput setAsyncInput; - + private ConnectionAdapterImpl adapter; private Cache> cache; private StatisticsCounters statCounters; + /** * Initialize mocks + * Start counting and reset counters before each test */ @Before public void setUp() { MockitoAnnotations.initMocks(this); statCounters = StatisticsCounters.getInstance(); - statCounters.resetCounters(); + statCounters.startCounting(true,false, 0); } + /** * Disconnect adapter + * Stop counting after each test */ @After public void tierDown(){ if (adapter != null && adapter.isAlive()) { adapter.disconnect(); } - statCounters.resetCounters(); + statCounters.stopCounting(); } + /** - * Test statistic counter for all rpc calls - * @throws InterruptedException + * Test statistic counter for all rpc calls (counters DS_ENTERED_OFJAVA and DS_FLOW_MODS_ENTERED have to be enabled) */ @Test - public void testEnterOFJavaCounter() throws InterruptedException { + public void testEnterOFJavaCounter() { + if(!statCounters.isCounterEnabled(CounterEventTypes.DS_ENTERED_OFJAVA)){ + Assert.fail("Counter " + CounterEventTypes.DS_ENTERED_OFJAVA + " is not enabled"); + } + if(!statCounters.isCounterEnabled(CounterEventTypes.DS_FLOW_MODS_ENTERED)){ + Assert.fail("Counter " + CounterEventTypes.DS_FLOW_MODS_ENTERED + " is not enabled"); + } EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); - // -- barrier adapter.barrier(barrierInput); embChannel.runPendingTasks(); - // -- echo adapter.echo(echoInput); embChannel.runPendingTasks(); - // -- echoReply adapter.echoReply(echoReplyInput); embChannel.runPendingTasks(); - // -- experimenter adapter.experimenter(experimenterInput); embChannel.runPendingTasks(); - // -- flowMod adapter.flowMod(flowModInput); embChannel.runPendingTasks(); - // -- getConfig adapter.getConfig(getConfigInput); embChannel.runPendingTasks(); - // -- getFeatures adapter.getFeatures(getFeaturesInput); embChannel.runPendingTasks(); - // -- getQueueConfig adapter.getQueueConfig(getQueueConfigInput); embChannel.runPendingTasks(); - // -- groupMod adapter.groupMod(groupModInput); embChannel.runPendingTasks(); - // -- hello adapter.hello(helloInput); embChannel.runPendingTasks(); - // -- meterMod adapter.meterMod(meterModInput); embChannel.runPendingTasks(); - // -- packetOut adapter.packetOut(packetOutInput); embChannel.runPendingTasks(); - // -- multipartRequest adapter.multipartRequest(multipartRequestInput); embChannel.runPendingTasks(); - // -- portMod adapter.portMod(portModInput); embChannel.runPendingTasks(); - // -- roleRequest adapter.roleRequest(roleRequestInput); embChannel.runPendingTasks(); - // -- setConfig adapter.setConfig(setConfigInput); embChannel.runPendingTasks(); - // -- tableMod adapter.tableMod(tableModInput); embChannel.runPendingTasks(); - // -- getAsync adapter.getAsync(getAsyncInput); embChannel.runPendingTasks(); - // -- setAsync adapter.setAsync(setAsyncInput); embChannel.runPendingTasks(); - LOGGER.debug("Waiting to Event Queue process"); Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl rpc methods", 19, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl flow-mod entered", 1, statCounters.getCounter(CounterEventTypes.DS_FLOW_MODS_ENTERED).getCounterValue()); adapter.disconnect(); } + /** + * Test counter for pass messages to consumer (counter US_MESSAGE_PASS has to be enabled) + */ @Test - public void testMessagePassCounter() throws InterruptedException { + public void testMessagePassCounter() { + if(!statCounters.isCounterEnabled(CounterEventTypes.US_MESSAGE_PASS)){ + Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled"); + } when(channel.pipeline()).thenReturn(pipeline); adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); adapter.setMessageListener(messageListener); @@ -235,26 +226,16 @@ public void testMessagePassCounter() throws InterruptedException { adapter.consume(message); message = new EchoRequestMessageBuilder().build(); adapter.consume(message); - LOGGER.debug("Waiting to Event Queue process"); Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); adapter.disconnect(); } - + /** - * Channel Handler for testing + * Empty channel Handler for testing * @author madamjak * */ private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { - @Override - public void write(ChannelHandlerContext ctx, Object msg, - ChannelPromise promise) throws Exception { - OfHeader responseOfCall = null; - if(msg instanceof MessageListenerWrapper){ - MessageListenerWrapper listener = (MessageListenerWrapper) msg; - OfHeader ofHeader = listener.getMsg(); - responseOfCall = ofHeader; - } - } + // no operation need to test } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java index a66e9768..ec947e9a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java @@ -11,9 +11,11 @@ import java.net.InetAddress; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.StatisticsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.modules.module.configuration.openflow._switch.connection.provider.impl.Statistics; /** * @author michal.polkorab @@ -28,6 +30,7 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration { private long switchIdleTimeout; private ThreadConfiguration threadConfig; private TransportProtocol protocol; + private Statistics statistics; /** * Creates {@link ConnectionConfigurationImpl} @@ -93,4 +96,10 @@ public ThreadConfiguration getThreadConfiguration() { public void setThreadConfiguration(ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } + + @Override + public StatisticsConfiguration getStatisticsConfiguration() { + // TODO Auto-generated method stub + return null; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java index 9f064d5f..1bb549b6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; /** + * General tests for StatisticsCounters class * @author madamjak * */ @@ -23,62 +24,115 @@ public class StatisticsCountersTest { private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); private StatisticsCounters statCounters; + /** + * Initialize StatisticsCounters before each test, reset counters + */ @Before public void initTest(){ statCounters = StatisticsCounters.getInstance(); - statCounters.resetCounters(); + statCounters.startCounting(true,false, 0); } + /** + * Stop counting after each test + */ @After public void tierDown(){ - statCounters.resetCounters(); + statCounters.stopCounting(); } + /** + * Basic test of increment and reset counters + */ @Test - public void testCounterAll() throws InterruptedException{ + public void testCounterAll() { int testCount = 4; - incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); - incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS,testCount); - incrementCounter(CounterEventTypes.DS_ENCODE_FAIL,testCount); - incrementCounter(CounterEventTypes.US_DECODE_FAIL,testCount); - incrementCounter(CounterEventTypes.US_DECODE_SUCCESS,testCount); - incrementCounter(CounterEventTypes.US_MESSAGE_PASS,testCount); - incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA,testCount); - LOGGER.debug("Waiting to process event queue"); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENTERED_OFJAVA, testCount, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENCODE_SUCCESS, testCount, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.DS_ENCODE_FAIL, testCount, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_DECODE_FAIL, testCount, statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_DECODE_SUCCESS, testCount, statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_MESSAGE_PASS, testCount, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value " + CounterEventTypes.US_RECEIVED_IN_OFJAVA, testCount, statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue()); + for(CounterEventTypes cet : CounterEventTypes.values()){ + if(statCounters.isCounterEnabled(cet)){ + incrementCounter(cet,testCount); + Assert.assertEquals("Wrong - bad counter value " + cet, testCount, statCounters.getCounter(cet).getCounterValue()); + } else { + Assert.assertNull("Wrong - not enabled counter give not null value", statCounters.getCounter(cet)); + } + + } statCounters.resetCounters(); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENTERED_OFJAVA, 0, statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENCODE_SUCCESS, 0, statCounters.getCounter(CounterEventTypes.DS_ENCODE_SUCCESS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.DS_ENCODE_FAIL, 0, statCounters.getCounter(CounterEventTypes.DS_ENCODE_FAIL).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_DECODE_FAIL, 0, statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_DECODE_SUCCESS, 0, statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_MESSAGE_PASS, 0, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue()); - Assert.assertEquals("Wrong - bad counter value after reset " + CounterEventTypes.US_RECEIVED_IN_OFJAVA, 0, statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue()); + for(CounterEventTypes cet : CounterEventTypes.values()){ + if(statCounters.isCounterEnabled(cet)){ + Assert.assertEquals("Wrong - bad counter value after reset " + cet, 0, statCounters.getCounter(cet).getCounterValue()); + } + } } + /** + * Test to store current and last read value of counter (at least one counter has to be enabled) + */ @Test - public void testCounterLastRead() throws InterruptedException{ + public void testCounterLastRead() { int testCount = 4; - incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); - LOGGER.debug("Waiting to process event queue"); - Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); - Assert.assertEquals("Wrong - bad value", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue(false)); - Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); - Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); - Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); - incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA,testCount); + CounterEventTypes firstEnabledCET = null; + for(CounterEventTypes cet : CounterEventTypes.values()){ + if(statCounters.isCounterEnabled(cet)){ + firstEnabledCET = cet; + break; + } + } + if(firstEnabledCET == null){ + Assert.fail("No counter is enabled"); + } + incrementCounter(firstEnabledCET,testCount); LOGGER.debug("Waiting to process event queue"); - Assert.assertEquals("Wrong - bad last read value.", 4,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterLastReadValue()); - Assert.assertEquals("Wrong - bad last read value.", 8,statCounters.getCounter(CounterEventTypes.DS_ENTERED_OFJAVA).getCounterValue()); + Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad value", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue(false)); + Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue()); + Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); + incrementCounter(firstEnabledCET,testCount); + Assert.assertEquals("Wrong - bad last read value.", testCount,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); + Assert.assertEquals("Wrong - bad last read value.", 2*testCount,statCounters.getCounter(firstEnabledCET).getCounterValue()); + } + + /** + * Test start and stop log reporter + */ + @Test + public void testStartStopLogReporter(){ + int testDelay = 10000; + statCounters.startLogReport(testDelay); + Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); + Assert.assertEquals("Wrong - bad logReportPeriod", testDelay, statCounters.getLogReportPeriod()); + statCounters.startLogReport(); + Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); + Assert.assertEquals("Wrong - bad logReportPeriod", testDelay, statCounters.getLogReportPeriod()); + statCounters.stopLogReport(); + Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport()); + statCounters.startLogReport(statCounters.MINIMAL_LOG_REPORT_PERIOD / 2); + Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); + Assert.assertEquals("Wrong - bad logReportPeriod", statCounters.MINIMAL_LOG_REPORT_PERIOD, statCounters.getLogReportPeriod()); + statCounters.stopCounting(); + Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport()); + } + + /** + * Test start log report with bad logReportDealy + */ + @Test(expected = IllegalArgumentException.class) + public void testLogReportBadPeriod(){ + statCounters.startLogReport(-1); + } + + /** + * Test to get counter with null key + */ + @Test(expected = IllegalArgumentException.class) + public void testGetCounterbyNull(){ + statCounters.getCounter(null); } private void incrementCounter(CounterEventTypes cet, int count){ + if(!statCounters.isCounterEnabled(cet)){ + return; + } for(int i = 0; i< count; i++){ statCounters.incrementCounter(cet); } From f7f6622d4de5ea6c70a24c583d42020301b69cf3 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 13 Nov 2014 16:20:44 +0100 Subject: [PATCH 108/285] JConsole support for statistics collection - sevice identity moved to spi - removed unnecessary methods - toString() renamed to getStat() Change-Id: I84d8c2f333f11c202b3cbb82f55578ea3f7961f9 Signed-off-by: Michal Polkorab --- .../connection/ConnectionConfiguration.java | 4 - .../connection/StatisticsConfiguration.java | 18 ++- .../openflowjava/statistics/Counter.java | 6 +- .../statistics/StatisticsCounters.java | 92 +++++-------- .../rev140328/StatisticsCollectionModule.java | 121 ++++++++++++++++++ .../StatisticsCollectionModuleFactory.java | 13 ++ .../SwitchConnectionProviderModule.java | 64 +-------- ...nflow-switch-connection-provider-impl.yang | 76 ++++++++++- .../impl/core/OFDecoderStatisticsTest.java | 2 +- .../impl/core/OFEncoderStatisticsTest.java | 2 +- .../ConnectionAdapterImplStatisticsTest.java | 2 +- .../ConnectionConfigurationImpl.java | 10 -- .../statistics/StatisticsCountersTest.java | 7 +- openflow-protocol-spi/pom.xml | 2 +- .../spi/statistics/StatisticsHandler.java | 28 ++++ .../openflow-switch-connection-provider.yang | 7 + 16 files changed, 302 insertions(+), 152 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModuleFactory.java create mode 100644 openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index 0ba121cc..243f2d93 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -53,8 +53,4 @@ public interface ConnectionConfiguration { * @return thread numbers for TcpHandler's eventloopGroups */ ThreadConfiguration getThreadConfiguration(); - /** - * @return Statistics configuration - */ - StatisticsConfiguration getStatisticsConfiguration(); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java index 68cfa433..e5b25d40 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java @@ -5,13 +5,23 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ + package org.opendaylight.openflowjava.protocol.api.connection; /** + * Used for StatisticsCounter configuration + * * @author madamjak - * */ public interface StatisticsConfiguration { - Boolean getStatisticsCollect(); - Integer getLogReportDelay(); -} + + /** + * @return true if statistics are / will be collected, false otherwise + */ + boolean getStatisticsCollect(); + + /** + * @return delay between two statistics logs (in milliseconds) + */ + int getLogReportDelay(); +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index 9d7ddc77..c5f18729 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -73,8 +73,10 @@ public void reset(){ counterLastReadValue.set(0l); } - @Override - public String toString() { + /** + * @return last and current count for specified statistic + */ + public String getStat() { long cntPrevVal = getCounterLastReadValue(); long cntCurValue = getCounterValue(); return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 34f072b0..951969ab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -12,6 +12,7 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; +import org.opendaylight.openflowjava.protocol.spi.statistics.StatisticsHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +21,7 @@ * @author madamjak * */ -public final class StatisticsCounters { +public final class StatisticsCounters implements StatisticsHandler { /** * Default delay between two writings into log (milliseconds) @@ -67,43 +68,28 @@ private StatisticsCounters() { countersMap.put(cet, new Counter()); } runCounting = false; - this.logReportPeriod = -1; + this.logReportPeriod = 0; this.runLogReport = false; LOGGER.debug("StaticsCounters has been created"); } /** - * Start counting - * @param resetCounters - true = statistics counters will be reset before start counting - * @param reportToLogs - true = statistics counters will periodically write to log - * @param logReportDelay - delay between two writings into logs in milliseconds (for details see startLogReport(int logReportDelay)) + * Start counting (counters are set to 0 before counting starts) + * @param reportToLogs - true = statistic counters will periodically log + * @param logReportDelay - delay between two logs (in milliseconds) */ - public void startCounting(boolean resetCounters, boolean reportToLogs, int logReportDelay){ + public void startCounting(boolean reportToLogs, int logReportDelay){ if (runCounting) { return; } - LOGGER.debug("Start counting..."); + resetCounters(); + LOGGER.debug("Counting started..."); if(reportToLogs){ startLogReport(logReportDelay); } - if(resetCounters){ - resetCounters(); - } runCounting = true; } - /** - * Start counting (counters are set to 0 before start counting) - * @param reportToLogs - true = statistics counters will periodically write to log - * @param logReportDelay - delay between two writings into logs in milliseconds (for details see startLogReport(int logReportDelay)) - */ - public void startCounting(boolean reportToLogs, int logReportDelay){ - if (runCounting) { - return; - } - startCounting(true,reportToLogs,logReportDelay); - } - /** * Stop counting, values in counters are untouched, log reporter is stopped */ @@ -122,49 +108,30 @@ public boolean isRunCounting(){ } /** - * Start write statistics into logs, if writing is run calling has no effect. - * If method is called without previous setting of report delay than DEFAULT_LOG_REPORT_PERIOD will be used. - */ - public void startLogReport(){ - if(runLogReport){ - return; - } - if(this.logReportPeriod <= 0){ - this.logReportPeriod = DEFAULT_LOG_REPORT_PERIOD; - } - if(this.logReportPeriod <= MINIMAL_LOG_REPORT_PERIOD){ - this.logReportPeriod = MINIMAL_LOG_REPORT_PERIOD; - } - logReporter = new Timer("SC_Timer"); - logReporter.schedule(new LogReporterTask(this), this.logReportPeriod,this.logReportPeriod); - runLogReport = true; - LOGGER.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod); - } - - /** - * Start write statistics into logs with given delay between writings, if writing is run calling has no effect. - * @param logReportDelay - delay between two writings into logs (milliseconds). - * It is mandatory if reportToLogs is true, value have to be greater than 0 (zero) - * If value is smaller than MINIMAL_LOG_REPORT_PERIOD, the value MINIMAL_LOG_REPORT_PERIOD will be used. - * @exception IllegalArgumentException if logReportDelay is not greater than 0 (zero) + * Prints statistics with given delay between logs + * @param logReportDelay - delay between two logs (in milliseconds) + * @exception IllegalArgumentException if logReportDelay is less than 0 */ public void startLogReport(int logReportDelay){ if(runLogReport){ return; } if(logReportDelay <= 0){ - throw new IllegalArgumentException("logReportPeriod have to bee greater than 0 zero"); + throw new IllegalArgumentException("logReportDelay has to be greater than 0"); } if(logReportDelay < MINIMAL_LOG_REPORT_PERIOD){ this.logReportPeriod = MINIMAL_LOG_REPORT_PERIOD; } else { this.logReportPeriod = logReportDelay; } - startLogReport(); + logReporter = new Timer("SC_Timer"); + logReporter.schedule(new LogReporterTask(this), this.logReportPeriod, this.logReportPeriod); + runLogReport = true; + LOGGER.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod); } /** - * Stop write statistics into logs, counting does not stop + * Stops logging, counting continues */ public void stopLogReport(){ if(runLogReport){ @@ -217,7 +184,7 @@ public boolean isCounterEnabled(CounterEventTypes counterEventKey){ } /** - * Get counter by counter event type + * Get counter by CounterEventType * @param counterEventKey key to identify counter (can not be null) * @return - Counter object or null if counter has not been enabled * @exception - IllegalArgumentException if counterEventKey is null @@ -241,9 +208,7 @@ public void incrementCounter(CounterEventTypes counterEventKey) { } } - /** - * Set values of all counter to 0 (zero) - */ + @Override public void resetCounters() { for(CounterEventTypes cet : enabledCounters){ countersMap.get(cet).reset(); @@ -251,6 +216,15 @@ public void resetCounters() { LOGGER.debug("StaticsCounters has been reset"); } + @Override + public String printStatistics() { + StringBuilder strBuilder = new StringBuilder(); + for(CounterEventTypes cet : getEnabledCounters()){ + strBuilder.append(cet.name() + ": " + getCountersMap().get(cet).getStat() + "\n"); + } + return strBuilder.toString(); + } + /** * internal class to process logReporter * @author madamjak @@ -266,9 +240,9 @@ public LogReporterTask(StatisticsCounters sc) { @Override public void run() { - for(CounterEventTypes cet : sc.getEnabledCounters()){ - LOG.debug(cet.toString() + ": " + sc.getCountersMap().get(cet).toString()); - } + for(CounterEventTypes cet : sc.getEnabledCounters()){ + LOG.debug(cet.name() + ": " + sc.getCountersMap().get(cet).getStat()); + } } } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java new file mode 100644 index 00000000..ff686c16 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java @@ -0,0 +1,121 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328; + +import org.opendaylight.openflowjava.protocol.api.connection.StatisticsConfiguration; +import org.opendaylight.openflowjava.protocol.spi.statistics.StatisticsHandler; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** +* This is the definition of statistics collection module identity. +*/ +public class StatisticsCollectionModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractStatisticsCollectionModule { + + private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCollectionModule.class); + + public StatisticsCollectionModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public StatisticsCollectionModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.StatisticsCollectionModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + final Statistics statistics = getStatistics(); + final StatisticsCounters statsCounter = StatisticsCounters.getInstance(); + StatisticsConfiguration statsConfig = null; + if (statistics != null) { + statsConfig = new StatisticsConfiguration() { + + @Override + public boolean getStatisticsCollect() { + if (statistics.getStatisticsCollect() != null) { + return statistics.getStatisticsCollect().booleanValue(); + } + return false; + } + + @Override + public int getLogReportDelay() { + if (statistics.getLogReportDelay() != null) { + return statistics.getLogReportDelay().intValue(); + } + return 0; + } + }; + } else { + LOGGER.error("STATISTICS ARE NULL"); + } + LOGGER.error("config " + statsConfig); + if (statsConfig != null) { + statsCounter.startCounting(statsConfig.getStatisticsCollect(), statsConfig.getLogReportDelay()); + } else { + LOGGER.debug("Unable to start StatisticCounter - wrong configuration"); + } + + /* Internal MXBean implementation */ + final StatisticsCollectionRuntimeMXBean collectionBean = new StatisticsCollectionRuntimeMXBean() { + + @Override + public String printOfjavaStatistics() { + if (statsCounter != null) { + return statsCounter.printStatistics(); + } + return "Statistics collection is not avaliable."; + } + @Override + public String getMsgStatistics() { + return printOfjavaStatistics(); + } + @Override + public String resetOfjavaStatistics() { + statsCounter.resetCounters(); + return "Statistics have been reset"; + } + }; + + /* MXBean registration */ + final StatisticsCollectionRuntimeRegistration runtimeReg = + getRootRuntimeBeanRegistratorWrapper().register(collectionBean); + + /* Internal StatisticsCollectionService implementation */ + final class AutoClosableStatisticsCollection implements StatisticsHandler, AutoCloseable { + + @Override + public void close() { + if (runtimeReg != null) { + try { + runtimeReg.close(); + } + catch (Exception e) { + String errMsg = "Error by stoping StatisticsCollectionService."; + LOGGER.error(errMsg, e); + throw new IllegalStateException(errMsg, e); + } + } + LOGGER.info("StatisticsCollection Service consumer (instance {} turn down.)", this); + } + + @Override + public void resetCounters() { + statsCounter.resetCounters(); + } + + @Override + public String printStatistics() { + return statsCounter.printStatistics(); + } + } + + AutoCloseable ret = new AutoClosableStatisticsCollection(); + LOGGER.info("StatisticsCollection service (instance {}) initialized.", ret); + return ret; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModuleFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModuleFactory.java new file mode 100644 index 00000000..04db2fa8 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: openflow-switch-connection-provider-impl yang module local name: statistics-collection-service-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Nov 13 12:52:26 CET 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328; +public class StatisticsCollectionModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractStatisticsCollectionModuleFactory { + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index d6494108..fd5cf8aa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -13,11 +13,9 @@ import java.net.UnknownHostException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.StatisticsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; -import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; @@ -63,18 +61,15 @@ protected void customValidation(){ public java.lang.AutoCloseable createInstance() { LOG.info("SwitchConnectionProvider started."); SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); - StatisticsCounters sc = StatisticsCounters.getInstance(); try { ConnectionConfiguration connConfiguration = createConnectionConfiguration(); switchConnectionProviderImpl.setConfiguration(connConfiguration); - startStatistics(sc, connConfiguration.getStatisticsConfiguration()); } catch (UnknownHostException e) { throw new IllegalArgumentException(e.getMessage(), e); } return switchConnectionProviderImpl; } - /** * @return instance configuration object * @throws UnknownHostException @@ -86,8 +81,7 @@ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHo final Tls tlsConfig = getTls(); final Threads threads = getThreads(); final TransportProtocol transportProtocol = getTransportProtocol(); - final Statistics statistics = getStatistics(); - + return new ConnectionConfiguration() { @Override public InetAddress getAddress() { @@ -172,31 +166,6 @@ public int getBossThreadCount() { } }; } - @Override - public StatisticsConfiguration getStatisticsConfiguration(){ - return new StatisticsConfiguration() { - @Override - public Boolean getStatisticsCollect() { - if(statistics == null){ - return false; - } - if (statistics.getStatisticsCollect() == null){ - return false; - } - return statistics.getStatisticsCollect(); - } - @Override - public Integer getLogReportDelay() { - if(statistics == null){ - return -1; - } - if(statistics.getLogReportDelay() == null){ - return -1; - }; - return statistics.getLogReportDelay(); - } - }; - } }; } @@ -222,37 +191,6 @@ private static InetAddress extractIpAddressBin(IpAddress address) throws Unknown } } - /** - * Configure and start Statistics Counters by configuration parameters. - * No operations is performed if: - * - statisticsConfig is null - * - sc is null - * - sc is not null and if counting is running - * @param sc - statistic counter to configure and start - * @param statisticsConfig - configuration parameters - */ - private static void startStatistics(StatisticsCounters sc, StatisticsConfiguration statisticsConfig){ - if(statisticsConfig == null){ - return; - } - if(sc == null || sc.isRunCounting()){ - return; - } - Boolean toCollectStats = statisticsConfig.getStatisticsCollect(); - Integer logDelay = statisticsConfig.getLogReportDelay(); - if(toCollectStats != null && toCollectStats.booleanValue()){ - int logPeriod = -1; - if(logDelay != null){ - logPeriod = logDelay.intValue(); - } - if(logPeriod >0){ - sc.startCounting(true, logPeriod); - } else { - sc.startCounting(false, 0); - } - } - } - /** * @param value * @return diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index 4ca31886..cb714d6b 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -7,6 +7,7 @@ module openflow-switch-connection-provider-impl { import openflow-switch-connection-provider {prefix openflow-switch-connection-provider; revision-date 2014-03-28; } import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; } import openflow-configuration {prefix of-config; revision-date 2014-06-30; } + import rpc-context { prefix rpcx; revision-date 2013-06-17; } description "openflow-switch-connection-provider"; @@ -22,6 +23,13 @@ module openflow-switch-connection-provider-impl { config:java-name-prefix SwitchConnectionProvider; } + identity statistics-collection-service-impl { + description + "This is the definition of statistics collection module identity."; + base config:module-type; + config:provided-service openflow-switch-connection-provider:statistics-collection-service; + config:java-name-prefix StatisticsCollection; + } augment "/config:modules/config:module/config:configuration" { case openflow-switch-connection-provider-impl { @@ -92,9 +100,14 @@ module openflow-switch-connection-provider-impl { type uint16; } } + } + + case statistics-collection-service-impl { + when "/config:modules/config:module/config:type = 'statistics-collection-service-impl'"; + container statistics { leaf statistics-collect { - description "Toggle of collecting statistics"; + description "Toggle statistics collecting"; type boolean; } leaf log-report-delay { @@ -102,6 +115,67 @@ module openflow-switch-connection-provider-impl { type uint16; } } + list openflow-switch-connection-provider { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity openflow-switch-connection-provider:openflow-switch-connection-provider; + } + } + } + } + } + + augment "/config:modules/config:module/config:state" { + case statistics-collection-service-impl { + when "/config:modules/config:module/config:type = 'statistics-collection-service-impl'"; + + description + "MXBean designed for Message Statistic providing to JConsole."; + + leaf msgStatistics { + type string; + } + + rpcx:rpc-context-instance "print-ofjava-statistics-rpc"; + rpcx:rpc-context-instance "reset-ofjava-statistics-rpc"; + } + } + + identity print-ofjava-statistics-rpc; + identity reset-ofjava-statistics-rpc; + + rpc print-ofjava-statistics { + description + "Shortcut JMX call to printOfjavaStatistics."; + input { + uses rpcx:rpc-context-ref { + refine context-instance { + rpcx:rpc-context-instance print-ofjava-statistics-rpc; + } + } + } + output { + leaf result { + type string; + } + } + } + + rpc reset-ofjava-statistics { + description + "Shortcut JMX call to resetOfjavaStatistics."; + input { + uses rpcx:rpc-context-ref { + refine context-instance { + rpcx:rpc-context-instance reset-ofjava-statistics-rpc; + } + } + } + output { + leaf result { + type string; + } } } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java index 4dd3f53b..2b30d846 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java @@ -58,7 +58,7 @@ public void setUp() { ofDecoder.setDeserializationFactory(mockDeserializationFactory); outList = new ArrayList<>(); statCounters = StatisticsCounters.getInstance(); - statCounters.startCounting(true, false, 0); + statCounters.startCounting(false, 0); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java index 46aa2f45..cfafe994 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoderStatisticsTest.java @@ -59,7 +59,7 @@ public void initTlest(){ ofEncoder = new OFEncoder() ; ofEncoder.setSerializationFactory(mockSerializationFactory) ; statCounters = StatisticsCounters.getInstance(); - statCounters.startCounting(true,false, 0); + statCounters.startCounting(false, 0); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java index 8429afde..a770e853 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -117,7 +117,7 @@ public void onRemoval( public void setUp() { MockitoAnnotations.initMocks(this); statCounters = StatisticsCounters.getInstance(); - statCounters.startCounting(true,false, 0); + statCounters.startCounting(false, 0); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java index ec947e9a..6f199328 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java @@ -11,11 +11,9 @@ import java.net.InetAddress; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.StatisticsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.modules.module.configuration.openflow._switch.connection.provider.impl.Statistics; /** * @author michal.polkorab @@ -29,8 +27,6 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration { private TlsConfiguration tlsConfig; private long switchIdleTimeout; private ThreadConfiguration threadConfig; - private TransportProtocol protocol; - private Statistics statistics; /** * Creates {@link ConnectionConfigurationImpl} @@ -96,10 +92,4 @@ public ThreadConfiguration getThreadConfiguration() { public void setThreadConfiguration(ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } - - @Override - public StatisticsConfiguration getStatisticsConfiguration() { - // TODO Auto-generated method stub - return null; - } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java index 1bb549b6..d586a24d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -30,7 +30,7 @@ public class StatisticsCountersTest { @Before public void initTest(){ statCounters = StatisticsCounters.getInstance(); - statCounters.startCounting(true,false, 0); + statCounters.startCounting(false, 0); } /** @@ -101,9 +101,6 @@ public void testStartStopLogReporter(){ statCounters.startLogReport(testDelay); Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); Assert.assertEquals("Wrong - bad logReportPeriod", testDelay, statCounters.getLogReportPeriod()); - statCounters.startLogReport(); - Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); - Assert.assertEquals("Wrong - bad logReportPeriod", testDelay, statCounters.getLogReportPeriod()); statCounters.stopLogReport(); Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport()); statCounters.startLogReport(statCounters.MINIMAL_LOG_REPORT_PERIOD / 2); @@ -118,7 +115,7 @@ public void testStartStopLogReporter(){ */ @Test(expected = IllegalArgumentException.class) public void testLogReportBadPeriod(){ - statCounters.startLogReport(-1); + statCounters.startLogReport(0); } /** diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index f6ea1ffd..6cef4f39 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -23,7 +23,7 @@ - org.opendaylight.openflowjava.protocol.spi.connection*, + org.opendaylight.openflowjava.protocol.spi*, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.* diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java new file mode 100644 index 00000000..c5d7a6aa --- /dev/null +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.spi.statistics; + +/** + * Used for JConsole service + * + * @author michal.polkorab + */ +public interface StatisticsHandler { + + /** + * Resets all counters + */ + public void resetCounters(); + + /** + * Prints statistics + * @return statistics + */ + public String printStatistics(); +} \ No newline at end of file diff --git a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang index 88d2427f..3ed7c20b 100644 --- a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang +++ b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang @@ -17,4 +17,11 @@ module openflow-switch-connection-provider { base "config:service-type"; config:java-class "org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"; } + + identity statistics-collection-service { + description + "StatisticsHandlerService interface as a StatisticsCollection interface identity"; + base config:service-type; + config:java-class "org.opendaylight.openflowjava.protocol.spi.statistics.StatisticsHandler"; + } } \ No newline at end of file From 469c65356d15832801188e234281bc59e60f84b7 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 18 Nov 2014 10:41:42 +0100 Subject: [PATCH 109/285] Statistics loadable / installable in Karaf - created new feature odl-openflowjava-stats in order to ensure correct module start - created new project openflowjava-config to properly store and delagate statistics config file - removed stats-collection as a service from configuration xml Change-Id: If2b94c4ec9bf2a2c8157eaad546672df6e1d1500 Signed-off-by: Michal Polkorab --- features/src/main/resources/features.xml | 4 ++ .../rev140328/StatisticsCollectionModule.java | 3 -- openflowjava-config/pom.xml | 53 +++++++++++++++++++ .../main/resources/45-openflowjava-stats.xml | 41 ++++++++++++++ pom.xml | 19 +++---- 5 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 openflowjava-config/pom.xml create mode 100644 openflowjava-config/src/main/resources/45-openflowjava-stats.xml diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml index ace7ba14..87d05699 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/resources/features.xml @@ -24,4 +24,8 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-impl/${project.version} mvn:org.opendaylight.openflowjava/util/${project.version} + + odl-openflowjava-protocol + mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java index ff686c16..5de0a75f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java @@ -50,10 +50,7 @@ public int getLogReportDelay() { return 0; } }; - } else { - LOGGER.error("STATISTICS ARE NULL"); } - LOGGER.error("config " + statsConfig); if (statsConfig != null) { statsCounter.startCounting(statsConfig.getStatisticsCollect(), statsConfig.getLogReportDelay()); } else { diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml new file mode 100644 index 00000000..60647655 --- /dev/null +++ b/openflowjava-config/pom.xml @@ -0,0 +1,53 @@ + + + + + 4.0.0 + + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.6.0-SNAPSHOT + + openflowjava-config + Configuration files for openflowjava statistics + jar + Openflow Protocol Library - CONFIG + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + 45-openflowjava-stats.xml + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${configfile} + xml + configstats + + + + + + + + + diff --git a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml new file mode 100644 index 00000000..12761959 --- /dev/null +++ b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml @@ -0,0 +1,41 @@ + + + + + + + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28 + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28 + + + + + + + + stats:statistics-collection-service-impl + statistics-collection-service-impl + + true + 10000 + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-default + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-legacy + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index d2d90009..da66cf0c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,6 +6,7 @@ 0.6.0-SNAPSHOT pom + openflowjava-config openflow-protocol-api openflow-protocol-spi util @@ -13,7 +14,7 @@ openflow-protocol-it features simple-client - + scm:git:ssh://git.opendaylight.org:29418/openflowjava.git scm:git:ssh://git.opendaylight.org:29418/openflowjava.git @@ -434,7 +435,7 @@ - + @@ -447,7 +448,7 @@ - + @@ -462,7 +463,7 @@ - + @@ -490,7 +491,7 @@ - + @@ -503,7 +504,7 @@ - + @@ -516,7 +517,7 @@ - + @@ -529,7 +530,7 @@ - + @@ -628,4 +629,4 @@ - + \ No newline at end of file From ecb7fc834171428e79aa644661013c64ffaba23e Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 25 Nov 2014 13:10:50 +0100 Subject: [PATCH 110/285] Test updated according to yangtools string validation change Change-Id: I61a5a215721ef9d2d98e92a0fa0b15fcf1e43440 Signed-off-by: Michal Polkorab --- .../impl/util/OF13MatchSerializerTest.java | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index f9a0224f..ca39e1a7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -112,7 +112,7 @@ public void testIpv4Src() { /** * Test for correct serialization of Ipv6Address match entry */ - @Test(expected=IllegalStateException.class) + @Test public void testIpv6Various() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); @@ -162,24 +162,6 @@ public void testIpv6Various() { addressBuilder.setIpv6Address(new Ipv6Address("::")); entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); entries.add(entriesBuilder.build()); - // ipv6 match entry with incorrect Ipv6 address (longer) - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(Ipv6Dst.class); - entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8:9")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); - entries.add(entriesBuilder.build()); - // ipv6 match entry with too abbreviated Ipv6 address - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(Ipv6NdTarget.class); - entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1:2::::8")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); - entries.add(entriesBuilder.build()); builder.setMatchEntries(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); @@ -242,19 +224,31 @@ public void testIpv6Various() { Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong ipv6 address", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong field and mask", 54, out.readUnsignedByte()); - Assert.assertEquals("Wrong entry length", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong ipv6 address", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong ipv6 address", 8, out.readUnsignedShort()); } - + + /** + * Test for correct serialization of incorrect Ipv6Address match entry + */ + @Test(expected=IllegalStateException.class) + public void testIpv6Incorrect() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + // ipv6 match entry with incorrect Ipv6 address + MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(Ipv6Src.class); + entriesBuilder.setHasMask(false); + Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder(); + addressBuilder.setIpv6Address(new Ipv6Address("1:2::::8")); + entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + entries.add(entriesBuilder.build()); + builder.setMatchEntries(entries); + Match match = builder.build(); + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + matchSerializer.serialize(match, out); + } + /** * Test for correct serialization of Ipv4Address match entry */ From c28667b474e7eece91c2b28fa6a4f9a9cd742233 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 15:58:54 +0100 Subject: [PATCH 111/285] Reference odlparent to get common settings Change-Id: If12f2a59b039d43fd8f325445a4246ef578c45a2 Signed-off-by: Robert Varga --- pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index da66cf0c..bf773394 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,13 @@ 4.0.0 + + org.opendaylight.odlparent + odlparent + 1.5.0-SNAPSHOT + + + org.opendaylight.openflowjava openflow-protocol-parent 0.6.0-SNAPSHOT @@ -14,7 +21,7 @@ openflow-protocol-it features simple-client - + scm:git:ssh://git.opendaylight.org:29418/openflowjava.git scm:git:ssh://git.opendaylight.org:29418/openflowjava.git @@ -629,4 +636,4 @@ - \ No newline at end of file + From da39a20317abc214e09a551f8e99d206f9226aae Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 16:17:06 +0100 Subject: [PATCH 112/285] Do not override versions supplied by odlparent Remove overrides which cause downgrades. Change-Id: I7c55209cfce404368bfa732543197a9e1db91539 Signed-off-by: Robert Varga --- openflow-protocol-impl/pom.xml | 1 - openflow-protocol-it/pom.xml | 1 - pom.xml | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 0fd8d42e..8cc54c09 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -141,7 +141,6 @@ org.slf4j slf4j-log4j12 - ${slf4j.version} test diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 9aaa1c7e..4ef8ec36 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -41,7 +41,6 @@ org.slf4j slf4j-log4j12 - ${slf4j.version} diff --git a/pom.xml b/pom.xml index bf773394..b54ddd59 100644 --- a/pom.xml +++ b/pom.xml @@ -252,7 +252,6 @@ org.apache.maven.plugins maven-compiler-plugin - ${compiler.version} true 1.7 @@ -284,7 +283,7 @@ org.apache.maven.plugins - maven-checkstyle-plugin + maven-checkstyle-plugin 2.12 false From 632f1b4f5c0fca12f8f48eef64c78e0f48fa55e4 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 16:07:41 +0100 Subject: [PATCH 113/285] Make sure to pick up junit version from odlparent Fixes 4.10/4.11 inconsistency reported by maven. Also migrates imports of Assert to the new place. Change-Id: Id0953e69207ac9507b6baa0cc47bfaa938d86655 Signed-off-by: Robert Varga --- .../protocol/api/keys/KeysTest.java | 3 +- .../protocol/api/util/BinContentTest.java | 127 +++++++++--------- .../ChannelOutboundQueue02Test.java | 3 +- .../ConnectionAdapterImp02lTest.java | 3 +- .../deserialization/TypeToClassKeyTest.java | 3 +- ...GetQueueConfigInputMessageFactoryTest.java | 3 +- .../MeterModInputMessageFactoryTest.java | 3 +- .../OF10PortModInputMessageFactoryTest.java | 3 +- ...QueueGetConfigInputMessageFactoryTest.java | 3 +- .../PortModInputMessageFactoryTest.java | 3 +- .../RoleRequestInputMessageFactoryTest.java | 3 +- .../TableModInputMessageFactoryTest.java | 3 +- .../impl/util/OF10MatchSerializerTest.java | 3 +- pom.xml | 2 +- 14 files changed, 76 insertions(+), 89 deletions(-) diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index 6f2eb513..f270bd92 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -1,7 +1,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/util/BinContentTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/util/BinContentTest.java index af09e0cb..3c2bc650 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/util/BinContentTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/util/BinContentTest.java @@ -1,64 +1,63 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.util; - -import junit.framework.Assert; - -import org.junit.Test; - -/** - * @author michal.polkorab - */ -public class BinContentTest { - - /** - * Testing correct conversion from signed int value to unsigned long value - */ - @Test - public void testIntToUnsignedLong() { - int a = 0; - int b = 1; - int c = -1; - int d = Integer.MAX_VALUE; - int e = Integer.MIN_VALUE; - int f = 12345; - Assert.assertEquals("Wrong conversion", 0, BinContent.intToUnsignedLong(a)); - Assert.assertEquals("Wrong conversion", 1, BinContent.intToUnsignedLong(b)); - Assert.assertEquals("Wrong conversion", 4294967295L, BinContent.intToUnsignedLong(c)); - Assert.assertEquals("Wrong conversion", Integer.MAX_VALUE, BinContent.intToUnsignedLong(d)); - Assert.assertEquals("Wrong conversion", ((long) Integer.MAX_VALUE) + 1, BinContent.intToUnsignedLong(e)); - Assert.assertEquals("Wrong conversion", 12345, BinContent.intToUnsignedLong(f)); - } - - /** - * Testing correct conversion from unsigned long value to signed int value - */ - @Test - public void testLongToSignedInt() { - long a = 0; - long b = 1; - long c = -1; - long d = Integer.MAX_VALUE; - long e = Integer.MIN_VALUE; - long f = 12345; - long g = Long.MAX_VALUE; - long h = 1094624935644L; - long i = ((long) Integer.MAX_VALUE) + 1; - Assert.assertEquals("Wrong conversion", 0, BinContent.longToSignedInt(a)); - Assert.assertEquals("Wrong conversion", 1, BinContent.longToSignedInt(b)); - Assert.assertEquals("Wrong conversion", -1, BinContent.longToSignedInt(c)); - Assert.assertEquals("Wrong conversion", Integer.MAX_VALUE, BinContent.longToSignedInt(d)); - Assert.assertEquals("Wrong conversion", Integer.MIN_VALUE, BinContent.longToSignedInt(e)); - Assert.assertEquals("Wrong conversion", 12345, BinContent.longToSignedInt(f)); - Assert.assertEquals("Wrong conversion", -1, BinContent.longToSignedInt(g)); - Assert.assertEquals("Wrong conversion", -591724836, BinContent.longToSignedInt(h)); - Assert.assertEquals("Wrong conversion", Integer.MIN_VALUE, BinContent.longToSignedInt(i)); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.util; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author michal.polkorab + */ +public class BinContentTest { + + /** + * Testing correct conversion from signed int value to unsigned long value + */ + @Test + public void testIntToUnsignedLong() { + int a = 0; + int b = 1; + int c = -1; + int d = Integer.MAX_VALUE; + int e = Integer.MIN_VALUE; + int f = 12345; + Assert.assertEquals("Wrong conversion", 0, BinContent.intToUnsignedLong(a)); + Assert.assertEquals("Wrong conversion", 1, BinContent.intToUnsignedLong(b)); + Assert.assertEquals("Wrong conversion", 4294967295L, BinContent.intToUnsignedLong(c)); + Assert.assertEquals("Wrong conversion", Integer.MAX_VALUE, BinContent.intToUnsignedLong(d)); + Assert.assertEquals("Wrong conversion", ((long) Integer.MAX_VALUE) + 1, BinContent.intToUnsignedLong(e)); + Assert.assertEquals("Wrong conversion", 12345, BinContent.intToUnsignedLong(f)); + } + + /** + * Testing correct conversion from unsigned long value to signed int value + */ + @Test + public void testLongToSignedInt() { + long a = 0; + long b = 1; + long c = -1; + long d = Integer.MAX_VALUE; + long e = Integer.MIN_VALUE; + long f = 12345; + long g = Long.MAX_VALUE; + long h = 1094624935644L; + long i = ((long) Integer.MAX_VALUE) + 1; + Assert.assertEquals("Wrong conversion", 0, BinContent.longToSignedInt(a)); + Assert.assertEquals("Wrong conversion", 1, BinContent.longToSignedInt(b)); + Assert.assertEquals("Wrong conversion", -1, BinContent.longToSignedInt(c)); + Assert.assertEquals("Wrong conversion", Integer.MAX_VALUE, BinContent.longToSignedInt(d)); + Assert.assertEquals("Wrong conversion", Integer.MIN_VALUE, BinContent.longToSignedInt(e)); + Assert.assertEquals("Wrong conversion", 12345, BinContent.longToSignedInt(f)); + Assert.assertEquals("Wrong conversion", -1, BinContent.longToSignedInt(g)); + Assert.assertEquals("Wrong conversion", -591724836, BinContent.longToSignedInt(h)); + Assert.assertEquals("Wrong conversion", Integer.MIN_VALUE, BinContent.longToSignedInt(i)); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java index 3719d3dc..80a58df2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java @@ -16,9 +16,8 @@ import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; - import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java index bc9e93ba..0e561fdc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java @@ -15,9 +15,8 @@ import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; - import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java index 71a56750..08cd1a4f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java @@ -8,8 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java index 0c7b2911..f1da495a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index 8dfa9554..7ac417a4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -14,8 +14,7 @@ import java.util.ArrayList; import java.util.List; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index d03f7983..b64d6c5c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java index cc2a7576..c8a41d2c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index 8b5f8bfa..ce226535 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java index 981a8901..a67b2a48 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java @@ -13,8 +13,7 @@ import java.math.BigInteger; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java index 823ed686..d547f064 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index c6f566cb..ca295ea1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; diff --git a/pom.xml b/pom.xml index b54ddd59..71becad6 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ junit junit - 4.10 + ${junit.version} test true From 9a0a2899b730e740cdaae425f7d5dd7027dfa1d1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 16:26:13 +0100 Subject: [PATCH 114/285] Static fields should be accessed via class This emits a warning in eclipse, so get rid of it. Change-Id: I92734c32e76cfc6320340de714689aa6c235f34e Signed-off-by: Robert Varga --- .../openflowjava/statistics/StatisticsCountersTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java index d586a24d..d922d590 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -103,9 +103,9 @@ public void testStartStopLogReporter(){ Assert.assertEquals("Wrong - bad logReportPeriod", testDelay, statCounters.getLogReportPeriod()); statCounters.stopLogReport(); Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport()); - statCounters.startLogReport(statCounters.MINIMAL_LOG_REPORT_PERIOD / 2); + statCounters.startLogReport(StatisticsCounters.MINIMAL_LOG_REPORT_PERIOD / 2); Assert.assertTrue("Wrong - logRepoter is not running", statCounters.isRunLogReport()); - Assert.assertEquals("Wrong - bad logReportPeriod", statCounters.MINIMAL_LOG_REPORT_PERIOD, statCounters.getLogReportPeriod()); + Assert.assertEquals("Wrong - bad logReportPeriod", StatisticsCounters.MINIMAL_LOG_REPORT_PERIOD, statCounters.getLogReportPeriod()); statCounters.stopCounting(); Assert.assertFalse("Wrong - logRepoter is running", statCounters.isRunLogReport()); } From 519a86d1ddcfb8f0fe264174e62e5424e1efba1f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 15:59:46 +0100 Subject: [PATCH 115/285] Mass replace CRLF->LF Windows EOLs generate a checkstyle warning. Eliminate them to silence the build a bit. Change-Id: I16281420a51e237f516decd64ed46bbe7b4b1461 Signed-off-by: Robert Varga --- .../api/connection/ThreadConfiguration.java | 52 +- .../api/connection/TlsConfiguration.java | 130 +- .../api/connection/TlsConfigurationImpl.java | 182 +- .../DeserializerExtensionProvider.java | 230 +- .../extensibility/DeserializerRegistry.java | 102 +- .../DeserializerRegistryInjector.java | 42 +- .../extensibility/EnhancedMessageCodeKey.java | 118 +- .../extensibility/EnhancedMessageTypeKey.java | 130 +- .../api/extensibility/HeaderDeserializer.java | 54 +- .../api/extensibility/HeaderSerializer.java | 54 +- .../api/extensibility/MessageCodeKey.java | 144 +- .../extensibility/OFGeneralDeserializer.java | 34 +- .../extensibility/OFGeneralSerializer.java | 34 +- .../SerializerExtensionProvider.java | 198 +- .../api/extensibility/SerializerRegistry.java | 108 +- .../SerializerRegistryInjector.java | 44 +- .../api/keys/ActionDeserializerKey.java | 130 +- .../api/keys/ActionSerializerKey.java | 154 +- .../api/keys/InstructionDeserializerKey.java | 130 +- .../api/keys/InstructionSerializerKey.java | 160 +- .../api/keys/MatchEntryDeserializerKey.java | 160 +- .../api/keys/MatchEntrySerializerKey.java | 198 +- .../ExperimenterActionDeserializerKey.java | 56 +- .../ExperimenterActionSerializerKey.java | 122 +- .../ExperimenterDeserializerKey.java | 34 +- .../ExperimenterIdDeserializerKey.java | 138 +- .../ExperimenterIdSerializerKey.java | 134 +- ...xperimenterInstructionDeserializerKey.java | 56 +- .../ExperimenterInstructionSerializerKey.java | 54 +- .../ExperimenterSerializerKey.java | 34 +- .../protocol/api/util/OxmMatchConstants.java | 232 +- .../src/main/yang/openflow-augments.yang | 812 ++--- .../src/main/yang/openflow-configuration.yang | 116 +- .../src/main/yang/openflow-protocol.yang | 2856 ++++++++--------- .../connection/TlsConfigurationImplTest.java | 78 +- .../EnhancedMessageCodeKeyTest.java | 146 +- .../EnhancedMessageTypeKeyTest.java | 168 +- .../api/extensibility/MessageCodeKeyTest.java | 152 +- .../api/extensibility/MessageTypeKeyTest.java | 150 +- .../api/keys/ActionDeserializerKeyTest.java | 138 +- .../api/keys/ActionSerializerKeyTest.java | 160 +- .../keys/InstructionDeserializerKeyTest.java | 138 +- .../keys/InstructionSerializerKeyTest.java | 168 +- .../keys/MatchEntryDeserializerKeyTest.java | 164 +- .../api/keys/MatchEntrySerializerKeyTest.java | 212 +- ...ExperimenterActionDeserializerKeyTest.java | 82 +- .../ExperimenterActionSerializerKeyTest.java | 144 +- .../ExperimenterIdDeserializerKeyTest.java | 132 +- .../ExperimenterIdSerializerKeyTest.java | 132 +- ...imenterInstructionDeserializerKeyTest.java | 82 +- ...erimenterInstructionSerializerKeyTest.java | 84 +- .../impl/core/ChannelInitializerFactory.java | 172 +- .../impl/core/OFDatagramPacketDecoder.java | 122 +- .../impl/core/OFDatagramPacketEncoder.java | 110 +- .../impl/core/OFDatagramPacketHandler.java | 208 +- .../protocol/impl/core/PipelineHandlers.java | 124 +- .../impl/core/ProtocolChannelInitializer.java | 200 +- .../impl/core/UdpChannelInitializer.java | 62 +- .../protocol/impl/core/UdpConnectionMap.java | 122 +- .../protocol/impl/core/UdpHandler.java | 296 +- .../impl/core/VersionMessageUdpWrapper.java | 78 +- .../connection/MessageListenerWrapper.java | 98 +- .../connection/UdpMessageListenerWrapper.java | 88 +- .../ActionDeserializerInitializer.java | 182 +- .../InstructionDeserializerInitializer.java | 90 +- .../MatchEntryDeserializerInitializer.java | 254 +- .../MessageDeserializerInitializer.java | 202 +- .../TypeToClassMapInitializer.java | 160 +- .../action/AbstractActionDeserializer.java | 76 +- .../AbstractEthertypeActionDeserializer.java | 76 +- .../AbstractHeaderActionDeserializer.java | 66 +- ...10AbstractIpAddressActionDeserializer.java | 90 +- ...0AbstractMacAddressActionDeserializer.java | 92 +- .../OF10AbstractPortActionDeserializer.java | 86 +- .../action/OF10EnqueueActionDeserializer.java | 94 +- .../action/OF10OutputActionDeserializer.java | 90 +- .../OF10SetDlDstActionDeserializer.java | 50 +- .../OF10SetDlSrcActionDeserializer.java | 50 +- .../OF10SetNwDstActionDeserializer.java | 50 +- .../OF10SetNwSrcActionDeserializer.java | 50 +- .../OF10SetNwTosActionDeserializer.java | 92 +- .../OF10SetTpDstActionDeserializer.java | 50 +- .../OF10SetTpSrcActionDeserializer.java | 50 +- .../OF10SetVlanPcpActionDeserializer.java | 92 +- .../OF10SetVlanVidActionDeserializer.java | 92 +- .../OF10StripVlanActionDeserializer.java | 50 +- .../OF13CopyTtlInActionDeserializer.java | 50 +- .../OF13CopyTtlOutActionDeserializer.java | 50 +- .../OF13DecMplsTtlActionDeserializer.java | 50 +- .../OF13DecNwTtlActionDeserializer.java | 50 +- .../action/OF13GroupActionDeserializer.java | 86 +- .../action/OF13OutputActionDeserializer.java | 102 +- .../action/OF13PopMplsActionDeserializer.java | 50 +- .../action/OF13PopPbbActionDeserializer.java | 50 +- .../action/OF13PopVlanActionDeserializer.java | 50 +- .../OF13PushMplsActionDeserializer.java | 50 +- .../action/OF13PushPbbActionDeserializer.java | 50 +- .../OF13PushVlanActionDeserializer.java | 50 +- .../OF13SetFieldActionDeserializer.java | 156 +- .../OF13SetMplsTtlActionDeserializer.java | 90 +- .../OF13SetNwTtlActionDeserializer.java | 90 +- .../OF13SetQueueActionDeserializer.java | 86 +- .../factories/ExperimenterMessageFactory.java | 86 +- .../factories/VendorMessageFactory.java | 84 +- ...AbstractActionInstructionDeserializer.java | 130 +- .../AbstractInstructionDeserializer.java | 132 +- .../ApplyActionsInstructionDeserializer.java | 50 +- .../ClearActionsInstructionDeserializer.java | 82 +- .../GoToTableInstructionDeserializer.java | 78 +- .../MeterInstructionDeserializer.java | 76 +- .../WriteActionsInstructionDeserializer.java | 50 +- .../WriteMetadataInstructionDeserializer.java | 88 +- .../AbstractOxmIpv4AddressDeserializer.java | 86 +- .../AbstractOxmIpv6AddressDeserializer.java | 88 +- .../AbstractOxmMacAddressDeserializer.java | 90 +- .../AbstractOxmMatchEntryDeserializer.java | 128 +- .../AbstractOxmMetadataDeserializer.java | 86 +- .../match/AbstractOxmPortDeserializer.java | 76 +- .../AbstractOxmPortNumberDeserializer.java | 68 +- .../match/NxmTcpFlagDeserializer.java | 104 +- .../match/OxmArpOpDeserializer.java | 102 +- .../match/OxmArpShaDeserializer.java | 60 +- .../match/OxmArpSpaDeserializer.java | 60 +- .../match/OxmArpThaDeserializer.java | 60 +- .../match/OxmArpTpaDeserializer.java | 60 +- .../match/OxmEthDstDeserializer.java | 62 +- .../match/OxmEthSrcDeserializer.java | 62 +- .../match/OxmEthTypeDeserializer.java | 104 +- .../match/OxmIcmpv4CodeDeserializer.java | 106 +- .../match/OxmIcmpv4TypeDeserializer.java | 104 +- .../match/OxmIcmpv6CodeDeserializer.java | 104 +- .../match/OxmIcmpv6TypeDeserializer.java | 94 +- .../match/OxmInPhyPortDeserializer.java | 60 +- .../match/OxmInPortDeserializer.java | 60 +- .../match/OxmIpDscpDeserializer.java | 104 +- .../match/OxmIpEcnDeserializer.java | 102 +- .../match/OxmIpProtoDeserializer.java | 102 +- .../match/OxmIpv4DstDeserializer.java | 60 +- .../match/OxmIpv4SrcDeserializer.java | 60 +- .../match/OxmIpv6DstDeserializer.java | 60 +- .../match/OxmIpv6ExtHdrDeserializer.java | 132 +- .../match/OxmIpv6FlabelDeserializer.java | 116 +- .../match/OxmIpv6NdSllDeserializer.java | 60 +- .../match/OxmIpv6NdTargetDeserializer.java | 60 +- .../match/OxmIpv6NdTllDeserializer.java | 62 +- .../match/OxmIpv6SrcDeserializer.java | 60 +- .../match/OxmMaskDeserializer.java | 80 +- .../match/OxmMetadataDeserializer.java | 60 +- .../match/OxmMplsBosDeserializer.java | 114 +- .../match/OxmMplsLabelDeserializer.java | 104 +- .../match/OxmMplsTcDeserializer.java | 102 +- .../match/OxmPbbIsidDeserializer.java | 112 +- .../match/OxmSctpDstDeserializer.java | 60 +- .../match/OxmSctpSrcDeserializer.java | 60 +- .../match/OxmTcpDstDeserializer.java | 60 +- .../match/OxmTcpSrcDeserializer.java | 60 +- .../match/OxmTunnelIdDeserializer.java | 60 +- .../match/OxmUdpDstDeserializer.java | 60 +- .../match/OxmUdpSrcDeserializer.java | 60 +- .../match/OxmVlanPcpDeserializer.java | 102 +- .../match/OxmVlanVidDeserializer.java | 114 +- .../serialization/ActionsInitializer.java | 236 +- .../InstructionsInitializer.java | 104 +- .../MatchEntriesInitializer.java | 344 +- .../MessageFactoryInitializer.java | 226 +- .../action/AbstractActionSerializer.java | 94 +- .../AbstractEthertypeActionSerializer.java | 70 +- .../AbstractHeaderActionSerializer.java | 64 +- ...OF10AbstractIpAddressActionSerializer.java | 64 +- ...F10AbstractMacAddressActionSerializer.java | 64 +- .../OF10AbstractPortActionSerializer.java | 60 +- .../action/OF10EnqueueActionSerializer.java | 88 +- .../action/OF10OutputActionSerializer.java | 86 +- .../action/OF10SetDlDstActionSerializer.java | 58 +- .../action/OF10SetDlSrcActionSerializer.java | 58 +- .../action/OF10SetNwDstActionSerializer.java | 58 +- .../action/OF10SetNwSrcActionSerializer.java | 54 +- .../action/OF10SetNwTosActionSerializer.java | 80 +- .../action/OF10SetTpDstActionSerializer.java | 58 +- .../action/OF10SetTpSrcActionSerializer.java | 58 +- .../OF10SetVlanPcpActionSerializer.java | 80 +- .../OF10SetVlanVidActionSerializer.java | 80 +- .../action/OF10StripVlanActionSerializer.java | 50 +- .../action/OF13CopyTtlInActionSerializer.java | 48 +- .../OF13CopyTtlOutActionSerializer.java | 48 +- .../OF13DecMplsTtlActionSerializer.java | 48 +- .../action/OF13DecNwTtlActionSerializer.java | 50 +- .../action/OF13GroupActionSerializer.java | 80 +- .../action/OF13OutputActionSerializer.java | 88 +- .../action/OF13PopMplsActionSerializer.java | 48 +- .../action/OF13PopPbbActionSerializer.java | 48 +- .../action/OF13PopVlanActionSerializer.java | 48 +- .../action/OF13PushMplsActionSerializer.java | 48 +- .../action/OF13PushPbbActionSerializer.java | 48 +- .../action/OF13PushVlanActionSerializer.java | 50 +- .../action/OF13SetFieldActionSerializer.java | 142 +- .../OF13SetMplsTtlActionSerializer.java | 86 +- .../action/OF13SetNwTtlActionSerializer.java | 82 +- .../action/OF13SetQueueActionSerializer.java | 80 +- .../AbstractActionInstructionSerializer.java | 128 +- .../AbstractInstructionSerializer.java | 72 +- .../ApplyActionsInstructionSerializer.java | 48 +- .../ClearActionsInstructionSerializer.java | 48 +- .../GoToTableInstructionSerializer.java | 72 +- .../MeterInstructionSerializer.java | 72 +- .../WriteActionsInstructionSerializer.java | 48 +- .../WriteMetadataInstructionSerializer.java | 76 +- .../AbstractOxmIpv4AddressSerializer.java | 74 +- .../AbstractOxmIpv6AddressSerializer.java | 166 +- .../AbstractOxmMacAddressSerializer.java | 58 +- .../AbstractOxmMatchEntrySerializer.java | 146 +- .../match/AbstractOxmMetadataSerializer.java | 54 +- .../AbstractOxmPortNumberSerializer.java | 52 +- .../match/AbstractOxmPortSerializer.java | 52 +- .../match/NxmTcpFlagSerializer.java | 90 +- .../match/OxmArpOpSerializer.java | 86 +- .../match/OxmArpShaSerializer.java | 66 +- .../match/OxmArpSpaSerializer.java | 66 +- .../match/OxmArpThaSerializer.java | 66 +- .../match/OxmArpTpaSerializer.java | 66 +- .../match/OxmEthDstSerializer.java | 66 +- .../match/OxmEthSrcSerializer.java | 66 +- .../match/OxmEthTypeSerializer.java | 86 +- .../match/OxmIcmpv4CodeSerializer.java | 86 +- .../match/OxmIcmpv4TypeSerializer.java | 86 +- .../match/OxmIcmpv6CodeSerializer.java | 86 +- .../match/OxmIcmpv6TypeSerializer.java | 86 +- .../match/OxmInPhyPortSerializer.java | 66 +- .../match/OxmInPortSerializer.java | 66 +- .../match/OxmIpDscpSerializer.java | 86 +- .../match/OxmIpEcnSerializer.java | 86 +- .../match/OxmIpProtoSerializer.java | 86 +- .../match/OxmIpv4DstSerializer.java | 66 +- .../match/OxmIpv4SrcSerializer.java | 66 +- .../match/OxmIpv6DstSerializer.java | 66 +- .../match/OxmIpv6ExtHdrSerializer.java | 114 +- .../match/OxmIpv6FlabelSerializer.java | 88 +- .../match/OxmIpv6NdSllSerializer.java | 66 +- .../match/OxmIpv6NdTargetSerializer.java | 66 +- .../match/OxmIpv6NdTllSerializer.java | 66 +- .../match/OxmIpv6SrcSerializer.java | 66 +- .../match/OxmMetadataSerializer.java | 66 +- .../match/OxmMplsBosSerializer.java | 86 +- .../match/OxmMplsLabelSerializer.java | 86 +- .../match/OxmMplsTcSerializer.java | 86 +- .../match/OxmPbbIsidSerializer.java | 88 +- .../match/OxmSctpDstSerializer.java | 66 +- .../match/OxmSctpSrcSerializer.java | 66 +- .../match/OxmTcpDstSerializer.java | 66 +- .../match/OxmTcpSrcSerializer.java | 66 +- .../match/OxmTunnelIdSerializer.java | 66 +- .../match/OxmUdpDstSerializer.java | 66 +- .../match/OxmUdpSrcSerializer.java | 68 +- .../match/OxmVlanPcpSerializer.java | 88 +- .../match/OxmVlanVidSerializer.java | 104 +- .../impl/util/AbstractCodeKeyMaker.java | 70 +- .../impl/util/AbstractTypeKeyMaker.java | 70 +- .../protocol/impl/util/ActionConstants.java | 214 +- .../ActionDeserializerRegistryHelper.java | 84 +- .../util/ActionSerializerRegistryHelper.java | 84 +- .../protocol/impl/util/CodeKeyMaker.java | 52 +- .../impl/util/CodeKeyMakerFactory.java | 180 +- .../util/CommonMessageRegistryHelper.java | 78 +- .../impl/util/InstructionConstants.java | 96 +- ...InstructionDeserializerRegistryHelper.java | 84 +- .../InstructionSerializerRegistryHelper.java | 82 +- .../protocol/impl/util/ListDeserializer.java | 156 +- .../protocol/impl/util/ListSerializer.java | 122 +- .../MatchEntryDeserializerRegistryHelper.java | 92 +- .../MatchEntrySerializerRegistryHelper.java | 98 +- .../protocol/impl/util/OpenflowUtils.java | 150 +- .../SimpleDeserializerRegistryHelper.java | 88 +- .../protocol/impl/util/TypeKeyMaker.java | 52 +- .../impl/util/TypeKeyMakerFactory.java | 184 +- .../impl/util/TypeToClassInitHelper.java | 80 +- .../protocol/impl/util/TypeToClassKey.java | 112 +- .../openflowjava/statistics/Counter.java | 166 +- .../statistics/CounterEventTypes.java | 104 +- .../src/main/resources/log4j.xml | 56 +- .../core/OFDatagramPacketEncoderTest.java | 174 +- .../connection/ChannelOutboundQueueTest.java | 108 +- .../connection/ConnectionAdapterImplTest.java | 358 +-- .../MessageListenerWrapperTest.java | 70 +- .../ResponseExpectedRpcListenerTest.java | 262 +- .../connection/SimpleRpcListenerTest.java | 214 +- .../SwitchConnectionProviderImplTest.java | 362 +-- .../DeserializationFactoryTest.java | 110 +- .../TypeToClassMapInitializerTest.java | 160 +- .../ExperimenterMessageFactoryTest.java | 116 +- .../OF10StatsReplyMessageFactoryTest.java | 634 ++-- .../factories/VendorMessageFactoryTest.java | 94 +- .../MultipartReplyExperimenterTest.java | 104 +- .../multipart/MultipartReplyFlowTest.java | 270 +- .../MultipartReplyGroupFeaturesTest.java | 206 +- .../MultipartReplyMeterFeaturesTest.java | 158 +- .../multipart/MultipartReplyPortDescTest.java | 242 +- .../MultipartReplyTableFeaturesTest.java | 372 +-- .../OF10StatsReplyExperimenterTest.java | 102 +- .../AbstractInstructionDeserializerTest.java | 128 +- .../match/OxmIpv6ExtHdrDeserializerTest.java | 96 +- .../match/OxmIpv6FlabelDeserializerTest.java | 86 +- .../match/OxmMetadataDeserializerTest.java | 88 +- .../match/OxmMplsBosDeserializerTest.java | 84 +- .../match/OxmPbbIsidDeserializerTest.java | 84 +- .../match/OxmVlanVidDeserializerTest.java | 90 +- .../SerializationFactoryTest.java | 118 +- .../ExperimenterInputMessageFactoryTest.java | 256 +- .../OF10StatsRequestInputFactoryTest.java | 604 ++-- .../VendorInputMessageFactoryTest.java | 112 +- .../MultipartRequestExperimenterTest.java | 156 +- .../MultipartRequestGroupDescTest.java | 152 +- .../MultipartRequestGroupFeaturesTest.java | 152 +- .../MultipartRequestMeterFeaturesTest.java | 152 +- .../MultipartRequestPortDescTest.java | 152 +- .../MultipartRequestTableFeaturesTest.java | 932 +++--- .../multipart/MultipartRequestTableTest.java | 152 +- .../OF10StatsRequestAggregateTest.java | 202 +- .../OF10StatsRequestExperimenterTest.java | 156 +- .../match/OxmArpOpSerializerTest.java | 216 +- .../match/OxmArpShaSerializerTest.java | 316 +- .../match/OxmArpSpaSerializerTest.java | 316 +- .../match/OxmArpThaSerializerTest.java | 316 +- .../match/OxmArpTpaSerializerTest.java | 316 +- .../match/OxmEthDstSerializerTest.java | 316 +- .../match/OxmEthSrcSerializerTest.java | 316 +- .../match/OxmEthTypeSerializerTest.java | 220 +- .../match/OxmIcmpv4CodeSerializerTest.java | 218 +- .../match/OxmIcmpv4TypeSerializerTest.java | 218 +- .../match/OxmIcmpv6CodeSerializerTest.java | 216 +- .../match/OxmIcmpv6TypeSerializerTest.java | 218 +- .../match/OxmIpDscpSerializerTest.java | 218 +- .../match/OxmIpProtoSerializerTest.java | 216 +- .../match/OxmIpv4DstSerializerTest.java | 316 +- .../match/OxmIpv4SrcSerializerTest.java | 316 +- .../match/OxmIpv6ExtHdrSerializerTest.java | 312 +- .../match/OxmIpv6NdSllSerializerTest.java | 238 +- .../match/OxmIpv6NdTllSerializerTest.java | 238 +- .../match/OxmMetadataSerializerTest.java | 314 +- .../match/OxmMplsBosSerializerTest.java | 218 +- .../match/OxmMplsLabelSerializerTest.java | 216 +- .../match/OxmMplsTcSerializerTest.java | 216 +- .../match/OxmPbbIsidSerializerTest.java | 306 +- .../match/OxmSctpDstSerializerTest.java | 218 +- .../match/OxmSctpSrcSerializerTest.java | 218 +- .../match/OxmTcpDstSerializerTest.java | 218 +- .../match/OxmTcpSrcSerializerTest.java | 218 +- .../match/OxmTunnelIdSerializerTest.java | 314 +- .../match/OxmUdpDstSerializerTest.java | 218 +- .../match/OxmUdpSrcSerializerTest.java | 218 +- .../match/OxmVlanPcpSerializerTest.java | 216 +- .../match/OxmVlanVidSerializerTest.java | 306 +- .../impl/util/ActionsDeserializerTest.java | 332 +- .../impl/util/CodeKeyMakerFactoryTest.java | 268 +- .../util/InstructionsDeserializerTest.java | 224 +- .../impl/util/ListDeserializerTest.java | 114 +- .../impl/util/ListSerializerTest.java | 88 +- .../impl/util/MatchDeserializerTest.java | 1030 +++--- .../util/OF10ActionsDeserializerTest.java | 270 +- .../impl/util/OF10ActionsSerializerTest.java | 436 +-- .../impl/util/OF13ActionsSerializerTest.java | 572 ++-- .../util/OF13InstructionsSerializerTest.java | 392 +-- .../impl/util/OF13MatchSerializer02Test.java | 1586 ++++----- .../protocol/impl/util/OpenflowUtilsTest.java | 134 +- .../impl/util/TypeKeyMakerFactoryTest.java | 360 +-- .../src/test/resources/log4j.xml | 48 +- .../spi/statistics/StatisticsHandler.java | 54 +- openflowjava-config/pom.xml | 102 +- .../main/resources/45-openflowjava-stats.xml | 80 +- .../protocol/impl/clients/OFClient.java | 78 +- .../ExperimenterDeserializerKeyFactory.java | 166 +- .../ExperimenterSerializerKeyFactory.java | 122 +- ...xperimenterDeserializerKeyFactoryTest.java | 186 +- .../ExperimenterSerializerKeyFactoryTest.java | 142 +- 373 files changed, 26372 insertions(+), 26372 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java index 89dae4a2..e3d1fb66 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.connection; - -/** - * @author michal.polkorab - * - */ -public interface ThreadConfiguration { - - /** - * @return desired number of workerThreads processing the Openflow I/O - */ - int getWorkerThreadCount(); - - /** - * @return desired number of bossThreads registering incomming Openflow connections - */ - int getBossThreadCount(); -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +/** + * @author michal.polkorab + * + */ +public interface ThreadConfiguration { + + /** + * @return desired number of workerThreads processing the Openflow I/O + */ + int getWorkerThreadCount(); + + /** + * @return desired number of bossThreads registering incomming Openflow connections + */ + int getBossThreadCount(); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index fde44efb..84eeab3e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.connection; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - - -/** - * @author michal.polkorab - * - */ -public interface TlsConfiguration { - - /** - * @return keystore location - */ - String getTlsKeystore(); - - /** - * @return keystore type - */ - KeystoreType getTlsKeystoreType(); - - /** - * @return truststore location - */ - String getTlsTruststore(); - - /** - * @return truststore type - */ - KeystoreType getTlsTruststoreType(); - - /** - * @return keystore path type (CLASSPATH or PATH) - */ - PathType getTlsKeystorePathType(); - - /** - * @return truststore path type (CLASSPATH or PATH) - */ - PathType getTlsTruststorePathType(); - - /** - * @return password protecting specified keystore - */ - String getKeystorePassword(); - - /** - * @return password protecting certificate - */ - String getCertificatePassword(); - - /** - * @return password protecting specified truststore - */ - String getTruststorePassword(); -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + + +/** + * @author michal.polkorab + * + */ +public interface TlsConfiguration { + + /** + * @return keystore location + */ + String getTlsKeystore(); + + /** + * @return keystore type + */ + KeystoreType getTlsKeystoreType(); + + /** + * @return truststore location + */ + String getTlsTruststore(); + + /** + * @return truststore type + */ + KeystoreType getTlsTruststoreType(); + + /** + * @return keystore path type (CLASSPATH or PATH) + */ + PathType getTlsKeystorePathType(); + + /** + * @return truststore path type (CLASSPATH or PATH) + */ + PathType getTlsTruststorePathType(); + + /** + * @return password protecting specified keystore + */ + String getKeystorePassword(); + + /** + * @return password protecting certificate + */ + String getCertificatePassword(); + + /** + * @return password protecting specified truststore + */ + String getTruststorePassword(); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java index 4d6fa87d..78a6c6b8 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java @@ -1,91 +1,91 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.connection; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - -/** - * Class is used only for testing purposes - passwords are hardcoded - * @author michal.polkorab - */ -public class TlsConfigurationImpl implements TlsConfiguration { - - private KeystoreType trustStoreType; - private String trustStore; - private KeystoreType keyStoreType; - private String keyStore; - private PathType keystorePathType; - private PathType truststorePathType; - - /** - * Default constructor - * @param trustStoreType JKS or PKCS12 - * @param trustStore path to trustStore file - * @param trustStorePathType truststore path type (classpath or path) - * @param keyStoreType JKS or PKCS12 - * @param keyStore path to keyStore file - * @param keyStorePathType keystore path type (classpath or path) - */ - public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, - PathType trustStorePathType, KeystoreType keyStoreType, - String keyStore, PathType keyStorePathType) { - this.trustStoreType = trustStoreType; - this.trustStore = trustStore; - this.truststorePathType = trustStorePathType; - this.keyStoreType = keyStoreType; - this.keyStore = keyStore; - this.keystorePathType = keyStorePathType; - } - - @Override - public KeystoreType getTlsTruststoreType() { - return trustStoreType; - } - - @Override - public String getTlsTruststore() { - return trustStore; - } - - @Override - public KeystoreType getTlsKeystoreType() { - return keyStoreType; - } - - @Override - public String getTlsKeystore() { - return keyStore; - } - - @Override - public PathType getTlsKeystorePathType() { - return keystorePathType; - } - - @Override - public PathType getTlsTruststorePathType() { - return truststorePathType; - } - - @Override - public String getKeystorePassword() { - return "opendaylight"; - } - - @Override - public String getCertificatePassword() { - return "opendaylight"; - } - - @Override - public String getTruststorePassword() { - return "opendaylight"; - } -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * Class is used only for testing purposes - passwords are hardcoded + * @author michal.polkorab + */ +public class TlsConfigurationImpl implements TlsConfiguration { + + private KeystoreType trustStoreType; + private String trustStore; + private KeystoreType keyStoreType; + private String keyStore; + private PathType keystorePathType; + private PathType truststorePathType; + + /** + * Default constructor + * @param trustStoreType JKS or PKCS12 + * @param trustStore path to trustStore file + * @param trustStorePathType truststore path type (classpath or path) + * @param keyStoreType JKS or PKCS12 + * @param keyStore path to keyStore file + * @param keyStorePathType keystore path type (classpath or path) + */ + public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, + PathType trustStorePathType, KeystoreType keyStoreType, + String keyStore, PathType keyStorePathType) { + this.trustStoreType = trustStoreType; + this.trustStore = trustStore; + this.truststorePathType = trustStorePathType; + this.keyStoreType = keyStoreType; + this.keyStore = keyStore; + this.keystorePathType = keyStorePathType; + } + + @Override + public KeystoreType getTlsTruststoreType() { + return trustStoreType; + } + + @Override + public String getTlsTruststore() { + return trustStore; + } + + @Override + public KeystoreType getTlsKeystoreType() { + return keyStoreType; + } + + @Override + public String getTlsKeystore() { + return keyStore; + } + + @Override + public PathType getTlsKeystorePathType() { + return keystorePathType; + } + + @Override + public PathType getTlsTruststorePathType() { + return truststorePathType; + } + + @Override + public String getKeystorePassword() { + return "opendaylight"; + } + + @Override + public String getCertificatePassword() { + return "opendaylight"; + } + + @Override + public String getTruststorePassword() { + return "opendaylight"; + } +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 0fd529db..f8f3c1b3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; - -/** - * Provides methods for deserialization part of extensibility. - * In case of handling multiple multiple structures of same type (actions, - * instructions, match entries, ... ) which are differentiated by - * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
- * - * This has to be done in this way because of experimenter headers, which - * provide only vendor / experimenter ID. Subtype position may be different - * for different vendors (or not present at all) - that's why vendor has to - * handle it in his own implementations. - * @author michal.polkorab - */ -public interface DeserializerExtensionProvider { - - /** - * Unregisters custom deserializer - * @param key used for deserializer lookup - * @return true if deserializer was removed, - * false if no deserializer was found under specified key - */ - boolean unregisterDeserializer(ExperimenterDeserializerKey key); - - /** - * Registers action deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerActionDeserializer(ExperimenterActionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers instruction deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers match entry deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers error message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerErrorDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers experimenter (vendor) message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers multipart-reply (stats) message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers multipart-reply table-features message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers meter band deserializer (used in multipart-reply meter-config) - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers queue property (QUEUE_GET_CONFIG_REPLY message) deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; + +/** + * Provides methods for deserialization part of extensibility. + * In case of handling multiple multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of experimenter headers, which + * provide only vendor / experimenter ID. Subtype position may be different + * for different vendors (or not present at all) - that's why vendor has to + * handle it in his own implementations. + * @author michal.polkorab + */ +public interface DeserializerExtensionProvider { + + /** + * Unregisters custom deserializer + * @param key used for deserializer lookup + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + boolean unregisterDeserializer(ExperimenterDeserializerKey key); + + /** + * Registers action deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerActionDeserializer(ExperimenterActionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers instruction deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers match entry deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers error message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerErrorDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers experimenter (vendor) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply (stats) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply table-features message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers meter band deserializer (used in multipart-reply meter-config) + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers queue property (QUEUE_GET_CONFIG_REPLY message) deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 646f4e08..3b647a49 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - -/** - * @author michal.polkorab - * - */ -public interface DeserializerRegistry { - - /** - * Initializes deserializers - */ - void init(); - - /** - * @param key used for deserializer lookup - * @return deserializer found - */ - - SERIALIZERTYPE getDeserializer(MessageCodeKey key); - - /** - * Registers deserializer. - * Throws IllegalStateException when there is - * a deserializer already registered under given key. - * - * If the deserializer implements {@link DeserializerRegistryInjector} interface, - * the deserializer is injected with DeserializerRegistry instance. - * - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerDeserializer(MessageCodeKey key, - OFGeneralDeserializer deserializer); - - /** - * Unregisters deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - * @return true if deserializer was removed, - * false if no deserializer was found under specified key - */ - boolean unregisterDeserializer(MessageCodeKey key); -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + + +/** + * @author michal.polkorab + * + */ +public interface DeserializerRegistry { + + /** + * Initializes deserializers + */ + void init(); + + /** + * @param key used for deserializer lookup + * @return deserializer found + */ + + SERIALIZERTYPE getDeserializer(MessageCodeKey key); + + /** + * Registers deserializer. + * Throws IllegalStateException when there is + * a deserializer already registered under given key. + * + * If the deserializer implements {@link DeserializerRegistryInjector} interface, + * the deserializer is injected with DeserializerRegistry instance. + * + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerDeserializer(MessageCodeKey key, + OFGeneralDeserializer deserializer); + + /** + * Unregisters deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + boolean unregisterDeserializer(MessageCodeKey key); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java index 662ac802..0b291af3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -/** - * Injects registry - * @author michal.polkorab - */ -public interface DeserializerRegistryInjector { - - /** - * Injects deserializer registry into deserializer - * @param deserializerRegistry - */ - void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +/** + * Injects registry + * @author michal.polkorab + */ +public interface DeserializerRegistryInjector { + + /** + * Injects deserializer registry into deserializer + * @param deserializerRegistry + */ + void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java index 08db5a01..4ecec614 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageCodeKey extends MessageCodeKey { - - private int msgType2; - - /** - * Constructor - * @param version wire protocol version - * @param value used as distinguisher - * @param value2 used as detailed distinguisher - * @param clazz class of object that is going to be deserialized - */ - public EnhancedMessageCodeKey(short version, int value, int value2, Class clazz) { - super(version, value, clazz); - this.msgType2 = value2; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + msgType2; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj; - if (msgType2 != other.msgType2) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " msgType2: " + msgType2; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageCodeKey extends MessageCodeKey { + + private int msgType2; + + /** + * Constructor + * @param version wire protocol version + * @param value used as distinguisher + * @param value2 used as detailed distinguisher + * @param clazz class of object that is going to be deserialized + */ + public EnhancedMessageCodeKey(short version, int value, int value2, Class clazz) { + super(version, value, clazz); + this.msgType2 = value2; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + msgType2; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj; + if (msgType2 != other.msgType2) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " msgType2: " + msgType2; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index d2ce5a91..c0f17c6a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - -/** - * More specific key for {@link SerializerRegistry} - * @author michal.polkorab - * @param main type - * @param specific type - */ -public class EnhancedMessageTypeKey extends MessageTypeKey { - - private final Class msgType2; - - /** - * @param msgVersion - * @param msgType - * @param msgType2 - */ - public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgType2) { - super(msgVersion, msgType); - this.msgType2 = msgType2; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - @SuppressWarnings("rawtypes") - EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj; - if (msgType2 == null) { - if (other.msgType2 != null) { - return false; - } - } else if (!msgType2.getName().equals(other.msgType2.getName())) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " msgType2: " + msgType2.getName(); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + + +/** + * More specific key for {@link SerializerRegistry} + * @author michal.polkorab + * @param main type + * @param specific type + */ +public class EnhancedMessageTypeKey extends MessageTypeKey { + + private final Class msgType2; + + /** + * @param msgVersion + * @param msgType + * @param msgType2 + */ + public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgType2) { + super(msgVersion, msgType); + this.msgType2 = msgType2; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + @SuppressWarnings("rawtypes") + EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj; + if (msgType2 == null) { + if (other.msgType2 != null) { + return false; + } + } else if (!msgType2.getName().equals(other.msgType2.getName())) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " msgType2: " + msgType2.getName(); + } } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index 594f3d02..855b2f69 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * @param - */ -public interface HeaderDeserializer extends OFGeneralDeserializer { - - /** - * Deserializes byte message headers - * - * @param rawMessage message as bytes in ByteBuf - * @return POJO/DTO - */ - E deserializeHeader(ByteBuf rawMessage); -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * @param + */ +public interface HeaderDeserializer extends OFGeneralDeserializer { + + /** + * Deserializes byte message headers + * + * @param rawMessage message as bytes in ByteBuf + * @return POJO/DTO + */ + E deserializeHeader(ByteBuf rawMessage); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index cd8cf038..d1966fb1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.opendaylight.yangtools.yang.binding.DataObject; - -import io.netty.buffer.ByteBuf; - -/** - * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) - * @author michal.polkorab - * @param - */ -public interface HeaderSerializer extends OFGeneralSerializer { - - /** - * Serializes object headers (e.g. for Multipart message - Table Features) - * @param input object whose headers should be serialized - * @param outBuffer output buffer - */ - void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.yangtools.yang.binding.DataObject; + +import io.netty.buffer.ByteBuf; + +/** + * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) + * @author michal.polkorab + * @param + */ +public interface HeaderSerializer extends OFGeneralSerializer { + + /** + * Serializes object headers (e.g. for Multipart message - Table Features) + * @param input object whose headers should be serialized + * @param outBuffer output buffer + */ + void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index 56b6bb1a..ea487ea6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -/** - * @author michal.polkorab - */ -public class MessageCodeKey { - - private short msgVersion; - private int msgType; - private Class clazz; - - /** - * Constructor - * @param version wire protocol version - * @param value used as distinguisher (read from binary data / buffer) - * @param clazz class of object that is going to be deserialized - */ - public MessageCodeKey(short version, int value, Class clazz) { - this.msgVersion = version; - this.msgType = value; - this.clazz = clazz; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); - result = prime * result + msgType; - result = prime * result + msgVersion; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof MessageCodeKey)) { - return false; - } - MessageCodeKey other = (MessageCodeKey) obj; - if (clazz == null) { - if (other.clazz != null) { - return false; - } - } else if (!clazz.equals(other.clazz)) { - return false; - } - if (msgType != other.msgType) { - return false; - } - if (msgVersion != other.msgVersion) { - return false; - } - return true; - } - - @Override - public String toString() { - return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +/** + * @author michal.polkorab + */ +public class MessageCodeKey { + + private short msgVersion; + private int msgType; + private Class clazz; + + /** + * Constructor + * @param version wire protocol version + * @param value used as distinguisher (read from binary data / buffer) + * @param clazz class of object that is going to be deserialized + */ + public MessageCodeKey(short version, int value, Class clazz) { + this.msgVersion = version; + this.msgType = value; + this.clazz = clazz; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); + result = prime * result + msgType; + result = prime * result + msgVersion; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof MessageCodeKey)) { + return false; + } + MessageCodeKey other = (MessageCodeKey) obj; + if (clazz == null) { + if (other.clazz != null) { + return false; + } + } else if (!clazz.equals(other.clazz)) { + return false; + } + if (msgType != other.msgType) { + return false; + } + if (msgVersion != other.msgVersion) { + return false; + } + return true; + } + + @Override + public String toString() { + return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java index bedb267a..c4132cc6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - -/** - * @author michal.polkorab - */ -public interface OFGeneralDeserializer { - - // empty unifying interface -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + + +/** + * @author michal.polkorab + */ +public interface OFGeneralDeserializer { + + // empty unifying interface +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java index 0001c3e9..6dd5d3f0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -/** - * Unifying superinterface - * @author michal.polkorab - * */ -public interface OFGeneralSerializer { - - // empty unifying superinterface -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +/** + * Unifying superinterface + * @author michal.polkorab + * */ +public interface OFGeneralSerializer { + + // empty unifying superinterface +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index f658f5f1..b5bb0c2c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - - -/** - * Provides methods for serialization part of extensibility. - * In case of handling multiple structures of same type (actions, - * instructions, match entries, ... ) which are differentiated by - * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
- * - * This has to be done in this way because of unknown augmentations - * - that's why vendor has to handle it in his own implementations. - * @author michal.polkorab - */ -public interface SerializerExtensionProvider { - - /** - * Unregisters custom serializer - * @param key used for serializer lookup - * @return true if serializer was removed, - * false if no serializer was found under specified key - */ - boolean unregisterSerializer(ExperimenterSerializerKey key); - - /** - * Registers action serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerActionSerializer(ExperimenterActionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers instruction serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers match entry serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMatchEntrySerializer( - MatchEntrySerializerKey key,OFGeneralSerializer serializer); - - /** - * Registers experimenter (vendor) message serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); - - /** - * Registers multipart-request (stats-request) serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); - - /** - * Registers multipart-request table-features serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers meter band serializer (used in meter-mod messages) - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMeterBandSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + + +/** + * Provides methods for serialization part of extensibility. + * In case of handling multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of unknown augmentations + * - that's why vendor has to handle it in his own implementations. + * @author michal.polkorab + */ +public interface SerializerExtensionProvider { + + /** + * Unregisters custom serializer + * @param key used for serializer lookup + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + boolean unregisterSerializer(ExperimenterSerializerKey key); + + /** + * Registers action serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerActionSerializer(ExperimenterActionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers instruction serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers match entry serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); + + /** + * Registers experimenter (vendor) message serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request (stats-request) serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request table-features serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers meter band serializer (used in meter-mod messages) + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMeterBandSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index c0590140..30141911 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - - - -/** - * Stores and handles serializers - * @author michal.polkorab - * - */ -public interface SerializerRegistry { - - /** - * Serializer registry provisioning - */ - public void init(); - - /** - * @param msgTypeKey lookup key - * @return serializer or NullPointerException if no serializer was found - */ - SERIALIZERTYPE - getSerializer(MessageTypeKey msgTypeKey); - - /** - * Registers serializer - * Throws IllegalStateException when there is - * a serializer already registered under given key. - * - * If the serializer implements {@link SerializerRegistryInjector} interface, - * the serializer is injected with SerializerRegistry instance. - * - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerSerializer(MessageTypeKey key, - OFGeneralSerializer serializer); - - /** - * Unregisters serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - * @return true if serializer was removed, - * false if no serializer was found under specified key - */ - boolean unregisterSerializer(MessageTypeKey key); -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + + + + +/** + * Stores and handles serializers + * @author michal.polkorab + * + */ +public interface SerializerRegistry { + + /** + * Serializer registry provisioning + */ + public void init(); + + /** + * @param msgTypeKey lookup key + * @return serializer or NullPointerException if no serializer was found + */ + SERIALIZERTYPE + getSerializer(MessageTypeKey msgTypeKey); + + /** + * Registers serializer + * Throws IllegalStateException when there is + * a serializer already registered under given key. + * + * If the serializer implements {@link SerializerRegistryInjector} interface, + * the serializer is injected with SerializerRegistry instance. + * + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer); + + /** + * Unregisters serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + boolean unregisterSerializer(MessageTypeKey key); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java index 1204055e..b074b15f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java @@ -1,22 +1,22 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - -/** - * Serializer registry injector - * @author michal.polkorab - */ -public interface SerializerRegistryInjector { - - /** - * Injects serializer registry - * @param serializerRegistry registry instance - */ - void injectSerializerRegistry(SerializerRegistry serializerRegistry); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +/** + * Serializer registry injector + * @author michal.polkorab + */ +public interface SerializerRegistryInjector { + + /** + * Injects serializer registry + * @param serializerRegistry registry instance + */ + void injectSerializerRegistry(SerializerRegistry serializerRegistry); + +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index d7363fbb..a80bd7ae 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerKey extends MessageCodeKey { - - private Long experimenterId; - /** - * @param version protocol wire version - * @param type action type - * @param experimenterId experimenter / vendor ID - */ - public ActionDeserializerKey(short version, - int type, Long experimenterId) { - super(version, type, Action.class); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ActionDeserializerKey)) { - return false; - } - ActionDeserializerKey other = (ActionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type action type + * @param experimenterId experimenter / vendor ID + */ + public ActionDeserializerKey(short version, + int type, Long experimenterId) { + super(version, type, Action.class); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ActionDeserializerKey)) { + return false; + } + ActionDeserializerKey other = (ActionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 4e33c56c..d1120467 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * @param action type - */ -public class ActionSerializerKey extends MessageTypeKey { - - private Class actionType; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param actionType type of action - * @param experimenterId experimenter / vendor ID - */ - public ActionSerializerKey(short msgVersion, Class actionType, - Long experimenterId) { - super(msgVersion, Action.class); - this.actionType = actionType; - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ActionSerializerKey other = (ActionSerializerKey) obj; - if (actionType == null) { - if (other.actionType != null) { - return false; - } - } else if (!actionType.equals(other.actionType)) { - return false; - } - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class ActionSerializerKey extends MessageTypeKey { + + private Class actionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param actionType type of action + * @param experimenterId experimenter / vendor ID + */ + public ActionSerializerKey(short msgVersion, Class actionType, + Long experimenterId) { + super(msgVersion, Action.class); + this.actionType = actionType; + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ActionSerializerKey other = (ActionSerializerKey) obj; + if (actionType == null) { + if (other.actionType != null) { + return false; + } + } else if (!actionType.equals(other.actionType)) { + return false; + } + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index c2160878..f7ebcb3c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerKey extends MessageCodeKey { - - private Long experimenterId; - /** - * @param version protocol wire version - * @param type instruction type - * @param experimenterId - */ - public InstructionDeserializerKey(short version, int type, - Long experimenterId) { - super(version, type, Instruction.class); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof InstructionDeserializerKey)) { - return false; - } - InstructionDeserializerKey other = (InstructionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type instruction type + * @param experimenterId + */ + public InstructionDeserializerKey(short version, int type, + Long experimenterId) { + super(version, type, Instruction.class); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof InstructionDeserializerKey)) { + return false; + } + InstructionDeserializerKey other = (InstructionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 7759c0bf..73d0f153 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * @param action type - */ -public class InstructionSerializerKey - extends MessageTypeKey{ - - private Class instructionType; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param objectType class of serialized object (Instruction.class) - * @param instructionType type of instruction - * @param experimenterId experimenter / vendor ID - */ - public InstructionSerializerKey(short msgVersion, Class instructionType, - Long experimenterId) { - super(msgVersion, Instruction.class); - this.instructionType = instructionType; - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof InstructionSerializerKey)) { - return false; - } - InstructionSerializerKey other = (InstructionSerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (instructionType == null) { - if (other.instructionType != null) { - return false; - } - } else if (!instructionType.equals(other.instructionType)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " instructionType type: " + instructionType.getName() - + " vendorID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class InstructionSerializerKey + extends MessageTypeKey{ + + private Class instructionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object (Instruction.class) + * @param instructionType type of instruction + * @param experimenterId experimenter / vendor ID + */ + public InstructionSerializerKey(short msgVersion, Class instructionType, + Long experimenterId) { + super(msgVersion, Instruction.class); + this.instructionType = instructionType; + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof InstructionSerializerKey)) { + return false; + } + InstructionSerializerKey other = (InstructionSerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (instructionType == null) { + if (other.instructionType != null) { + return false; + } + } else if (!instructionType.equals(other.instructionType)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " instructionType type: " + instructionType.getName() + + " vendorID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index d50d9fb1..ebd16ad7 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public final class MatchEntryDeserializerKey extends MessageCodeKey - implements ExperimenterDeserializerKey { - - private int oxmField; - private Long experimenterId; - - /** - * @param version protocol wire version - * @param oxmClass oxm_class (see specification) - * @param oxmField oxm_field (see specification) - */ - public MatchEntryDeserializerKey(short version, - int oxmClass, int oxmField) { - super(version, oxmClass, MatchEntries.class); - this.oxmField = oxmField; - } - - /** - * @param experimenterId experimenter / vendor ID - */ - public void setExperimenterId(Long experimenterId) { - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + oxmField; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (oxmField != other.oxmField) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public final class MatchEntryDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private int oxmField; + private Long experimenterId; + + /** + * @param version protocol wire version + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntryDeserializerKey(short version, + int oxmClass, int oxmField) { + super(version, oxmClass, MatchEntries.class); + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + oxmField; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (oxmField != other.oxmField) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index 55d67e56..fddc35c6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * @param oxm_class (see specification) - * @param oxm_field (see specification) - */ -public final class MatchEntrySerializerKey - extends MessageTypeKey implements ExperimenterSerializerKey { - - private Class oxmClass; - private Class oxmField; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param objectType class of serialized object - * @param oxmClass oxm_class (see specification) - * @param oxmField oxm_field (see specification) - */ - public MatchEntrySerializerKey(short msgVersion, Class oxmClass, - Class oxmField) { - super(msgVersion, MatchEntries.class); - this.oxmClass = oxmClass; - this.oxmField = oxmField; - } - - /** - * @param experimenterId experimenter / vendor ID - */ - public void setExperimenterId(Long experimenterId) { - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode()); - result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (oxmClass == null) { - if (other.oxmClass != null) { - return false; - } - } else if (!oxmClass.equals(other.oxmClass)) { - return false; - } - if (oxmField == null) { - if (other.oxmField != null) { - return false; - } - } else if (!oxmField.equals(other.oxmField)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: " - + oxmField.getName() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * @param oxm_class (see specification) + * @param oxm_field (see specification) + */ +public final class MatchEntrySerializerKey + extends MessageTypeKey implements ExperimenterSerializerKey { + + private Class oxmClass; + private Class oxmField; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntrySerializerKey(short msgVersion, Class oxmClass, + Class oxmField) { + super(msgVersion, MatchEntries.class); + this.oxmClass = oxmClass; + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode()); + result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (oxmClass == null) { + if (other.oxmClass != null) { + return false; + } + } else if (!oxmClass.equals(other.oxmClass)) { + return false; + } + if (oxmField == null) { + if (other.oxmField != null) { + return false; + } + } else if (!oxmField.equals(other.oxmField)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: " + + oxmField.getName() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java index b700f04b..3b599b43 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey - implements ExperimenterDeserializerKey { - - /** - * @param version protocol wire version - * @param experimenterId experimenter / vendor ID - */ - public ExperimenterActionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey + implements ExperimenterDeserializerKey { + + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterActionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index 45b2d02a..e5c9c806 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; - -/** - * @author michal.polkorab - */ -public final class ExperimenterActionSerializerKey extends ActionSerializerKey - implements ExperimenterSerializerKey { - - private Class actionSubType; - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - * @param actionSubType vendor defined subtype - */ - public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class actionSubType) { - super(msgVersion, Experimenter.class, experimenterId); - this.actionSubType = actionSubType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; - if (actionSubType == null) { - if (other.actionSubType != null) { - return false; - } - } else if (!actionSubType.equals(other.actionSubType)) { - return false; - } - return true; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; + +/** + * @author michal.polkorab + */ +public final class ExperimenterActionSerializerKey extends ActionSerializerKey + implements ExperimenterSerializerKey { + + private Class actionSubType; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param actionSubType vendor defined subtype + */ + public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class actionSubType) { + super(msgVersion, Experimenter.class, experimenterId); + this.actionSubType = actionSubType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; + if (actionSubType == null) { + if (other.actionSubType != null) { + return false; + } + } else if (!actionSubType.equals(other.actionSubType)) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java index 2b73858d..770a9162 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -/** - * Marker interface - marks keys appropriate for experimenter deserializer registration - * @author michal.polkorab - */ -public interface ExperimenterDeserializerKey { - // only empty marker interface - to ease extensions registration -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter deserializer registration + * @author michal.polkorab + */ +public interface ExperimenterDeserializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java index 1682d6d3..cb00362e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterIdDeserializerKey extends MessageCodeKey - implements ExperimenterDeserializerKey { - - private Long experimenterId; - - /** - * @param version protocol wire version - * @param experimenterId experimenter / vendor ID - * @param objectClass class of created object - */ - public ExperimenterIdDeserializerKey(short version, - Long experimenterId, Class objectClass) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); - this.experimenterId = experimenterId; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ExperimenterIdDeserializerKey)) { - return false; - } - ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterIdDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private Long experimenterId; + + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of created object + */ + public ExperimenterIdDeserializerKey(short version, + Long experimenterId, Class objectClass) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); + this.experimenterId = experimenterId; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdDeserializerKey)) { + return false; + } + ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java index 2336e9a8..1718246c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * @param class of object to be serialized - */ -public class ExperimenterIdSerializerKey extends MessageTypeKey - implements ExperimenterSerializerKey { - - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - * @param objectClass class of object to be serialized - */ - public ExperimenterIdSerializerKey(short msgVersion, - Long experimenterId, Class objectClass) { - super(msgVersion, objectClass); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ExperimenterIdSerializerKey)) { - return false; - } - ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * @param class of object to be serialized + */ +public class ExperimenterIdSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { + + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of object to be serialized + */ + public ExperimenterIdSerializerKey(short msgVersion, + Long experimenterId, Class objectClass) { + super(msgVersion, objectClass); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdSerializerKey)) { + return false; + } + ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java index cfe99569..b15a1173 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey - implements ExperimenterDeserializerKey { - - /** - * @param version protocol wire version - * @param experimenterId - */ - public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey + implements ExperimenterDeserializerKey { + + /** + * @param version protocol wire version + * @param experimenterId + */ + public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java index 28201506..7d46b590 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; - -/** - * @author michal.polkorab - */ -public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey - implements ExperimenterSerializerKey { - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - */ - public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Experimenter.class, experimenterId); - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; + +/** + * @author michal.polkorab + */ +public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey + implements ExperimenterSerializerKey { + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { + super(msgVersion, Experimenter.class, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java index a99990fe..8ce152bc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -/** - * Marker interface - marks keys appropriate for experimenter serializer registration - * @author michal.polkorab - */ -public interface ExperimenterSerializerKey { - // only empty marker interface - to ease extensions registration -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter serializer registration + * @author michal.polkorab + */ +public interface ExperimenterSerializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 499e95c5..3bc7558e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -1,117 +1,117 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.util; - -/** - * Stores oxm_match constants - * @author michal.polkorab - * - */ -public abstract class OxmMatchConstants { - - /** Backward compatibility with NXM */ - public static final int NXM_0_CLASS = 0x0000; - /** Backward compatibility with NXM */ - public static final int NXM_1_CLASS = 0x0001; - /** Basic class for OpenFlow */ - public static final int OPENFLOW_BASIC_CLASS = 0x8000; - /** Experimenter class */ - public static final int EXPERIMENTER_CLASS = 0xFFFF; - - /** Switch input port */ - public static final int IN_PORT = 0; - /** Switch physical input port */ - public static final int IN_PHY_PORT = 1; - /** Metadata passed between tables */ - public static final int METADATA = 2; - /** Ethernet destination address */ - public static final int ETH_DST = 3; - /** Ethernet source address */ - public static final int ETH_SRC = 4; - /** Ethernet frame type */ - public static final int ETH_TYPE = 5; - /** VLAN id. */ - public static final int VLAN_VID = 6; - /** VLAN priority. */ - public static final int VLAN_PCP = 7; - /** IP DSCP (6 bits in ToS field). */ - public static final int IP_DSCP = 8; - /** IP ECN (2 bits in ToS field). */ - public static final int IP_ECN = 9; - /** IP protocol. */ - public static final int IP_PROTO = 10; - /** IPv4 source address. */ - public static final int IPV4_SRC = 11; - /** IPv4 destination address. */ - public static final int IPV4_DST = 12; - /** TCP source port. */ - public static final int TCP_SRC = 13; - /** TCP destination port. */ - public static final int TCP_DST = 14; - /** UDP source port. */ - public static final int UDP_SRC = 15; - /** UDP destination port. */ - public static final int UDP_DST = 16; - /** SCTP source port. */ - public static final int SCTP_SRC = 17; - /** SCTP destination port. */ - public static final int SCTP_DST = 18; - /** ICMP type. */ - public static final int ICMPV4_TYPE = 19; - /** ICMP code. */ - public static final int ICMPV4_CODE = 20; - /** ARP opcode. */ - public static final int ARP_OP = 21; - /** ARP source IPv4 address. */ - public static final int ARP_SPA = 22; - /** ARP target IPv4 address. */ - public static final int ARP_TPA = 23; - /** ARP source hardware address. */ - public static final int ARP_SHA = 24; - /** ARP target hardware address. */ - public static final int ARP_THA = 25; - /** IPv6 source address. */ - public static final int IPV6_SRC = 26; - /** IPv6 destination address. */ - public static final int IPV6_DST = 27; - /** IPv6 Flow Label */ - public static final int IPV6_FLABEL = 28; - /** ICMPv6 type. */ - public static final int ICMPV6_TYPE = 29; - /** ICMPv6 code. */ - public static final int ICMPV6_CODE = 30; - /** Target address for ND. */ - public static final int IPV6_ND_TARGET = 31; - /** Source link-layer for ND. */ - public static final int IPV6_ND_SLL = 32; - /** Target link-layer for ND. */ - public static final int IPV6_ND_TLL = 33; - /** MPLS label. */ - public static final int MPLS_LABEL = 34; - /** MPLS TC. */ - public static final int MPLS_TC = 35; - /** MPLS BoS bit. */ - public static final int MPLS_BOS = 36; - /** PBB I-SID. */ - public static final int PBB_ISID = 37; - /** Logical Port Metadata. */ - public static final int TUNNEL_ID = 38; - /** IPv6 Extension Header pseudo-field */ - public static final int IPV6_EXTHDR = 39; - - /** - * OFPXMC_NXM_1 class Constants - */ - - /** NXM IPv4 Tunnel Endpoint Source */ - public static final int NXM_NX_TUN_IPV4_SRC = 31; - /** NXM IPv4 Tunnel Endpoint Destination */ - public static final int NXM_NX_TUN_IPV4_DST = 32; - /** NXM TCP_Flag value */ - public static final int NXM_NX_TCP_FLAG = 34; +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.util; + +/** + * Stores oxm_match constants + * @author michal.polkorab + * + */ +public abstract class OxmMatchConstants { + + /** Backward compatibility with NXM */ + public static final int NXM_0_CLASS = 0x0000; + /** Backward compatibility with NXM */ + public static final int NXM_1_CLASS = 0x0001; + /** Basic class for OpenFlow */ + public static final int OPENFLOW_BASIC_CLASS = 0x8000; + /** Experimenter class */ + public static final int EXPERIMENTER_CLASS = 0xFFFF; + + /** Switch input port */ + public static final int IN_PORT = 0; + /** Switch physical input port */ + public static final int IN_PHY_PORT = 1; + /** Metadata passed between tables */ + public static final int METADATA = 2; + /** Ethernet destination address */ + public static final int ETH_DST = 3; + /** Ethernet source address */ + public static final int ETH_SRC = 4; + /** Ethernet frame type */ + public static final int ETH_TYPE = 5; + /** VLAN id. */ + public static final int VLAN_VID = 6; + /** VLAN priority. */ + public static final int VLAN_PCP = 7; + /** IP DSCP (6 bits in ToS field). */ + public static final int IP_DSCP = 8; + /** IP ECN (2 bits in ToS field). */ + public static final int IP_ECN = 9; + /** IP protocol. */ + public static final int IP_PROTO = 10; + /** IPv4 source address. */ + public static final int IPV4_SRC = 11; + /** IPv4 destination address. */ + public static final int IPV4_DST = 12; + /** TCP source port. */ + public static final int TCP_SRC = 13; + /** TCP destination port. */ + public static final int TCP_DST = 14; + /** UDP source port. */ + public static final int UDP_SRC = 15; + /** UDP destination port. */ + public static final int UDP_DST = 16; + /** SCTP source port. */ + public static final int SCTP_SRC = 17; + /** SCTP destination port. */ + public static final int SCTP_DST = 18; + /** ICMP type. */ + public static final int ICMPV4_TYPE = 19; + /** ICMP code. */ + public static final int ICMPV4_CODE = 20; + /** ARP opcode. */ + public static final int ARP_OP = 21; + /** ARP source IPv4 address. */ + public static final int ARP_SPA = 22; + /** ARP target IPv4 address. */ + public static final int ARP_TPA = 23; + /** ARP source hardware address. */ + public static final int ARP_SHA = 24; + /** ARP target hardware address. */ + public static final int ARP_THA = 25; + /** IPv6 source address. */ + public static final int IPV6_SRC = 26; + /** IPv6 destination address. */ + public static final int IPV6_DST = 27; + /** IPv6 Flow Label */ + public static final int IPV6_FLABEL = 28; + /** ICMPv6 type. */ + public static final int ICMPV6_TYPE = 29; + /** ICMPv6 code. */ + public static final int ICMPV6_CODE = 30; + /** Target address for ND. */ + public static final int IPV6_ND_TARGET = 31; + /** Source link-layer for ND. */ + public static final int IPV6_ND_SLL = 32; + /** Target link-layer for ND. */ + public static final int IPV6_ND_TLL = 33; + /** MPLS label. */ + public static final int MPLS_LABEL = 34; + /** MPLS TC. */ + public static final int MPLS_TC = 35; + /** MPLS BoS bit. */ + public static final int MPLS_BOS = 36; + /** PBB I-SID. */ + public static final int PBB_ISID = 37; + /** Logical Port Metadata. */ + public static final int TUNNEL_ID = 38; + /** IPv6 Extension Header pseudo-field */ + public static final int IPV6_EXTHDR = 39; + + /** + * OFPXMC_NXM_1 class Constants + */ + + /** NXM IPv4 Tunnel Endpoint Source */ + public static final int NXM_NX_TUN_IPV4_SRC = 31; + /** NXM IPv4 Tunnel Endpoint Destination */ + public static final int NXM_NX_TUN_IPV4_DST = 32; + /** NXM TCP_Flag value */ + public static final int NXM_NX_TCP_FLAG = 34; } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index a2e69293..9a545416 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -1,407 +1,407 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - - module openflow-augments { - namespace "urn:opendaylight:openflow:augments"; - prefix "aug"; - - import yang-ext {prefix ext;} - import ietf-inet-types {prefix inet;} - import ietf-yang-types {prefix yang;} - - import openflow-types {prefix oft;} - import openflow-protocol {prefix ofproto;} - import openflow-action {prefix ofaction;} - import openflow-instruction {prefix ofinstruction;} - import openflow-extensible-match {prefix oxm;} - - revision "2013-10-02" { - description "OpenFlow 1.3 - augments model. - Please visit - https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf - - Augmentation Tables chapter"; - } - -// OFP_MATCH AUGMENTS - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-number-match-entry"; - leaf port-number { - type oft:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "metadata-match-entry"; - leaf metadata { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mask-match-entry"; - leaf mask { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mac-address-match-entry"; - leaf mac-address { - type yang:mac-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "eth-type-match-entry"; - leaf eth-type { - type oft:ether-type; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-vid-match-entry"; - leaf vlan-vid { - type uint16; - } - leaf cfi-bit { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-pcp-match-entry"; - leaf vlan-pcp { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "dscp-match-entry"; - leaf dscp { - type inet:dscp; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ecn-match-entry"; - leaf ecn { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "protocol-number-match-entry"; - leaf protocol-number { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-match-entry"; - leaf port { - type inet:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-type-match-entry"; - leaf icmpv4-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-code-match-entry"; - leaf icmpv4-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "op-code-match-entry"; - leaf op-code { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-flabel-match-entry"; - leaf ipv6-flabel { - type inet:ipv6-flow-label; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-type-match-entry"; - leaf icmpv6-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-code-match-entry"; - leaf icmpv6-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-address-match-entry"; - leaf ipv6-address { - type inet:ipv6-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv4-address-match-entry"; - leaf ipv4-address { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mpls-label-match-entry"; - leaf mpls-label { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tc-match-entry"; - leaf tc { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "bos-match-entry"; - leaf bos { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "isid-match-entry"; - leaf isid { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "pseudo-field-match-entry"; - leaf pseudo-field { - type oft:ipv6-exthdr-flags; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "experimenter-id-match-entry"; - leaf experimenter { - type oft:experimenter-id; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tcp-flag-match-entry"; - leaf tcp-flag { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-dst-match-entry"; - leaf tunnel-ipv4-dst { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-src-match-entry"; - leaf tunnel-ipv4-src { - type inet:ipv4-address; - } - } - -// OFP_ACTION AUGMENTS - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "port-action"; - leaf port { - type oft:port-number; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "max-length-action"; - leaf max-length { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "mpls-ttl-action"; - leaf mpls-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ethertype-action"; - leaf ethertype { - type oft:ether-type; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "queue-id-action"; - leaf queue-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "group-id-action"; - leaf group-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-ttl-action"; - leaf nw-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "oxm-fields-action"; - uses oxm:oxm-fields-grouping; - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "experimenter-id-action"; - leaf experimenter { - type oft:experimenter-id; - } - leaf sub-type { - type identityref { - base ofaction:experimenter-action-sub-type; - } - } - } - // OF1.0 structures - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-vid-action"; - leaf vlan-vid { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-pcp-action"; - leaf vlan-pcp { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "dl-address-action"; - leaf dl-address { - type yang:mac-address; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-tos-action"; - leaf nw-tos { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ip-address-action"; - leaf ip-address { - type inet:ipv4-address; - } - } - -// OFP_TABLE_FEATURES_PROPERTIES AUGMENTS - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "instruction-related-table-feature-property"; - uses ofinstruction:instructions-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "next-table-related-table-feature-property"; - list next-table-ids { - config false; - leaf table-id { - type uint8; - } - } - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "action-related-table-feature-property"; - uses ofaction:actions-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "oxm-related-table-feature-property"; - uses oxm:oxm-fields-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "experimenter-id-table-feature-property"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - -// OFP_INSTRUCTION AUGMENTS - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "table-id-instruction"; - leaf table-id { - type uint8; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "metadata-instruction"; - leaf metadata { - type binary; - } - leaf metadata-mask { - type binary; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "actions-instruction"; - uses ofaction:actions-grouping; - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "meter-id-instruction"; - leaf meter-id { - type uint32; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "experimenter-id-instruction"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_QUEUE_PROP AUGMENTS - augment "/ofproto:queue-prop-container/ofproto:queue-property" { - ext:augment-identifier "rate-queue-property"; - leaf rate { - type uint16; - } - } - augment "/ofproto:queue-prop-container/ofproto:queue-property" { - ext:augment-identifier "experimenter-id-queue-property"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) - augment "/ofproto:error-message" { - ext:augment-identifier "experimenter-id-error"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_MULTIPART AUGMENTS - augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { - ext:augment-identifier "experimenter-id-multipart-request"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { - ext:augment-identifier "experimenter-id-multipart-reply"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - -// OFP_METER_BAND AUGMENTS - augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { - ext:augment-identifier "experimenter-id-meter-band"; - leaf experimenter { - type oft:experimenter-id; - } - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + module openflow-augments { + namespace "urn:opendaylight:openflow:augments"; + prefix "aug"; + + import yang-ext {prefix ext;} + import ietf-inet-types {prefix inet;} + import ietf-yang-types {prefix yang;} + + import openflow-types {prefix oft;} + import openflow-protocol {prefix ofproto;} + import openflow-action {prefix ofaction;} + import openflow-instruction {prefix ofinstruction;} + import openflow-extensible-match {prefix oxm;} + + revision "2013-10-02" { + description "OpenFlow 1.3 - augments model. + Please visit + https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf + - Augmentation Tables chapter"; + } + +// OFP_MATCH AUGMENTS + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "port-number-match-entry"; + leaf port-number { + type oft:port-number; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "metadata-match-entry"; + leaf metadata { + type binary; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mask-match-entry"; + leaf mask { + type binary; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mac-address-match-entry"; + leaf mac-address { + type yang:mac-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "eth-type-match-entry"; + leaf eth-type { + type oft:ether-type; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "vlan-vid-match-entry"; + leaf vlan-vid { + type uint16; + } + leaf cfi-bit { + type boolean; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "vlan-pcp-match-entry"; + leaf vlan-pcp { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "dscp-match-entry"; + leaf dscp { + type inet:dscp; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ecn-match-entry"; + leaf ecn { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "protocol-number-match-entry"; + leaf protocol-number { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "port-match-entry"; + leaf port { + type inet:port-number; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv4-type-match-entry"; + leaf icmpv4-type { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv4-code-match-entry"; + leaf icmpv4-code { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "op-code-match-entry"; + leaf op-code { + type uint16; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv6-flabel-match-entry"; + leaf ipv6-flabel { + type inet:ipv6-flow-label; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv6-type-match-entry"; + leaf icmpv6-type { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv6-code-match-entry"; + leaf icmpv6-code { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv6-address-match-entry"; + leaf ipv6-address { + type inet:ipv6-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv4-address-match-entry"; + leaf ipv4-address { + type inet:ipv4-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mpls-label-match-entry"; + leaf mpls-label { + type uint32; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tc-match-entry"; + leaf tc { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "bos-match-entry"; + leaf bos { + type boolean; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "isid-match-entry"; + leaf isid { + type uint32; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "pseudo-field-match-entry"; + leaf pseudo-field { + type oft:ipv6-exthdr-flags; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "experimenter-id-match-entry"; + leaf experimenter { + type oft:experimenter-id; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tcp-flag-match-entry"; + leaf tcp-flag { + type uint16; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tunnel-ipv4-dst-match-entry"; + leaf tunnel-ipv4-dst { + type inet:ipv4-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tunnel-ipv4-src-match-entry"; + leaf tunnel-ipv4-src { + type inet:ipv4-address; + } + } + +// OFP_ACTION AUGMENTS + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "port-action"; + leaf port { + type oft:port-number; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "max-length-action"; + leaf max-length { + type uint16; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "mpls-ttl-action"; + leaf mpls-ttl { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "ethertype-action"; + leaf ethertype { + type oft:ether-type; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "queue-id-action"; + leaf queue-id { + type uint32; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "group-id-action"; + leaf group-id { + type uint32; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "nw-ttl-action"; + leaf nw-ttl { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "oxm-fields-action"; + uses oxm:oxm-fields-grouping; + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "experimenter-id-action"; + leaf experimenter { + type oft:experimenter-id; + } + leaf sub-type { + type identityref { + base ofaction:experimenter-action-sub-type; + } + } + } + // OF1.0 structures + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "vlan-vid-action"; + leaf vlan-vid { + type uint16; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "vlan-pcp-action"; + leaf vlan-pcp { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "dl-address-action"; + leaf dl-address { + type yang:mac-address; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "nw-tos-action"; + leaf nw-tos { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "ip-address-action"; + leaf ip-address { + type inet:ipv4-address; + } + } + +// OFP_TABLE_FEATURES_PROPERTIES AUGMENTS + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "instruction-related-table-feature-property"; + uses ofinstruction:instructions-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "next-table-related-table-feature-property"; + list next-table-ids { + config false; + leaf table-id { + type uint8; + } + } + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "action-related-table-feature-property"; + uses ofaction:actions-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "oxm-related-table-feature-property"; + uses oxm:oxm-fields-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "experimenter-id-table-feature-property"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + +// OFP_INSTRUCTION AUGMENTS + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "table-id-instruction"; + leaf table-id { + type uint8; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "metadata-instruction"; + leaf metadata { + type binary; + } + leaf metadata-mask { + type binary; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "actions-instruction"; + uses ofaction:actions-grouping; + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "meter-id-instruction"; + leaf meter-id { + type uint32; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "experimenter-id-instruction"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_QUEUE_PROP AUGMENTS + augment "/ofproto:queue-prop-container/ofproto:queue-property" { + ext:augment-identifier "rate-queue-property"; + leaf rate { + type uint16; + } + } + augment "/ofproto:queue-prop-container/ofproto:queue-property" { + ext:augment-identifier "experimenter-id-queue-property"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) + augment "/ofproto:error-message" { + ext:augment-identifier "experimenter-id-error"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_MULTIPART AUGMENTS + augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { + ext:augment-identifier "experimenter-id-multipart-request"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { + ext:augment-identifier "experimenter-id-multipart-reply"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + +// OFP_METER_BAND AUGMENTS + augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { + ext:augment-identifier "experimenter-id-meter-band"; + leaf experimenter { + type oft:experimenter-id; + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-configuration.yang b/openflow-protocol-api/src/main/yang/openflow-configuration.yang index 8a1f8bbc..38d8d58b 100644 --- a/openflow-protocol-api/src/main/yang/openflow-configuration.yang +++ b/openflow-protocol-api/src/main/yang/openflow-configuration.yang @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - - module openflow-configuration { - namespace "urn:opendaylight:openflow:config"; - prefix "of-config"; - - revision "2014-06-30" { - description "Library configuration classes"; - } - - typedef path-type { - type enumeration { - enum CLASSPATH { - value 0; - description "Keystore file is located on classpath."; - } - enum PATH { - value 1; - description "Keystore file is located on absolute or relative path."; - } - } - } - - typedef keystore-type { - type enumeration { - enum JKS { - value 0; - description "Keystore type - JKS."; - } - enum PKCS12 { - value 1; - description "Keystore type - PKCS12."; - } - } - } - - typedef transport-protocol { - type enumeration { - enum TCP { - value 0; - description "Communication over TCP protocol."; - } - enum TLS { - value 1; - description "Communication over TLS protocol."; - } - enum UDP { - value 2; - description "Communication over UDP protocol."; - } - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + module openflow-configuration { + namespace "urn:opendaylight:openflow:config"; + prefix "of-config"; + + revision "2014-06-30" { + description "Library configuration classes"; + } + + typedef path-type { + type enumeration { + enum CLASSPATH { + value 0; + description "Keystore file is located on classpath."; + } + enum PATH { + value 1; + description "Keystore file is located on absolute or relative path."; + } + } + } + + typedef keystore-type { + type enumeration { + enum JKS { + value 0; + description "Keystore type - JKS."; + } + enum PKCS12 { + value 1; + description "Keystore type - PKCS12."; + } + } + } + + typedef transport-protocol { + type enumeration { + enum TCP { + value 0; + description "Communication over TCP protocol."; + } + enum TLS { + value 1; + description "Communication over TLS protocol."; + } + enum UDP { + value 2; + description "Communication over UDP protocol."; + } + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 32070d14..9330fac6 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -1,1429 +1,1429 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - - module openflow-protocol { - namespace "urn:opendaylight:openflow:protocol"; - prefix "ofproto"; - - import ietf-yang-types {prefix yang;} - - import openflow-types {prefix oft;} - import openflow-extensible-match { prefix oxm;} - import openflow-instruction { prefix ofinstruction;} - import openflow-action {prefix ofaction;} - - revision "2013-07-31" { - description "OpenFlow 1.3 - protocol objects model"; - } - - // Generic Structures - grouping port-grouping { - reference "ofp_port"; - leaf port-no { - type uint32; - } - leaf hw-addr { - type yang:mac-address; - } - leaf name { - type string; - } - leaf config { - description "Bitmap of OFPPC_* flags."; - type oft:port-config; - } - leaf state { - description "Bitmap of OFPPS_* flags."; - type oft:port-state; - } - leaf current-features { - description "Current features."; - type oft:port-features; - } - leaf advertised-features { - description "Features being advertised by the port."; - type oft:port-features; - } - leaf supported-features { - description "Features supported by the port."; - type oft:port-features; - } - leaf peer-features { - description "Features advertised by peer."; - type oft:port-features; - } - leaf curr-speed { - description "Current port bitrate in kbps."; - type uint32; - units "kbps"; - } - leaf max-speed { - description "Max port bitrate in kbps"; - type uint32; - units "kbps"; - } - - // OF1.0 structures - leaf config-v10 { - type oft:port-config-v10; - } - leaf state-v10 { - type oft:port-state-v10; - } - leaf current-features-v10 { - description "Current features."; - type oft:port-features-v10; - } - leaf advertised-features-v10 { - description "Features being advertised by the port."; - type oft:port-features-v10; - } - leaf supported-features-v10 { - description "Features supported by the port."; - type oft:port-features-v10; - } - leaf peer-features-v10 { - description "Features advertised by peer."; - type oft:port-features-v10; - } - } - - grouping buckets-grouping { - list buckets-list { - uses bucket-grouping; - } - } - - grouping bucket-grouping { - description "Bucket for use in groups."; - leaf weight { - description "Relative weight of bucket. Only - defined for select groups."; - type uint16; - } - leaf watch-port { - description "Port whose state affects whether this - bucket is live. Only required for fast - failover groups."; - type oft:port-number; - } - leaf watch-group { - description "Group whose state affects whether this - bucket is live. Only required for fast - failover groups."; - type uint32; - } - - uses ofaction:actions-grouping; - } - - container table-features-properties-container { - uses table-features-properties-grouping; - } - - grouping table-features-properties-grouping { - list table-feature-properties { - config false; - leaf type { - type oft:table-features-prop-type; - } - } - } - - // # MESSAGE Structures - /* Immutable messages. */ - grouping ofHeader { - reference "ofp_header struct in Openflow Switch 1.3 Spec"; - leaf version { - type uint8; - description "OpenFlow version"; - } - leaf xid { - type uint32; - description "Transaction ID"; - } - } - grouping ofHelloElementHeader { - reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"; - leaf type { - type oft:hello-element-type; - //reference "OpenFlow Header element type - OFPHET_*"; - } - } - grouping hello { - reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - list elements { - uses ofHelloElementHeader; - - leaf-list version-bitmap { - type boolean; - } - } - } - grouping error { - reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf type { - type uint16; - } - leaf code { - type uint16; - } - leaf type-string { - type string; - } - leaf code-string { - type string; - } - leaf data { - type binary; - } - } - grouping echo-request { - reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf data { - type binary; - } - } - grouping echo-reply { - reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf data { - type binary; - } - } - grouping experimenter { - reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf experimenter { - type oft:experimenter-id; - } - leaf exp_type { - type uint32; - } - } - /* Switch configuration messages. */ - grouping features-request { - reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping features-reply { - reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - - leaf datapathId { - type uint64; - } - leaf buffers { - type uint32; - } - leaf tables { - type uint8; - } - leaf auxiliaryId { - type uint8; - } - leaf capabilities { - type oft:capabilities; - } - leaf reserved { - type uint32; - } - // OF1.0 structures - leaf capabilities-v10 { - type oft:capabilities-v10; - } - leaf actions-v10 { - type oft:action-type-v10; - } - list phy-port { - uses port-grouping; - } - } - grouping get-config-request { - reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping get-config-reply { - reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - - leaf flags { - type oft:switch-config-flag; - } - leaf miss-send-len { - type uint16; - } - } - grouping set-config { - reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf flags { - type oft:switch-config-flag; - } - leaf miss-send-len { - type uint16; - } - } - /* Asynchronous messages. */ - grouping packet-in { - reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"; - /* Async message */ - - uses ofHeader; - - leaf buffer-id { - // ID assigned by datapath. - type uint32; - } - leaf total-len { - // Full length of frame. - type uint16; - } - leaf reason { - // Reason packet is being sent (one of OFPR_*) - type oft:packet-in-reason; - } - leaf table-id { - // ID of the table that was looked up - type oft:table-id; - } - leaf cookie { - // Cookie of the flow entry that was looked up. - type uint64; - } - uses oxm:match-grouping; - - leaf data { - type binary; - } - - // OF1.0 structures - leaf in-port { - type uint16; - } - } - grouping flow-removed { - reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"; - /* Async message */ - uses ofHeader; - - leaf cookie { - type uint64; - } - leaf priority { - type uint16; - } - leaf reason { - type oft:flow-removed-reason; - } - leaf table-id { - type oft:table-id; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - grouping port-status { - reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"; - - uses ofHeader; - - uses port-grouping; - - leaf reason { - type oft:port-reason; - } - } - /* Controller command messages. */ - grouping packet-out { - reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - uses ofaction:actions-grouping; - - leaf data { - type binary; - } - leaf buffer-id { - type uint32; - } - leaf in-port { - type oft:port-number; - } - } - grouping flow-mod { - reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - leaf table-id { - type oft:table-id; - } - leaf command { - type oft:flow-mod-command; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf priority { - type uint16; - } - leaf buffer-id { - type uint32; - } - leaf out-port { - type oft:port-number; - } - leaf out-group { - type uint32; - } - leaf flags { - type oft:flow-mod-flags; - } - uses oxm:match-grouping; - - uses ofinstruction:instructions-grouping; - - // OF1.0 structures - leaf flags-v10 { - type oft:flow-mod-flags-v10; - } - uses oxm:match-v10-grouping; - uses ofaction:actions-grouping; - } - grouping group-mod { - reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf command { - type oft:group-mod-command; - } - leaf type { - type oft:group-type; - } - leaf group-id { - type oft:group-id; - } - - uses buckets-grouping; - } - - grouping port-mod { - reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port-no { - type oft:port-number; - } - leaf hw-address { - type yang:mac-address; - } - leaf config { - type oft:port-config; - } - leaf mask { - type oft:port-config; - } - leaf advertise { - type oft:port-features; - } - // OF1.0 structures - leaf config-v10 { - type oft:port-config-v10; - } - leaf mask-v10 { - type oft:port-config-v10; - } - leaf advertise-v10 { - type oft:port-features-v10; - } - } - grouping table-mod { - reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf table-id { - type oft:table-id; - } - leaf config { - type oft:table-config; - } - } - - /* Multipart messages. */ - grouping multipart-request { - reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf type { - type oft:multipart-type; - } - leaf flags { - type oft:multipart-request-flags; - } - choice multipart-request-body { - case multipart-request-desc-case { - container multipart-request-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-flow-case { - container multipart-request-flow { - leaf table-id { - type uint8; - } - leaf out-port { - type uint32; - } - leaf out-group { - type uint32; - } - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - } - case multipart-request-aggregate-case { - container multipart-request-aggregate { - leaf table-id { - type uint8; - } - leaf out-port { - type uint32; - } - leaf out-group { - type uint32; - } - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - } - case multipart-request-table-case { - container multipart-request-table { - leaf empty { - type empty; - } - } - } - case multipart-request-port-stats-case { - container multipart-request-port-stats { - leaf port-no { - type uint32; - } - } - } - case multipart-request-queue-case { - container multipart-request-queue { - leaf port-no { - type uint32; - } - leaf queue-id { - type uint32; - } - } - } - case multipart-request-group-case { - container multipart-request-group { - leaf group-id { - type oft:group-id; - } - } - } - case multipart-request-group-desc-case { - container multipart-request-group-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-group-features-case { - container multipart-request-group-features { - leaf empty { - type empty; - } - } - } - case multipart-request-meter-case { - container multipart-request-meter { - leaf meter-id { - type oft:meter-id; - } - } - } - case multipart-request-meter-config-case { - container multipart-request-meter-config { - leaf meter-id { - type oft:meter-id; - } - } - } - case multipart-request-meter-features-case { - container multipart-request-meter-features { - leaf empty { - type empty; - } - } - } - case multipart-request-table-features-case { - container multipart-request-table-features { - list table-features { - leaf table-id { - type uint8; - } - leaf name { - type string; - } - leaf metadata-match { - type uint64; - } - leaf metadata-write { - type uint64; - } - leaf config { - type oft:table-config; - } - leaf max-entries { - type uint32; - } - uses table-features-properties-grouping; - } - } - } - case multipart-request-port-desc-case { - container multipart-request-port-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-experimenter-case { - container multipart-request-experimenter { - // empty body - used for experimenter augmentation - } - } - } - } - grouping multipart-reply { - reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf type { - type oft:multipart-type; - } - leaf flags { - type oft:multipart-request-flags; - } - choice multipart-reply-body { - case multipart-reply-desc-case { - container multipart-reply-desc { - leaf mfr_desc { - type string; - } - leaf hw_desc { - type string; - } - leaf sw_desc { - type string; - } - leaf serial_num { - type string; - } - leaf dp_desc { - type string; - } - } - } - case multipart-reply-flow-case { - container multipart-reply-flow { - list flow-stats { - leaf table-id { - type uint8; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - leaf priority { - type uint16; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf flags { - type oft:flow-mod-flags; - } - leaf cookie { - type uint64; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - uses oxm:match-grouping; - - uses ofinstruction:instructions-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - uses ofaction:actions-grouping; - } - } - } - case multipart-reply-aggregate-case { - container multipart-reply-aggregate { - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - leaf flow-count { - type uint32; - } - } - } - case multipart-reply-table-case { - container multipart-reply-table { - list table-stats { - leaf table-id { - type uint8; - } - leaf active-count { - type uint32; - } - leaf lookup-count { - type uint64; - } - leaf matched-count { - type uint64; - } - - // OF1.0 structures - leaf name { - type string; - } - leaf wildcards { - type oft:flow-wildcards-v10; - } - leaf nw-src-mask { - type uint8; - } - leaf nw-dst-mask { - type uint8; - } - leaf max-entries { - type uint32; - } - } - } - } - case multipart-reply-port-stats-case { - container multipart-reply-port-stats { - list port-stats { - leaf port-no { - type uint32; - } - leaf rx-packets { - type uint64; - } - leaf tx-packets { - type uint64; - } - leaf rx-bytes { - type uint64; - } - leaf tx-bytes { - type uint64; - } - leaf rx-dropped { - type uint64; - } - leaf tx-dropped { - type uint64; - } - leaf rx-errors { - type uint64; - } - leaf tx-errors { - type uint64; - } - leaf rx-frame-err { - type uint64; - } - leaf rx-over-err { - type uint64; - } - leaf rx-crc-err { - type uint64; - } - leaf collisions { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - } - } - } - case multipart-reply-queue-case { - container multipart-reply-queue { - list queue-stats { - leaf port-no { - type uint32; - } - leaf queue-id { - type uint32; - } - leaf tx-bytes { - type uint64; - } - leaf tx-packets { - type uint64; - } - leaf tx-errors { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - } - } - } - case multipart-reply-group-case { - container multipart-reply-group { - list group-stats { - leaf group-id { - type oft:group-id; - } - leaf ref-count { - type uint32; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - list bucket-stats { - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - } - } - } - } - case multipart-reply-group-desc-case { - container multipart-reply-group-desc { - list group-desc { - leaf type { - type oft:group-type; - } - leaf group-id { - type oft:group-id; - } - uses buckets-grouping; - } - } - } - case multipart-reply-group-features-case { - container multipart-reply-group-features { - leaf types { - type oft:group-types; - } - leaf capabilities { - type oft:group-capabilities; - } - leaf-list max_groups { - type uint32; - } - leaf-list actions-bitmap { - type oft:action-type; - } - } - } - case multipart-reply-meter-case { - container multipart-reply-meter { - list meter-stats { - leaf meter-id { - type oft:meter-id; - } - leaf flow-count { - type uint32; - } - leaf packet-in-count { - type uint64; - } - leaf byte-in-count { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - list meter-band-stats { - leaf packet-band-count { - type uint64; - } - leaf byte-band-count { - type uint64; - } - } - } - } - } - case multipart-reply-meter-config-case { - container multipart-reply-meter-config { - list meter-config { - leaf flags { - type oft:meter-flags; - } - leaf meter-id { - type oft:meter-id; - } - list bands { - uses meter-band-header; - } - } - } - } - case multipart-reply-meter-features-case { - container multipart-reply-meter-features { - leaf max-meter { - type uint32; - } - leaf band-types { - type oft:meter-band-type-bitmap; - } - leaf capabilities { - type oft:meter-flags; - } - leaf max-bands { - type uint8; - } - leaf max-color { - type uint8; - } - } - } - case multipart-reply-table-features-case { - container multipart-reply-table-features { - list table-features { - leaf table-id { - type uint8; - } - leaf name { - type string; - } - leaf metadata-match { - type binary; - } - leaf metadata-write { - type binary; - } - leaf config { - type oft:table-config; - } - leaf max-entries { - type uint32; - } - uses table-features-properties-grouping; - } - } - } - case multipart-reply-port-desc-case { - container multipart-reply-port-desc { - list ports { - uses port-grouping; - } - } - } - case multipart-reply-experimenter-case { - container multipart-reply-experimenter { - // empty body - used for experimenter augmentation - } - } - } - } - /* Barrier messages. */ - grouping barrier-request { - reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping barrier-reply { - reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - /* Queue Configuration messages. */ - grouping queue-get-config-request { - reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port { - type oft:port-number; - } - } - grouping queue-get-config-reply { - reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port { - type oft:port-number; - } - list queues { - uses packet-queue; - } - } - grouping packet-queue { - leaf queue-id { - type oft:queue-id; - } - leaf port { - type oft:port-number; - } - uses queue-property-header; - } - container queue-prop-container { - uses queue-property-header; - } - grouping queue-property-header { - list queue-property { - config false; - leaf property { - type oft:queue-properties; - } - } - } - /* Controller role change request messages. */ - grouping role-request { - reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf role { - type oft:controller-role; - } - leaf generation-id { - type uint64; - } - } - grouping role-reply { - reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf role { - type oft:controller-role; - } - leaf generation-id { - type uint64; - } - } - /* Asynchronous message configuration. */ - grouping get-async-request { - reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - } - grouping get-async-reply { - reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - uses async-body-grouping; - } - grouping set-async { - reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - uses async-body-grouping; - } - - grouping async-body-grouping { - list packet-in-mask { - leaf-list mask { - type oft:packet-in-reason; - } - } - list port-status-mask { - leaf-list mask { - type oft:port-reason; - } - } - list flow-removed-mask { - leaf-list mask { - type oft:flow-removed-reason; - } - } - } - /* Meters and rate limiters configuration messages. */ - grouping meter-mod { - reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf command { - type oft:meter-mod-command; - } - leaf flags { - type oft:meter-flags; - } - leaf meter-id { - type oft:meter-id; - } - list bands { - uses meter-band-header; - } - } - - container meter-band-container { - uses meter-band-header; - } - grouping meter-band-header { - choice meter-band { - case meter-band-drop-case { - container meter-band-drop { - uses meter-band-commons; - } - } - case meter-band-dscp-remark-case { - container meter-band-dscp-remark { - uses meter-band-commons; - leaf prec-level { - type uint8; - } - } - } - case meter-band-experimenter-case { - container meter-band-experimenter { - uses meter-band-commons; - } - } - } - } - - grouping meter-band-commons { - leaf type { - type oft:meter-band-type; - } - leaf rate { - type uint32; - } - leaf burst-size { - type uint32; - } - } - - /* Immutable messages. */ - notification hello-message { - uses hello; - reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification error-message { - uses error; - reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification echo-request-message { - uses echo-request; - reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification experimenter-message { - uses experimenter; - reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; - // TODO:: does switch send this when understood experimenter msg from lib? - /* Symmetric message */ - } - // # Notification and RPCs - /* Symmetric RPC. */ - rpc echo { - input { - uses echo-request; - } - /* Controller/switch message */ - output { - uses echo-reply; - } - } - - rpc echo-reply { - input { - uses echo-reply; - } - } - - rpc hello { - input { - uses hello; - } - } - - rpc experimenter { - input { - uses experimenter; - } - } - - /* Switch configuration messages. */ - rpc get-features { - input { - uses features-request; - } - /* Controller/switch message */ - output { - uses features-reply; - } - } - - rpc get-config { - input { - uses get-config-request; - } - output { - uses get-config-reply; - } - /* Controller/switch message */ - } - - rpc set-config { - input { - uses set-config; - } - /* Controller/switch message */ - } - /* Asynchronous messages. */ - notification packet-in-message { - uses packet-in; - - /* Async message */ - } - notification flow-removed-message { - uses flow-removed; - - /* Async message */ - } - notification port-status-message { - uses port-status; - - } /* Async message */ - - /* Controller command messages. */ - rpc packet-out { - input { - uses packet-out; - } - /* Controller/switch message */ - } - rpc flow-mod { - input { - uses flow-mod; - } - /* Controller/switch message */ - } - rpc group-mod { - input { - uses group-mod; - } - /* Controller/switch message */ - } - rpc port-mod { - input { - uses port-mod; - } - } /* Controller/switch message */ - - rpc table-mod { - input { - uses table-mod; - } - } /* Controller/switch message */ - - /* Multipart messages. */ - - rpc multipart-request { - input { - uses multipart-request; - } - } - - /* Controller/switch message */ - notification multipart-reply-message { - uses multipart-reply; - // notification because of multiple following responses - } /* Controller/switch message */ - - - /* Barrier messages. */ - rpc barrier { - input { - uses barrier-request; - } - output { - uses barrier-reply; - } - } - /* Queue Configuration messages. */ - rpc get-queue-config { - input { - uses queue-get-config-request; - } - output { - uses queue-get-config-reply; - } - } - - /* Controller role change request messages. */ - rpc role-request { - input { - uses role-request; - } - output { - uses role-reply; - } - } /* Controller/switch message */ - - /* Asynchronous message configuration. */ - rpc get-async { - input { - uses get-async-request; - } - output { - uses get-async-reply; - } - } - /* Controller/switch message */ - rpc set-async { - input { - uses set-async; - } - - } - /* Meters and rate limiters configuration messages. */ - rpc meter-mod { - input { - uses meter-mod; - } - } /* Controller/switch message */ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + + module openflow-protocol { + namespace "urn:opendaylight:openflow:protocol"; + prefix "ofproto"; + + import ietf-yang-types {prefix yang;} + + import openflow-types {prefix oft;} + import openflow-extensible-match { prefix oxm;} + import openflow-instruction { prefix ofinstruction;} + import openflow-action {prefix ofaction;} + + revision "2013-07-31" { + description "OpenFlow 1.3 - protocol objects model"; + } + + // Generic Structures + grouping port-grouping { + reference "ofp_port"; + leaf port-no { + type uint32; + } + leaf hw-addr { + type yang:mac-address; + } + leaf name { + type string; + } + leaf config { + description "Bitmap of OFPPC_* flags."; + type oft:port-config; + } + leaf state { + description "Bitmap of OFPPS_* flags."; + type oft:port-state; + } + leaf current-features { + description "Current features."; + type oft:port-features; + } + leaf advertised-features { + description "Features being advertised by the port."; + type oft:port-features; + } + leaf supported-features { + description "Features supported by the port."; + type oft:port-features; + } + leaf peer-features { + description "Features advertised by peer."; + type oft:port-features; + } + leaf curr-speed { + description "Current port bitrate in kbps."; + type uint32; + units "kbps"; + } + leaf max-speed { + description "Max port bitrate in kbps"; + type uint32; + units "kbps"; + } + + // OF1.0 structures + leaf config-v10 { + type oft:port-config-v10; + } + leaf state-v10 { + type oft:port-state-v10; + } + leaf current-features-v10 { + description "Current features."; + type oft:port-features-v10; + } + leaf advertised-features-v10 { + description "Features being advertised by the port."; + type oft:port-features-v10; + } + leaf supported-features-v10 { + description "Features supported by the port."; + type oft:port-features-v10; + } + leaf peer-features-v10 { + description "Features advertised by peer."; + type oft:port-features-v10; + } + } + + grouping buckets-grouping { + list buckets-list { + uses bucket-grouping; + } + } + + grouping bucket-grouping { + description "Bucket for use in groups."; + leaf weight { + description "Relative weight of bucket. Only + defined for select groups."; + type uint16; + } + leaf watch-port { + description "Port whose state affects whether this + bucket is live. Only required for fast + failover groups."; + type oft:port-number; + } + leaf watch-group { + description "Group whose state affects whether this + bucket is live. Only required for fast + failover groups."; + type uint32; + } + + uses ofaction:actions-grouping; + } + + container table-features-properties-container { + uses table-features-properties-grouping; + } + + grouping table-features-properties-grouping { + list table-feature-properties { + config false; + leaf type { + type oft:table-features-prop-type; + } + } + } + + // # MESSAGE Structures + /* Immutable messages. */ + grouping ofHeader { + reference "ofp_header struct in Openflow Switch 1.3 Spec"; + leaf version { + type uint8; + description "OpenFlow version"; + } + leaf xid { + type uint32; + description "Transaction ID"; + } + } + grouping ofHelloElementHeader { + reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"; + leaf type { + type oft:hello-element-type; + //reference "OpenFlow Header element type - OFPHET_*"; + } + } + grouping hello { + reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + list elements { + uses ofHelloElementHeader; + + leaf-list version-bitmap { + type boolean; + } + } + } + grouping error { + reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf type { + type uint16; + } + leaf code { + type uint16; + } + leaf type-string { + type string; + } + leaf code-string { + type string; + } + leaf data { + type binary; + } + } + grouping echo-request { + reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf data { + type binary; + } + } + grouping echo-reply { + reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf data { + type binary; + } + } + grouping experimenter { + reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf experimenter { + type oft:experimenter-id; + } + leaf exp_type { + type uint32; + } + } + /* Switch configuration messages. */ + grouping features-request { + reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping features-reply { + reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + + leaf datapathId { + type uint64; + } + leaf buffers { + type uint32; + } + leaf tables { + type uint8; + } + leaf auxiliaryId { + type uint8; + } + leaf capabilities { + type oft:capabilities; + } + leaf reserved { + type uint32; + } + // OF1.0 structures + leaf capabilities-v10 { + type oft:capabilities-v10; + } + leaf actions-v10 { + type oft:action-type-v10; + } + list phy-port { + uses port-grouping; + } + } + grouping get-config-request { + reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping get-config-reply { + reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + + leaf flags { + type oft:switch-config-flag; + } + leaf miss-send-len { + type uint16; + } + } + grouping set-config { + reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf flags { + type oft:switch-config-flag; + } + leaf miss-send-len { + type uint16; + } + } + /* Asynchronous messages. */ + grouping packet-in { + reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"; + /* Async message */ + + uses ofHeader; + + leaf buffer-id { + // ID assigned by datapath. + type uint32; + } + leaf total-len { + // Full length of frame. + type uint16; + } + leaf reason { + // Reason packet is being sent (one of OFPR_*) + type oft:packet-in-reason; + } + leaf table-id { + // ID of the table that was looked up + type oft:table-id; + } + leaf cookie { + // Cookie of the flow entry that was looked up. + type uint64; + } + uses oxm:match-grouping; + + leaf data { + type binary; + } + + // OF1.0 structures + leaf in-port { + type uint16; + } + } + grouping flow-removed { + reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"; + /* Async message */ + uses ofHeader; + + leaf cookie { + type uint64; + } + leaf priority { + type uint16; + } + leaf reason { + type oft:flow-removed-reason; + } + leaf table-id { + type oft:table-id; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + grouping port-status { + reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"; + + uses ofHeader; + + uses port-grouping; + + leaf reason { + type oft:port-reason; + } + } + /* Controller command messages. */ + grouping packet-out { + reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + uses ofaction:actions-grouping; + + leaf data { + type binary; + } + leaf buffer-id { + type uint32; + } + leaf in-port { + type oft:port-number; + } + } + grouping flow-mod { + reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + leaf table-id { + type oft:table-id; + } + leaf command { + type oft:flow-mod-command; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf priority { + type uint16; + } + leaf buffer-id { + type uint32; + } + leaf out-port { + type oft:port-number; + } + leaf out-group { + type uint32; + } + leaf flags { + type oft:flow-mod-flags; + } + uses oxm:match-grouping; + + uses ofinstruction:instructions-grouping; + + // OF1.0 structures + leaf flags-v10 { + type oft:flow-mod-flags-v10; + } + uses oxm:match-v10-grouping; + uses ofaction:actions-grouping; + } + grouping group-mod { + reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf command { + type oft:group-mod-command; + } + leaf type { + type oft:group-type; + } + leaf group-id { + type oft:group-id; + } + + uses buckets-grouping; + } + + grouping port-mod { + reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port-no { + type oft:port-number; + } + leaf hw-address { + type yang:mac-address; + } + leaf config { + type oft:port-config; + } + leaf mask { + type oft:port-config; + } + leaf advertise { + type oft:port-features; + } + // OF1.0 structures + leaf config-v10 { + type oft:port-config-v10; + } + leaf mask-v10 { + type oft:port-config-v10; + } + leaf advertise-v10 { + type oft:port-features-v10; + } + } + grouping table-mod { + reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf table-id { + type oft:table-id; + } + leaf config { + type oft:table-config; + } + } + + /* Multipart messages. */ + grouping multipart-request { + reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf type { + type oft:multipart-type; + } + leaf flags { + type oft:multipart-request-flags; + } + choice multipart-request-body { + case multipart-request-desc-case { + container multipart-request-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-flow-case { + container multipart-request-flow { + leaf table-id { + type uint8; + } + leaf out-port { + type uint32; + } + leaf out-group { + type uint32; + } + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + } + case multipart-request-aggregate-case { + container multipart-request-aggregate { + leaf table-id { + type uint8; + } + leaf out-port { + type uint32; + } + leaf out-group { + type uint32; + } + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + } + case multipart-request-table-case { + container multipart-request-table { + leaf empty { + type empty; + } + } + } + case multipart-request-port-stats-case { + container multipart-request-port-stats { + leaf port-no { + type uint32; + } + } + } + case multipart-request-queue-case { + container multipart-request-queue { + leaf port-no { + type uint32; + } + leaf queue-id { + type uint32; + } + } + } + case multipart-request-group-case { + container multipart-request-group { + leaf group-id { + type oft:group-id; + } + } + } + case multipart-request-group-desc-case { + container multipart-request-group-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-group-features-case { + container multipart-request-group-features { + leaf empty { + type empty; + } + } + } + case multipart-request-meter-case { + container multipart-request-meter { + leaf meter-id { + type oft:meter-id; + } + } + } + case multipart-request-meter-config-case { + container multipart-request-meter-config { + leaf meter-id { + type oft:meter-id; + } + } + } + case multipart-request-meter-features-case { + container multipart-request-meter-features { + leaf empty { + type empty; + } + } + } + case multipart-request-table-features-case { + container multipart-request-table-features { + list table-features { + leaf table-id { + type uint8; + } + leaf name { + type string; + } + leaf metadata-match { + type uint64; + } + leaf metadata-write { + type uint64; + } + leaf config { + type oft:table-config; + } + leaf max-entries { + type uint32; + } + uses table-features-properties-grouping; + } + } + } + case multipart-request-port-desc-case { + container multipart-request-port-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-experimenter-case { + container multipart-request-experimenter { + // empty body - used for experimenter augmentation + } + } + } + } + grouping multipart-reply { + reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf type { + type oft:multipart-type; + } + leaf flags { + type oft:multipart-request-flags; + } + choice multipart-reply-body { + case multipart-reply-desc-case { + container multipart-reply-desc { + leaf mfr_desc { + type string; + } + leaf hw_desc { + type string; + } + leaf sw_desc { + type string; + } + leaf serial_num { + type string; + } + leaf dp_desc { + type string; + } + } + } + case multipart-reply-flow-case { + container multipart-reply-flow { + list flow-stats { + leaf table-id { + type uint8; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + leaf priority { + type uint16; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf flags { + type oft:flow-mod-flags; + } + leaf cookie { + type uint64; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + uses oxm:match-grouping; + + uses ofinstruction:instructions-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + uses ofaction:actions-grouping; + } + } + } + case multipart-reply-aggregate-case { + container multipart-reply-aggregate { + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + leaf flow-count { + type uint32; + } + } + } + case multipart-reply-table-case { + container multipart-reply-table { + list table-stats { + leaf table-id { + type uint8; + } + leaf active-count { + type uint32; + } + leaf lookup-count { + type uint64; + } + leaf matched-count { + type uint64; + } + + // OF1.0 structures + leaf name { + type string; + } + leaf wildcards { + type oft:flow-wildcards-v10; + } + leaf nw-src-mask { + type uint8; + } + leaf nw-dst-mask { + type uint8; + } + leaf max-entries { + type uint32; + } + } + } + } + case multipart-reply-port-stats-case { + container multipart-reply-port-stats { + list port-stats { + leaf port-no { + type uint32; + } + leaf rx-packets { + type uint64; + } + leaf tx-packets { + type uint64; + } + leaf rx-bytes { + type uint64; + } + leaf tx-bytes { + type uint64; + } + leaf rx-dropped { + type uint64; + } + leaf tx-dropped { + type uint64; + } + leaf rx-errors { + type uint64; + } + leaf tx-errors { + type uint64; + } + leaf rx-frame-err { + type uint64; + } + leaf rx-over-err { + type uint64; + } + leaf rx-crc-err { + type uint64; + } + leaf collisions { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + } + } + } + case multipart-reply-queue-case { + container multipart-reply-queue { + list queue-stats { + leaf port-no { + type uint32; + } + leaf queue-id { + type uint32; + } + leaf tx-bytes { + type uint64; + } + leaf tx-packets { + type uint64; + } + leaf tx-errors { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + } + } + } + case multipart-reply-group-case { + container multipart-reply-group { + list group-stats { + leaf group-id { + type oft:group-id; + } + leaf ref-count { + type uint32; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + list bucket-stats { + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + } + } + } + } + case multipart-reply-group-desc-case { + container multipart-reply-group-desc { + list group-desc { + leaf type { + type oft:group-type; + } + leaf group-id { + type oft:group-id; + } + uses buckets-grouping; + } + } + } + case multipart-reply-group-features-case { + container multipart-reply-group-features { + leaf types { + type oft:group-types; + } + leaf capabilities { + type oft:group-capabilities; + } + leaf-list max_groups { + type uint32; + } + leaf-list actions-bitmap { + type oft:action-type; + } + } + } + case multipart-reply-meter-case { + container multipart-reply-meter { + list meter-stats { + leaf meter-id { + type oft:meter-id; + } + leaf flow-count { + type uint32; + } + leaf packet-in-count { + type uint64; + } + leaf byte-in-count { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + list meter-band-stats { + leaf packet-band-count { + type uint64; + } + leaf byte-band-count { + type uint64; + } + } + } + } + } + case multipart-reply-meter-config-case { + container multipart-reply-meter-config { + list meter-config { + leaf flags { + type oft:meter-flags; + } + leaf meter-id { + type oft:meter-id; + } + list bands { + uses meter-band-header; + } + } + } + } + case multipart-reply-meter-features-case { + container multipart-reply-meter-features { + leaf max-meter { + type uint32; + } + leaf band-types { + type oft:meter-band-type-bitmap; + } + leaf capabilities { + type oft:meter-flags; + } + leaf max-bands { + type uint8; + } + leaf max-color { + type uint8; + } + } + } + case multipart-reply-table-features-case { + container multipart-reply-table-features { + list table-features { + leaf table-id { + type uint8; + } + leaf name { + type string; + } + leaf metadata-match { + type binary; + } + leaf metadata-write { + type binary; + } + leaf config { + type oft:table-config; + } + leaf max-entries { + type uint32; + } + uses table-features-properties-grouping; + } + } + } + case multipart-reply-port-desc-case { + container multipart-reply-port-desc { + list ports { + uses port-grouping; + } + } + } + case multipart-reply-experimenter-case { + container multipart-reply-experimenter { + // empty body - used for experimenter augmentation + } + } + } + } + /* Barrier messages. */ + grouping barrier-request { + reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping barrier-reply { + reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + /* Queue Configuration messages. */ + grouping queue-get-config-request { + reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port { + type oft:port-number; + } + } + grouping queue-get-config-reply { + reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port { + type oft:port-number; + } + list queues { + uses packet-queue; + } + } + grouping packet-queue { + leaf queue-id { + type oft:queue-id; + } + leaf port { + type oft:port-number; + } + uses queue-property-header; + } + container queue-prop-container { + uses queue-property-header; + } + grouping queue-property-header { + list queue-property { + config false; + leaf property { + type oft:queue-properties; + } + } + } + /* Controller role change request messages. */ + grouping role-request { + reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf role { + type oft:controller-role; + } + leaf generation-id { + type uint64; + } + } + grouping role-reply { + reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf role { + type oft:controller-role; + } + leaf generation-id { + type uint64; + } + } + /* Asynchronous message configuration. */ + grouping get-async-request { + reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + } + grouping get-async-reply { + reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + uses async-body-grouping; + } + grouping set-async { + reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + uses async-body-grouping; + } + + grouping async-body-grouping { + list packet-in-mask { + leaf-list mask { + type oft:packet-in-reason; + } + } + list port-status-mask { + leaf-list mask { + type oft:port-reason; + } + } + list flow-removed-mask { + leaf-list mask { + type oft:flow-removed-reason; + } + } + } + /* Meters and rate limiters configuration messages. */ + grouping meter-mod { + reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf command { + type oft:meter-mod-command; + } + leaf flags { + type oft:meter-flags; + } + leaf meter-id { + type oft:meter-id; + } + list bands { + uses meter-band-header; + } + } + + container meter-band-container { + uses meter-band-header; + } + grouping meter-band-header { + choice meter-band { + case meter-band-drop-case { + container meter-band-drop { + uses meter-band-commons; + } + } + case meter-band-dscp-remark-case { + container meter-band-dscp-remark { + uses meter-band-commons; + leaf prec-level { + type uint8; + } + } + } + case meter-band-experimenter-case { + container meter-band-experimenter { + uses meter-band-commons; + } + } + } + } + + grouping meter-band-commons { + leaf type { + type oft:meter-band-type; + } + leaf rate { + type uint32; + } + leaf burst-size { + type uint32; + } + } + + /* Immutable messages. */ + notification hello-message { + uses hello; + reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification error-message { + uses error; + reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification echo-request-message { + uses echo-request; + reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification experimenter-message { + uses experimenter; + reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; + // TODO:: does switch send this when understood experimenter msg from lib? + /* Symmetric message */ + } + // # Notification and RPCs + /* Symmetric RPC. */ + rpc echo { + input { + uses echo-request; + } + /* Controller/switch message */ + output { + uses echo-reply; + } + } + + rpc echo-reply { + input { + uses echo-reply; + } + } + + rpc hello { + input { + uses hello; + } + } + + rpc experimenter { + input { + uses experimenter; + } + } + + /* Switch configuration messages. */ + rpc get-features { + input { + uses features-request; + } + /* Controller/switch message */ + output { + uses features-reply; + } + } + + rpc get-config { + input { + uses get-config-request; + } + output { + uses get-config-reply; + } + /* Controller/switch message */ + } + + rpc set-config { + input { + uses set-config; + } + /* Controller/switch message */ + } + /* Asynchronous messages. */ + notification packet-in-message { + uses packet-in; + + /* Async message */ + } + notification flow-removed-message { + uses flow-removed; + + /* Async message */ + } + notification port-status-message { + uses port-status; + + } /* Async message */ + + /* Controller command messages. */ + rpc packet-out { + input { + uses packet-out; + } + /* Controller/switch message */ + } + rpc flow-mod { + input { + uses flow-mod; + } + /* Controller/switch message */ + } + rpc group-mod { + input { + uses group-mod; + } + /* Controller/switch message */ + } + rpc port-mod { + input { + uses port-mod; + } + } /* Controller/switch message */ + + rpc table-mod { + input { + uses table-mod; + } + } /* Controller/switch message */ + + /* Multipart messages. */ + + rpc multipart-request { + input { + uses multipart-request; + } + } + + /* Controller/switch message */ + notification multipart-reply-message { + uses multipart-reply; + // notification because of multiple following responses + } /* Controller/switch message */ + + + /* Barrier messages. */ + rpc barrier { + input { + uses barrier-request; + } + output { + uses barrier-reply; + } + } + /* Queue Configuration messages. */ + rpc get-queue-config { + input { + uses queue-get-config-request; + } + output { + uses queue-get-config-reply; + } + } + + /* Controller role change request messages. */ + rpc role-request { + input { + uses role-request; + } + output { + uses role-reply; + } + } /* Controller/switch message */ + + /* Asynchronous message configuration. */ + rpc get-async { + input { + uses get-async-request; + } + output { + uses get-async-reply; + } + } + /* Controller/switch message */ + rpc set-async { + input { + uses set-async; + } + + } + /* Meters and rate limiters configuration messages. */ + rpc meter-mod { + input { + uses meter-mod; + } + } /* Controller/switch message */ } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java index 9816c250..f71d2302 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.connection; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - -/** - * @author michal.polkorab - * - */ -public class TlsConfigurationImplTest { - - /** - * Test correct TlsConfigurationImpl creation - */ - @Test - public void test() { - TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, - "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); - assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); - assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); - assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); - assertEquals("Wrong truststore type", KeystoreType.JKS, config.getTlsTruststoreType()); - assertEquals("Wrong keystore path type", PathType.PATH, config.getTlsKeystorePathType()); - assertEquals("Wrong truststore path type", PathType.CLASSPATH, config.getTlsTruststorePathType()); - assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); - assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); - assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.connection; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * @author michal.polkorab + * + */ +public class TlsConfigurationImplTest { + + /** + * Test correct TlsConfigurationImpl creation + */ + @Test + public void test() { + TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, + "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); + assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); + assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); + assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); + assertEquals("Wrong truststore type", KeystoreType.JKS, config.getTlsTruststoreType()); + assertEquals("Wrong keystore path type", PathType.PATH, config.getTlsKeystorePathType()); + assertEquals("Wrong truststore path type", PathType.CLASSPATH, config.getTlsTruststorePathType()); + assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); + assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); + assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index 7b350d55..82377828 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageCodeKeyTest { - - /** - * Test EnhancedMessageCodeKey equals and hashCode - */ - @Test - public void test() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - EnhancedMessageCodeKey key2 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, 8, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, 8, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 16, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test EnhancedMessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - } - - /** - * Test EnhancedMessageCodeKey toString() - */ - @Test - public void testToString() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageCodeKeyTest { + + /** + * Test EnhancedMessageCodeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + EnhancedMessageCodeKey key2 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 16, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + } + + /** + * Test EnhancedMessageCodeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index e6be8a8d..40ff08cc 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageTypeKeyTest { - - /** - * Test EnhancedMessageTypeKey equals and hashCode - */ - @Test - public void test() { - EnhancedMessageTypeKey key1 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - EnhancedMessageTypeKey key2 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test EnhancedMessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - EnhancedMessageTypeKey key1; - EnhancedMessageTypeKey key2; - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); - Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); - Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); - } - - /** - * Test EnhancedMessageTypeKey toString() - */ - @Test - public void testToString() { - EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, - Action.class, Output.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageTypeKeyTest { + + /** + * Test EnhancedMessageTypeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageTypeKey key1 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + EnhancedMessageTypeKey key2 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + EnhancedMessageTypeKey key1; + EnhancedMessageTypeKey key2; + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); + } + + /** + * Test EnhancedMessageTypeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, + Action.class, Output.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java index 4087a55b..2c0425f4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class MessageCodeKeyTest { - - /** - * Test MessageCodeKey equals and hashCode - */ - @Test - public void test() { - MessageCodeKey key1 = - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - MessageCodeKey key2 = - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MessageCodeKey equals - additional test - */ - @Test - public void testEquals() { - MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to null.", key1.equals(null)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); - - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2)); - } - - /** - * Test MessageCodeKey toString() - */ - @Test - public void testToString() { - MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageCodeKeyTest { + + /** + * Test MessageCodeKey equals and hashCode + */ + @Test + public void test() { + MessageCodeKey key1 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + MessageCodeKey key2 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MessageCodeKey equals - additional test + */ + @Test + public void testEquals() { + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); + + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2)); + } + + /** + * Test MessageCodeKey toString() + */ + @Test + public void testToString() { + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 4dbd5541..83f426c4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class MessageTypeKeyTest { - - /** - * Test MessageTypeKey equals and hashCode - */ - @Test - public void test() { - MessageTypeKey key1 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - MessageTypeKey key2 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - MessageTypeKey key1; - MessageTypeKey key2; - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to null.", key1.equals(null)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); - - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); - } - - /** - * Test MessageTypeKey toString() - */ - @Test - public void testToString() { - MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageTypeKeyTest { + + /** + * Test MessageTypeKey equals and hashCode + */ + @Test + public void test() { + MessageTypeKey key1 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key2 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + MessageTypeKey key1; + MessageTypeKey key2; + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); + } + + /** + * Test MessageTypeKey toString() + */ + @Test + public void testToString() { + MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 66a09fe9..6ba052b7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerKeyTest { - - /** - * Test ActionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ActionDeserializerKey equals - additional test - */ - @Test - public void testEquals(){ - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test InstructionDeserializerKey toString() - */ - @Test - public void testToString(){ - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKeyTest { + + /** + * Test ActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index f9c5225d..043a3cfb 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; - -/** - * @author michal.polkorab - * - */ -public class ActionSerializerKeyTest { - - /** - * Test ActionSerializerKey equals and hashCode - */ - @Test - public void test() { - ActionSerializerKey key1 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - ActionSerializerKey key2 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ActionSerializerKey equals - additional test - */ - @Test - public void testEquals(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); - - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test ActionSerializerKey toString() - */ - @Test - public void testToString(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; + +/** + * @author michal.polkorab + * + */ +public class ActionSerializerKeyTest { + + /** + * Test ActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ActionSerializerKey key1 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key2 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test ActionSerializerKey toString() + */ + @Test + public void testToString(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java index 2497413a..208b4ff7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerKeyTest { - - /** - * Test InstructionDeserializerKey equals and hashCode - */ - @Test - public void test() { - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test InstructionDeserializerKey equals - additional test - */ - @Test - public void testEquals(){ - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test InstructionDeserializerKey toString() - */ - @Test - public void testToString(){ - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction msgType: 11" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKeyTest { + + /** + * Test InstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test InstructionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction msgType: 11" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index 8e7d1f5f..23aecd79 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; - -/** - * @author michal.polkorab - * - */ -public class InstructionSerializerKeyTest { - - /** - * Test InstructionSerializerKey equals and hashCode - */ - @Test - public void test() { - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test InstructionSerializerKey equals - additional test - */ - @Test - public void testEquals(){ - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2)); - } - - /** - * Test InstructionSerializerKey toString() - */ - @Test - public void testToString(){ - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" - + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" - + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; + +/** + * @author michal.polkorab + * + */ +public class InstructionSerializerKeyTest { + + /** + * Test InstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test InstructionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2)); + } + + /** + * Test InstructionSerializerKey toString() + */ + @Test + public void testToString(){ + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" + + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index be87d557..5c69cc65 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -1,83 +1,83 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class MatchEntryDeserializerKeyTest { - - /** - * Test MatchEntryDeserializerKey equals and hashCode - */ - @Test - public void test() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - key1.setExperimenterId(158L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MatchEntryDeserializerKey equals - additional test - */ - @Test - public void testEquals() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - Long expId1=123456L; - Long expId2=654321L; - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); - } - - /** - * Test MatchEntryDeserializerKey toString() - */ - @Test - public void testToString(){ - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerKeyTest { + + /** + * Test MatchEntryDeserializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + key1.setExperimenterId(158L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MatchEntryDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1=123456L; + Long expId2=654321L; + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); + } + + /** + * Test MatchEntryDeserializerKey toString() + */ + @Test + public void testToString(){ + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 576c446f..0863db37 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -1,107 +1,107 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; - -/** - * @author michal.polkorab - * - */ -public class MatchEntrySerializerKeyTest { - - /** - * Test MatchEntrySerializerKey equals and hashCode - */ - @Test - public void test() { - MatchEntrySerializerKey key1 = new MatchEntrySerializerKey<> - (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - MatchEntrySerializerKey key2 = new MatchEntrySerializerKey<> - (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - Nxm0Class.class, InPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID, - OpenflowBasicClass.class, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - null, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2.setExperimenterId(42L); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MatchEntrySerializerKey equals - additional test - */ - @Test - public void testEquals(){ - MatchEntrySerializerKey key1; - MatchEntrySerializerKey key2; - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - Long expId1 = 987654331L; - Long expId2 = 123456789L; - - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); - key1.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); - key2.setExperimenterId(expId2); - Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); - key1.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); - key2.setExperimenterId(expId2); - Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2)); - } - - /** - * Test MatchEntrySerializerKey toString() - */ - @Test - public void testToString(){ - MatchEntrySerializerKey key1; - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; + +/** + * @author michal.polkorab + * + */ +public class MatchEntrySerializerKeyTest { + + /** + * Test MatchEntrySerializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntrySerializerKey key1 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + MatchEntrySerializerKey key2 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Nxm0Class.class, InPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + null, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2.setExperimenterId(42L); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MatchEntrySerializerKey equals - additional test + */ + @Test + public void testEquals(){ + MatchEntrySerializerKey key1; + MatchEntrySerializerKey key2; + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1 = 987654331L; + Long expId2 = 123456789L; + + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key1.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2)); + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key1.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2)); + } + + /** + * Test MatchEntrySerializerKey toString() + */ + @Test + public void testToString(){ + MatchEntrySerializerKey key1; + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java index 47c59033..2357c71a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterActionDeserializerKeyTest { - - /** - * Test ExperimenterActionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterActionDeserializerKey key1 = - new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterActionDeserializerKey key2 = - new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionDeserializerKeyTest { + + /** + * Test ExperimenterActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionDeserializerKey key1 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterActionDeserializerKey key2 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index 761698d3..c8111fbd 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterActionSerializerKeyTest { - - - /** - * Test ExperimenterActionSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterActionSerializerKey key1 = - new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - ExperimenterActionSerializerKey key2 = - new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - @Test - public void testEquals() { - ExperimenterActionSerializerKey key1; - ExperimenterActionSerializerKey key2; - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); - Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - } - - - private static class TestSubType extends ExperimenterActionSubType { - // empty class - only used in test for comparation - } - - private static class TestSubType2 extends ExperimenterActionSubType { - // empty class - only used in test for comparation - } - - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionSerializerKeyTest { + + + /** + * Test ExperimenterActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionSerializerKey key1 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + ExperimenterActionSerializerKey key2 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + @Test + public void testEquals() { + ExperimenterActionSerializerKey key1; + ExperimenterActionSerializerKey key2; + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + } + + + private static class TestSubType extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } + + private static class TestSubType2 extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } + + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index dc3e956b..6938223a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterIdDeserializerKeyTest { - - /** - * Test ExperimenterIdDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - ExperimenterIdDeserializerKey key2 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ExperimenterIdDeserializerKey equals - additional test - */ - @Test - public void testEquals() { - ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); - ExperimenterIdDeserializerKey key2 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdDeserializerKeyTest { + + /** + * Test ExperimenterIdDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index 97fd73e1..06f06cbf 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterIdSerializerKeyTest { - - /** - * Test ExperimenterIdSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterIdSerializerKey key1 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - ExperimenterIdSerializerKey key2 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ExperimenterIdSerializerKey equals - additional test - */ - @Test - public void testEquals() { - ExperimenterIdSerializerKey key1 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); - Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); - ExperimenterIdSerializerKey key2 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdSerializerKeyTest { + + /** + * Test ExperimenterIdSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdSerializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java index 563cb562..fa924f91 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterInstructionDeserializerKeyTest { - - /** - * Test ExperimenterInstructionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterInstructionDeserializerKey key1 = - new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterInstructionDeserializerKey key2 = - new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionDeserializerKeyTest { + + /** + * Test ExperimenterInstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionDeserializerKey key1 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionDeserializerKey key2 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java index 58c535f8..db78e28c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterInstructionSerializerKeyTest { - - /** - * Test ExperimenterInstructionSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterInstructionSerializerKey key1 = - new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterInstructionSerializerKey key2 = - new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionSerializerKeyTest { + + /** + * Test ExperimenterInstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionSerializerKey key1 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionSerializerKey key2 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java index c453b0b0..7328f8c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; - -/** - * @author michal.polkorab - * - */ -public class ChannelInitializerFactory { - - private long switchIdleTimeOut; - private DeserializationFactory deserializationFactory; - private SerializationFactory serializationFactory; - private TlsConfiguration tlsConfig; - private SwitchConnectionHandler switchConnectionHandler; - - /** - * @return PublishingChannelInitializer that initializes new channels - */ - public TcpChannelInitializer createPublishingChannelInitializer() { - TcpChannelInitializer initializer = new TcpChannelInitializer(); - initializer.setSwitchIdleTimeout(switchIdleTimeOut); - initializer.setDeserializationFactory(deserializationFactory); - initializer.setSerializationFactory(serializationFactory); - initializer.setTlsConfiguration(tlsConfig); - initializer.setSwitchConnectionHandler(switchConnectionHandler); - return initializer; - } - - /** - * @return PublishingChannelInitializer that initializes new channels - */ - public UdpChannelInitializer createUdpChannelInitializer() { - UdpChannelInitializer initializer = new UdpChannelInitializer(); - initializer.setSwitchIdleTimeout(switchIdleTimeOut); - initializer.setDeserializationFactory(deserializationFactory); - initializer.setSerializationFactory(serializationFactory); - initializer.setSwitchConnectionHandler(switchConnectionHandler); - return initializer; - } - - /** - * @param switchIdleTimeOut - */ - public void setSwitchIdleTimeout(long switchIdleTimeOut) { - this.switchIdleTimeOut = switchIdleTimeOut; - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } - - /** - * @param tlsConfig - */ - public void setTlsConfig(TlsConfiguration tlsConfig) { - this.tlsConfig = tlsConfig; - } - - /** - * @param switchConnectionHandler - */ - public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { - this.switchConnectionHandler = switchConnectionHandler; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @author michal.polkorab + * + */ +public class ChannelInitializerFactory { + + private long switchIdleTimeOut; + private DeserializationFactory deserializationFactory; + private SerializationFactory serializationFactory; + private TlsConfiguration tlsConfig; + private SwitchConnectionHandler switchConnectionHandler; + + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public TcpChannelInitializer createPublishingChannelInitializer() { + TcpChannelInitializer initializer = new TcpChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setTlsConfiguration(tlsConfig); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public UdpChannelInitializer createUdpChannelInitializer() { + UdpChannelInitializer initializer = new UdpChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + + /** + * @param switchIdleTimeOut + */ + public void setSwitchIdleTimeout(long switchIdleTimeOut) { + this.switchIdleTimeOut = switchIdleTimeOut; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param tlsConfig + */ + public void setTlsConfig(TlsConfiguration tlsConfig) { + this.tlsConfig = tlsConfig; + } + + /** + * @param switchConnectionHandler + */ + public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index f4240bcc..670f552c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); - private DeserializationFactory deserializationFactory; - - @Override - public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg) - throws Exception { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("UdpVersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); - } - DataObject dataObject = null; - try { - dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); - if (dataObject == null) { - LOGGER.warn("Translated POJO is null"); - } else { - MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); - consumer.consume(dataObject); - } - } catch(Exception e) { - LOGGER.warn("Message deserialization failed"); - LOGGER.warn(e.getMessage(), e); - // TODO: delegate exception to allow easier deserialization - // debugging / deserialization problem awareness - } finally { - msg.getMessageBuffer().release(); - } - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); + private DeserializationFactory deserializationFactory; + + @Override + public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg) + throws Exception { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("UdpVersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + } + DataObject dataObject = null; + try { + dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); + if (dataObject == null) { + LOGGER.warn("Translated POJO is null"); + } else { + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); + consumer.consume(dataObject); + } + } catch(Exception e) { + LOGGER.warn("Message deserialization failed"); + LOGGER.warn(e.getMessage(), e); + // TODO: delegate exception to allow easier deserialization + // debugging / deserialization problem awareness + } finally { + msg.getMessageBuffer().release(); + } + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java index ab455f37..73a7a00e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.socket.DatagramPacket; -import io.netty.handler.codec.MessageToMessageEncoder; -import io.netty.util.concurrent.Future; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketEncoder extends MessageToMessageEncoder { - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); - private SerializationFactory serializationFactory; - - @Override - protected void encode(ChannelHandlerContext ctx, - UdpMessageListenerWrapper wrapper, List out) throws Exception { - LOGGER.trace("Encoding"); - try { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); - out.add(new DatagramPacket(buffer, wrapper.getAddress())); - } catch(Exception e) { - LOGGER.warn("Message serialization failed: {}", e.getMessage()); - Future newFailedFuture = ctx.newFailedFuture(e); - wrapper.getListener().operationComplete(newFailedFuture); - return; - } - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageEncoder; +import io.netty.util.concurrent.Future; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketEncoder extends MessageToMessageEncoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); + private SerializationFactory serializationFactory; + + @Override + protected void encode(ChannelHandlerContext ctx, + UdpMessageListenerWrapper wrapper, List out) throws Exception { + LOGGER.trace("Encoding"); + try { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); + out.add(new DatagramPacket(buffer, wrapper.getAddress())); + } catch(Exception e) { + LOGGER.warn("Message serialization failed: {}", e.getMessage()); + Future newFailedFuture = ctx.newFailedFuture(e); + wrapper.getListener().operationComplete(newFailedFuture); + return; + } + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index 3bda7b21..74e9c3a3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.socket.DatagramPacket; -import io.netty.handler.codec.MessageToMessageDecoder; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketHandler extends MessageToMessageDecoder { - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); - - /** Length of OpenFlow 1.3 header */ - public static final byte LENGTH_OF_HEADER = 8; - private static final byte LENGTH_INDEX_IN_HEADER = 2; - private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl(); - private SwitchConnectionHandler connectionHandler; - - /** - * Default constructor - * @param sch the switchConnectionHandler that decides - * what to do with incomming message / channel - */ - public OFDatagramPacketHandler(SwitchConnectionHandler sch) { - this.connectionHandler = sch; - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOGGER.warn("Unexpected exception from downstream.", cause); - LOGGER.warn("Closing connection."); - ctx.close(); - } - - @Override - protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, - List out) throws Exception { - LOGGER.debug("OFDatagramPacketFramer"); - MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); - if (consumer == null) { - ConnectionFacade connectionFacade = - adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); - connectionHandler.onSwitchConnected(connectionFacade); - connectionFacade.checkListeners(); - UdpConnectionMap.addConnection(msg.sender(), connectionFacade); - } - ByteBuf bb = msg.content(); - int readableBytes = bb.readableBytes(); - if (readableBytes < LENGTH_OF_HEADER) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); - LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); - } - return; - } - - int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); - LOGGER.debug("length of actual message: {}", length); - - if (readableBytes < length) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for msg: " + - readableBytes + " < " + length); - LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); - } - return; - } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); - - - byte version = bb.readByte(); - if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { - LOGGER.debug("detected version: " + version); - ByteBuf messageBuffer = bb.slice(); - out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); - messageBuffer.retain(); - } else { - LOGGER.warn("detected version: " + version + " - currently not supported"); - } - bb.skipBytes(bb.readableBytes()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageDecoder; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketHandler extends MessageToMessageDecoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); + + /** Length of OpenFlow 1.3 header */ + public static final byte LENGTH_OF_HEADER = 8; + private static final byte LENGTH_INDEX_IN_HEADER = 2; + private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl(); + private SwitchConnectionHandler connectionHandler; + + /** + * Default constructor + * @param sch the switchConnectionHandler that decides + * what to do with incomming message / channel + */ + public OFDatagramPacketHandler(SwitchConnectionHandler sch) { + this.connectionHandler = sch; + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + LOGGER.warn("Unexpected exception from downstream.", cause); + LOGGER.warn("Closing connection."); + ctx.close(); + } + + @Override + protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, + List out) throws Exception { + LOGGER.debug("OFDatagramPacketFramer"); + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); + if (consumer == null) { + ConnectionFacade connectionFacade = + adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); + connectionHandler.onSwitchConnected(connectionFacade); + connectionFacade.checkListeners(); + UdpConnectionMap.addConnection(msg.sender(), connectionFacade); + } + ByteBuf bb = msg.content(); + int readableBytes = bb.readableBytes(); + if (readableBytes < LENGTH_OF_HEADER) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); + LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); + LOGGER.debug("length of actual message: {}", length); + + if (readableBytes < length) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for msg: " + + readableBytes + " < " + length); + LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + + + byte version = bb.readByte(); + if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { + LOGGER.debug("detected version: " + version); + ByteBuf messageBuffer = bb.slice(); + out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); + messageBuffer.retain(); + } else { + LOGGER.warn("detected version: " + version + " - currently not supported"); + } + bb.skipBytes(bb.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java index 9a9bf3c4..26dad6d1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -/** - * Stores names of handlers used in pipeline. - * - * @author michal.polkorab - */ -public enum PipelineHandlers { - - /** - * Detects switch idle state - */ - IDLE_HANDLER, - /** - * 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 byte messages into POJOs - */ - OF_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol byte messages - */ - OF_ENCODER, - /** - * Delegates translated POJOs into MessageConsumer - */ - DELEGATING_INBOUND_HANDLER, - /** - * Performs efficient flushing - */ - CHANNEL_OUTBOUNF_QUEUE, - /** - * Decodes incoming messages into message frames - * and filters them based on version supported - */ - OF_DATAGRAMPACKET_HANDLER, - /** - * Transforms OpenFlow Protocol datagram messages into POJOs - */ - OF_DATAGRAMPACKET_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol datagrams - */ - OF_DATAGRAMPACKET_ENCODER +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +/** + * Stores names of handlers used in pipeline. + * + * @author michal.polkorab + */ +public enum PipelineHandlers { + + /** + * Detects switch idle state + */ + IDLE_HANDLER, + /** + * 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 byte messages into POJOs + */ + OF_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol byte messages + */ + OF_ENCODER, + /** + * Delegates translated POJOs into MessageConsumer + */ + DELEGATING_INBOUND_HANDLER, + /** + * Performs efficient flushing + */ + CHANNEL_OUTBOUNF_QUEUE, + /** + * Decodes incoming messages into message frames + * and filters them based on version supported + */ + OF_DATAGRAMPACKET_HANDLER, + /** + * Transforms OpenFlow Protocol datagram messages into POJOs + */ + OF_DATAGRAMPACKET_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol datagrams + */ + OF_DATAGRAMPACKET_ENCODER } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java index 2c486f00..2c1d7899 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; - -/** - * @param Channel type - * @author michal.polkorab - */ -public abstract class ProtocolChannelInitializer - extends ChannelInitializer { - - private SwitchConnectionHandler switchConnectionHandler; - private long switchIdleTimeout; - private SerializationFactory serializationFactory; - private DeserializationFactory deserializationFactory; - private TlsConfiguration tlsConfiguration; - - /** - * @param switchConnectionHandler the switchConnectionHandler to set - */ - public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { - this.switchConnectionHandler = switchConnectionHandler; - } - - /** - * @param switchIdleTimeout the switchIdleTimeout to set - */ - public void setSwitchIdleTimeout(final long switchIdleTimeout) { - this.switchIdleTimeout = switchIdleTimeout; - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(final SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } - - /** - * @param tlsConfiguration - */ - public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { - this.tlsConfiguration = tlsConfiguration; - } - - /** - * @return switch connection handler - */ - public SwitchConnectionHandler getSwitchConnectionHandler() { - return switchConnectionHandler; - } - - /** - * @return switch idle timeout - */ - public long getSwitchIdleTimeout() { - return switchIdleTimeout; - } - - /** - * @return serialization factory - */ - public SerializationFactory getSerializationFactory() { - return serializationFactory; - } - - /** - * @return deserialization factory - */ - public DeserializationFactory getDeserializationFactory() { - return deserializationFactory; - } - - /** - * @return TLS configuration - */ - public TlsConfiguration getTlsConfiguration() { - return tlsConfiguration; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @param Channel type + * @author michal.polkorab + */ +public abstract class ProtocolChannelInitializer + extends ChannelInitializer { + + private SwitchConnectionHandler switchConnectionHandler; + private long switchIdleTimeout; + private SerializationFactory serializationFactory; + private DeserializationFactory deserializationFactory; + private TlsConfiguration tlsConfiguration; + + /** + * @param switchConnectionHandler the switchConnectionHandler to set + */ + public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } + + /** + * @param switchIdleTimeout the switchIdleTimeout to set + */ + public void setSwitchIdleTimeout(final long switchIdleTimeout) { + this.switchIdleTimeout = switchIdleTimeout; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(final SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param tlsConfiguration + */ + public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { + this.tlsConfiguration = tlsConfiguration; + } + + /** + * @return switch connection handler + */ + public SwitchConnectionHandler getSwitchConnectionHandler() { + return switchConnectionHandler; + } + + /** + * @return switch idle timeout + */ + public long getSwitchIdleTimeout() { + return switchIdleTimeout; + } + + /** + * @return serialization factory + */ + public SerializationFactory getSerializationFactory() { + return serializationFactory; + } + + /** + * @return deserialization factory + */ + public DeserializationFactory getDeserializationFactory() { + return deserializationFactory; + } + + /** + * @return TLS configuration + */ + public TlsConfiguration getTlsConfiguration() { + return tlsConfiguration; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java index 51871440..9ff7d65b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.channel.socket.nio.NioDatagramChannel; - -/** - * @author michal.polkorab - * - */ -public class UdpChannelInitializer extends ProtocolChannelInitializer { - - @Override - protected void initChannel(NioDatagramChannel ch) throws Exception { - ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), - new OFDatagramPacketHandler(getSwitchConnectionHandler())); - OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); - ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); - ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), - ofDatagramPacketDecoder); - OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); - ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); - ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); -// connectionFacade.fireConnectionReadyNotification(); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.channel.socket.nio.NioDatagramChannel; + +/** + * @author michal.polkorab + * + */ +public class UdpChannelInitializer extends ProtocolChannelInitializer { + + @Override + protected void initChannel(NioDatagramChannel ch) throws Exception { + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), + new OFDatagramPacketHandler(getSwitchConnectionHandler())); + OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); + ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), + ofDatagramPacketDecoder); + OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); + ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); +// connectionFacade.fireConnectionReadyNotification(); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index d33f3a0b..d23d5ada 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import java.net.InetSocketAddress; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; - -/** - * As UDP communication is handled only by one channel, it is needed - * to store MessageConsumers, so that we know which consumer handles which channel - - * @author michal.polkorab - */ -public final class UdpConnectionMap { - - private static Map connectionMap = new ConcurrentHashMap<>(); - - private UdpConnectionMap() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * @param address sender's address - * @return corresponding MessageConsumer - */ - public static MessageConsumer getMessageConsumer(InetSocketAddress address) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - return connectionMap.get(address); - } - - /** - * @param address sender's address - * @param consumer MessageConsumer to be added / paired with specified address - */ - public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - connectionMap.put(address, consumer); - } - - /** - * @param address sender's address - */ - public static void removeConnection(InetSocketAddress address) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - connectionMap.remove(address); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import java.net.InetSocketAddress; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; + +/** + * As UDP communication is handled only by one channel, it is needed + * to store MessageConsumers, so that we know which consumer handles which channel + + * @author michal.polkorab + */ +public final class UdpConnectionMap { + + private static Map connectionMap = new ConcurrentHashMap<>(); + + private UdpConnectionMap() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * @param address sender's address + * @return corresponding MessageConsumer + */ + public static MessageConsumer getMessageConsumer(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + return connectionMap.get(address); + } + + /** + * @param address sender's address + * @param consumer MessageConsumer to be added / paired with specified address + */ + public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + connectionMap.put(address, consumer); + } + + /** + * @param address sender's address + */ + public static void removeConnection(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + connectionMap.remove(address); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 2ebeec76..0d7bb4e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioDatagramChannel; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetAddress; -import java.net.InetSocketAddress; - -import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - -/** - * Class implementing server over UDP for handling incoming connections. - * - * @author michal.polkorab - */ -public final class UdpHandler implements ServerFacade { - - private static final Logger LOGGER = LoggerFactory - .getLogger(UdpHandler.class); - private int port; - private EventLoopGroup group; - private final InetAddress startupAddress; - private final SettableFuture isOnlineFuture; - private UdpChannelInitializer channelInitializer; - private ThreadConfiguration threadConfig; - - /** - * Constructor of UdpHandler that listens on selected port. - * - * @param port listening port of UdpHandler server - */ - public UdpHandler(final int port) { - this(null, port); - } - - /** - * Constructor of UdpHandler that listens on selected address and port. - * @param address listening address of UdpHandler server - * @param port listening port of UdpHandler server - */ - public UdpHandler(final InetAddress address, final int port) { - this.port = port; - this.startupAddress = address; - isOnlineFuture = SettableFuture.create(); - } - - @Override - public void run() { - if (threadConfig != null) { - group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); - } else { - group = new NioEventLoopGroup(); - } - final ChannelFuture f; - try { - Bootstrap b = new Bootstrap(); - b.group(group) - .channel(NioDatagramChannel.class) - .option(ChannelOption.SO_BROADCAST, false) - .handler(channelInitializer); - - if (startupAddress != null) { - f = b.bind(startupAddress.getHostAddress(), port).sync(); - } else { - f = b.bind(port).sync(); - } - } catch (InterruptedException e) { - LOGGER.error("Interrupted while binding port {}", port, e); - return; - } - - try { - InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); - String address = isa.getHostString(); - - // Update port, as it may have been specified as 0 - this.port = isa.getPort(); - - LOGGER.debug("Address from udpHandler: {}", address); - isOnlineFuture.set(true); - LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); - f.channel().closeFuture().sync(); - } catch (InterruptedException e) { - LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); - } finally { - shutdown(); - } - } - - @Override - public ListenableFuture shutdown() { - final SettableFuture result = SettableFuture.create(); - group.shutdownGracefully().addListener(new GenericFutureListener>() { - - @Override - public void operationComplete( - final io.netty.util.concurrent.Future downResult) throws Exception { - result.set(downResult.isSuccess()); - if (downResult.cause() != null) { - result.setException(downResult.cause()); - } - } - - }); - return result; - } - - @Override - public ListenableFuture getIsOnlineFuture() { - return isOnlineFuture; - } - - /** - * @return the port - */ - public int getPort() { - return port; - } - - /** - * @param channelInitializer - */ - public void setChannelInitializer(UdpChannelInitializer channelInitializer) { - this.channelInitializer = channelInitializer; - } - - @Override - public void setThreadConfig(ThreadConfiguration threadConfig) { - this.threadConfig = threadConfig; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetAddress; +import java.net.InetSocketAddress; + +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +/** + * Class implementing server over UDP for handling incoming connections. + * + * @author michal.polkorab + */ +public final class UdpHandler implements ServerFacade { + + private static final Logger LOGGER = LoggerFactory + .getLogger(UdpHandler.class); + private int port; + private EventLoopGroup group; + private final InetAddress startupAddress; + private final SettableFuture isOnlineFuture; + private UdpChannelInitializer channelInitializer; + private ThreadConfiguration threadConfig; + + /** + * Constructor of UdpHandler that listens on selected port. + * + * @param port listening port of UdpHandler server + */ + public UdpHandler(final int port) { + this(null, port); + } + + /** + * Constructor of UdpHandler that listens on selected address and port. + * @param address listening address of UdpHandler server + * @param port listening port of UdpHandler server + */ + public UdpHandler(final InetAddress address, final int port) { + this.port = port; + this.startupAddress = address; + isOnlineFuture = SettableFuture.create(); + } + + @Override + public void run() { + if (threadConfig != null) { + group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); + } else { + group = new NioEventLoopGroup(); + } + final ChannelFuture f; + try { + Bootstrap b = new Bootstrap(); + b.group(group) + .channel(NioDatagramChannel.class) + .option(ChannelOption.SO_BROADCAST, false) + .handler(channelInitializer); + + if (startupAddress != null) { + f = b.bind(startupAddress.getHostAddress(), port).sync(); + } else { + f = b.bind(port).sync(); + } + } catch (InterruptedException e) { + LOGGER.error("Interrupted while binding port {}", port, e); + return; + } + + try { + InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); + String address = isa.getHostString(); + + // Update port, as it may have been specified as 0 + this.port = isa.getPort(); + + LOGGER.debug("Address from udpHandler: {}", address); + isOnlineFuture.set(true); + LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); + f.channel().closeFuture().sync(); + } catch (InterruptedException e) { + LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); + } finally { + shutdown(); + } + } + + @Override + public ListenableFuture shutdown() { + final SettableFuture result = SettableFuture.create(); + group.shutdownGracefully().addListener(new GenericFutureListener>() { + + @Override + public void operationComplete( + final io.netty.util.concurrent.Future downResult) throws Exception { + result.set(downResult.isSuccess()); + if (downResult.cause() != null) { + result.setException(downResult.cause()); + } + } + + }); + return result; + } + + @Override + public ListenableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + /** + * @return the port + */ + public int getPort() { + return port; + } + + /** + * @param channelInitializer + */ + public void setChannelInitializer(UdpChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; + } + + @Override + public void setThreadConfig(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java index 087bcb6b..e9a8bf98 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import io.netty.buffer.ByteBuf; - -import java.net.InetSocketAddress; - -/** - * Wraps received messages (includes version) and sender address - - * @author michal.polkorab - */ -public class VersionMessageUdpWrapper extends VersionMessageWrapper { - - private InetSocketAddress address; - - /** - * @param version Openflow wire version - * @param messageBuffer ByteBuf containing binary message - * @param address sender address - */ - public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { - super(version, messageBuffer); - this.address = address; - } - - /** - * @return sender address - */ - public InetSocketAddress getAddress() { - return address; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.buffer.ByteBuf; + +import java.net.InetSocketAddress; + +/** + * Wraps received messages (includes version) and sender address + + * @author michal.polkorab + */ +public class VersionMessageUdpWrapper extends VersionMessageWrapper { + + private InetSocketAddress address; + + /** + * @param version Openflow wire version + * @param messageBuffer ByteBuf containing binary message + * @param address sender address + */ + public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { + super(version, messageBuffer); + this.address = address; + } + + /** + * @return sender address + */ + public InetSocketAddress getAddress() { + return address; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java index 51ab4b82..ec415b38 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; - -/** - * Wraps outgoing message and includes listener attached to this message. This object - * is sent to OFEncoder. When OFEncoder fails to serialize the message, - * listener is filled with exception. The exception is then delegated to upper ODL layers. - * @author michal.polkorab - */ -public class MessageListenerWrapper { - - private OfHeader msg; - private GenericFutureListener> listener; - - /** - * @param msg outgoing message - * @param listener listener attached to channel.write(msg) Future - */ - public MessageListenerWrapper(Object msg, GenericFutureListener> listener) { - this.msg = (OfHeader) msg; - this.listener = listener; - } - - /** - * @return outgoing message (downstream) - */ - public OfHeader getMsg() { - return msg; - } - - - /** - * @return listener listening on message sending success / failure - */ - public GenericFutureListener> getListener() { - return listener; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * @author michal.polkorab + */ +public class MessageListenerWrapper { + + private OfHeader msg; + private GenericFutureListener> listener; + + /** + * @param msg outgoing message + * @param listener listener attached to channel.write(msg) Future + */ + public MessageListenerWrapper(Object msg, GenericFutureListener> listener) { + this.msg = (OfHeader) msg; + this.listener = listener; + } + + /** + * @return outgoing message (downstream) + */ + public OfHeader getMsg() { + return msg; + } + + + /** + * @return listener listening on message sending success / failure + */ + public GenericFutureListener> getListener() { + return listener; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java index 56d004bd..a946cf54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetSocketAddress; - -/** - * Wraps outgoing message and includes listener attached to this message. This object - * is sent to OFEncoder. When OFEncoder fails to serialize the message, - * listener is filled with exception. The exception is then delegated to upper ODL layers. - * This object is used for UDP communication - it also carries recipient address - - * @author michal.polkorab - */ -public class UdpMessageListenerWrapper extends MessageListenerWrapper { - - private InetSocketAddress address; - - /** - * @param msg message to be sent - * @param listener listener attached to channel.write(msg) Future - * @param address recipient's address - */ - public UdpMessageListenerWrapper(Object msg, GenericFutureListener> listener, - InetSocketAddress address) { - super(msg, listener); - this.address = address; - } - - /** - * @return recipient address - */ - public InetSocketAddress getAddress() { - return address; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * This object is used for UDP communication - it also carries recipient address + + * @author michal.polkorab + */ +public class UdpMessageListenerWrapper extends MessageListenerWrapper { + + private InetSocketAddress address; + + /** + * @param msg message to be sent + * @param listener listener attached to channel.write(msg) Future + * @param address recipient's address + */ + public UdpMessageListenerWrapper(Object msg, GenericFutureListener> listener, + InetSocketAddress address) { + super(msg, listener); + this.address = address; + } + + /** + * @return recipient address + */ + public InetSocketAddress getAddress() { + return address; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index cbec7394..e946f30f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwTosActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper; - -/** - * @author michal.polkorab - * - */ -public final class ActionDeserializerInitializer { - - private ActionDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers action deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerDeserializers(DeserializerRegistry registry) { - // register OF v1.0 action deserializers - ActionDeserializerRegistryHelper helper = - new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, new OF10OutputActionDeserializer()); - helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); - helper.registerDeserializer(2, new OF10SetVlanPcpActionDeserializer()); - helper.registerDeserializer(3, new OF10StripVlanActionDeserializer()); - helper.registerDeserializer(4, new OF10SetDlSrcActionDeserializer()); - helper.registerDeserializer(5, new OF10SetDlDstActionDeserializer()); - helper.registerDeserializer(6, new OF10SetNwSrcActionDeserializer()); - helper.registerDeserializer(7, new OF10SetNwDstActionDeserializer()); - helper.registerDeserializer(8, new OF10SetNwTosActionDeserializer()); - helper.registerDeserializer(9, new OF10SetTpSrcActionDeserializer()); - helper.registerDeserializer(10, new OF10SetTpDstActionDeserializer()); - helper.registerDeserializer(11, new OF10EnqueueActionDeserializer()); - // register OF v1.3 action deserializers - helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, new OF13OutputActionDeserializer()); - helper.registerDeserializer(11, new OF13CopyTtlOutActionDeserializer()); - helper.registerDeserializer(12, new OF13CopyTtlInActionDeserializer()); - helper.registerDeserializer(15, new OF13SetMplsTtlActionDeserializer()); - helper.registerDeserializer(16, new OF13DecMplsTtlActionDeserializer()); - helper.registerDeserializer(17, new OF13PushVlanActionDeserializer()); - helper.registerDeserializer(18, new OF13PopVlanActionDeserializer()); - helper.registerDeserializer(19, new OF13PushMplsActionDeserializer()); - helper.registerDeserializer(20, new OF13PopMplsActionDeserializer()); - helper.registerDeserializer(21, new OF13SetQueueActionDeserializer()); - helper.registerDeserializer(22, new OF13GroupActionDeserializer()); - helper.registerDeserializer(23, new OF13SetNwTtlActionDeserializer()); - helper.registerDeserializer(24, new OF13DecNwTtlActionDeserializer()); - helper.registerDeserializer(25, new OF13SetFieldActionDeserializer()); - helper.registerDeserializer(26, new OF13PushPbbActionDeserializer()); - helper.registerDeserializer(27, new OF13PopPbbActionDeserializer()); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwTosActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper; + +/** + * @author michal.polkorab + * + */ +public final class ActionDeserializerInitializer { + + private ActionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers action deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerDeserializers(DeserializerRegistry registry) { + // register OF v1.0 action deserializers + ActionDeserializerRegistryHelper helper = + new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(0, new OF10OutputActionDeserializer()); + helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); + helper.registerDeserializer(2, new OF10SetVlanPcpActionDeserializer()); + helper.registerDeserializer(3, new OF10StripVlanActionDeserializer()); + helper.registerDeserializer(4, new OF10SetDlSrcActionDeserializer()); + helper.registerDeserializer(5, new OF10SetDlDstActionDeserializer()); + helper.registerDeserializer(6, new OF10SetNwSrcActionDeserializer()); + helper.registerDeserializer(7, new OF10SetNwDstActionDeserializer()); + helper.registerDeserializer(8, new OF10SetNwTosActionDeserializer()); + helper.registerDeserializer(9, new OF10SetTpSrcActionDeserializer()); + helper.registerDeserializer(10, new OF10SetTpDstActionDeserializer()); + helper.registerDeserializer(11, new OF10EnqueueActionDeserializer()); + // register OF v1.3 action deserializers + helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(0, new OF13OutputActionDeserializer()); + helper.registerDeserializer(11, new OF13CopyTtlOutActionDeserializer()); + helper.registerDeserializer(12, new OF13CopyTtlInActionDeserializer()); + helper.registerDeserializer(15, new OF13SetMplsTtlActionDeserializer()); + helper.registerDeserializer(16, new OF13DecMplsTtlActionDeserializer()); + helper.registerDeserializer(17, new OF13PushVlanActionDeserializer()); + helper.registerDeserializer(18, new OF13PopVlanActionDeserializer()); + helper.registerDeserializer(19, new OF13PushMplsActionDeserializer()); + helper.registerDeserializer(20, new OF13PopMplsActionDeserializer()); + helper.registerDeserializer(21, new OF13SetQueueActionDeserializer()); + helper.registerDeserializer(22, new OF13GroupActionDeserializer()); + helper.registerDeserializer(23, new OF13SetNwTtlActionDeserializer()); + helper.registerDeserializer(24, new OF13DecNwTtlActionDeserializer()); + helper.registerDeserializer(25, new OF13SetFieldActionDeserializer()); + helper.registerDeserializer(26, new OF13PushPbbActionDeserializer()); + helper.registerDeserializer(27, new OF13PopPbbActionDeserializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java index 9fcfd4d6..40cae2c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper; - -/** - * @author michal.polkorab - * - */ -public final class InstructionDeserializerInitializer { - - private InstructionDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers instruction deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerDeserializers(DeserializerRegistry registry) { - // register OF v1.3 instruction deserializers - InstructionDeserializerRegistryHelper helper = - new InstructionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(1, new GoToTableInstructionDeserializer()); - helper.registerDeserializer(2, new WriteMetadataInstructionDeserializer()); - helper.registerDeserializer(3, new WriteActionsInstructionDeserializer()); - helper.registerDeserializer(4, new ApplyActionsInstructionDeserializer()); - helper.registerDeserializer(5, new ClearActionsInstructionDeserializer()); - helper.registerDeserializer(6, new MeterInstructionDeserializer()); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper; + +/** + * @author michal.polkorab + * + */ +public final class InstructionDeserializerInitializer { + + private InstructionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers instruction deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerDeserializers(DeserializerRegistry registry) { + // register OF v1.3 instruction deserializers + InstructionDeserializerRegistryHelper helper = + new InstructionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(1, new GoToTableInstructionDeserializer()); + helper.registerDeserializer(2, new WriteMetadataInstructionDeserializer()); + helper.registerDeserializer(3, new WriteActionsInstructionDeserializer()); + helper.registerDeserializer(4, new ApplyActionsInstructionDeserializer()); + helper.registerDeserializer(5, new ClearActionsInstructionDeserializer()); + helper.registerDeserializer(6, new MeterInstructionDeserializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index 28f87a4c..46273e89 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -1,127 +1,127 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public final class MatchEntryDeserializerInitializer { - - private MatchEntryDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers match entry deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerMatchEntryDeserializers(DeserializerRegistry registry) { - // register OpenflowBasicClass match entry deserializers - MatchEntryDeserializerRegistryHelper helper = - new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, - OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry); - helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer()); - helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer()); - helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer()); - helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer()); - helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer()); - helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer()); - helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer()); - helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer()); - helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer()); - helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer()); - helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer()); - helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer()); - helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer()); - helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer()); - helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer()); - helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer()); - helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer()); - helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer()); - helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer()); - helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer()); - helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer()); - helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer()); - helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer()); - helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer()); - helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer()); - helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer()); - helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer()); - helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer()); - helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer()); - helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer()); - helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer()); - helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer()); - helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer()); - helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer()); - helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); - helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); - helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); - - // Register NXM1Class match entry deserializers - MatchEntryDeserializerRegistryHelper nxm1helper = - new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, - OxmMatchConstants.NXM_1_CLASS, registry); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer()); - - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public final class MatchEntryDeserializerInitializer { + + private MatchEntryDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers match entry deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerMatchEntryDeserializers(DeserializerRegistry registry) { + // register OpenflowBasicClass match entry deserializers + MatchEntryDeserializerRegistryHelper helper = + new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry); + helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer()); + helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer()); + helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer()); + helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer()); + helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer()); + helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer()); + helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer()); + helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer()); + helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer()); + helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer()); + helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer()); + helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer()); + helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer()); + helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer()); + helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer()); + helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer()); + helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer()); + helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer()); + helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer()); + helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer()); + helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer()); + helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer()); + helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer()); + helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer()); + helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer()); + helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer()); + helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer()); + helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer()); + helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer()); + helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer()); + helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer()); + helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer()); + helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer()); + helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer()); + helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); + helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); + helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); + + // Register NXM1Class match entry deserializers + MatchEntryDeserializerRegistryHelper nxm1helper = + new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.NXM_1_CLASS, registry); + nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer()); + nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer()); + nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer()); + + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 525f5297..c82408bf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public final class MessageDeserializerInitializer { - - private MessageDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers message deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerMessageDeserializers(DeserializerRegistry registry) { - // register OF v1.0 message deserializers - SimpleDeserializerRegistryHelper helper = - new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); - helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); - helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); - helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); - // register Of v1.3 message deserializers - helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); - helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); - helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); - helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); - helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); - helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public final class MessageDeserializerInitializer { + + private MessageDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers message deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerMessageDeserializers(DeserializerRegistry registry) { + // register OF v1.0 message deserializers + SimpleDeserializerRegistryHelper helper = + new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); + helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); + helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); + helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + // register Of v1.3 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); + helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); + helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); + helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index fa110c09..b0b4d047 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import java.util.Map; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public final class TypeToClassMapInitializer { - - private TypeToClassMapInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Initializes type to class map - * @param messageClassMap - */ - public static void initializeTypeToClassMap(Map> messageClassMap) { - // init OF v1.0 mapping - TypeToClassInitHelper helper = - new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); - helper.registerTypeToClass((short) 0, HelloMessage.class); - helper.registerTypeToClass((short) 1, ErrorMessage.class); - helper.registerTypeToClass((short) 2, EchoRequestMessage.class); - helper.registerTypeToClass((short) 3, EchoOutput.class); - helper.registerTypeToClass((short) 4, ExperimenterMessage.class); - helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); - helper.registerTypeToClass((short) 8, GetConfigOutput.class); - helper.registerTypeToClass((short) 10, PacketInMessage.class); - helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); - helper.registerTypeToClass((short) 12, PortStatusMessage.class); - helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); - helper.registerTypeToClass((short) 19, BarrierOutput.class); - helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); - // init OF v1.0 mapping - helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); - helper.registerTypeToClass((short) 0, HelloMessage.class); - helper.registerTypeToClass((short) 1, ErrorMessage.class); - helper.registerTypeToClass((short) 2, EchoRequestMessage.class); - helper.registerTypeToClass((short) 3, EchoOutput.class); - helper.registerTypeToClass((short) 4, ExperimenterMessage.class); - helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); - helper.registerTypeToClass((short) 8, GetConfigOutput.class); - helper.registerTypeToClass((short) 10, PacketInMessage.class); - helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); - helper.registerTypeToClass((short) 12, PortStatusMessage.class); - helper.registerTypeToClass((short) 19, MultipartReplyMessage.class); - helper.registerTypeToClass((short) 21, BarrierOutput.class); - helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class); - helper.registerTypeToClass((short) 25, RoleRequestOutput.class); - helper.registerTypeToClass((short) 27, GetAsyncOutput.class); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import java.util.Map; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public final class TypeToClassMapInitializer { + + private TypeToClassMapInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Initializes type to class map + * @param messageClassMap + */ + public static void initializeTypeToClassMap(Map> messageClassMap) { + // init OF v1.0 mapping + TypeToClassInitHelper helper = + new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 1, ErrorMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 4, ExperimenterMessage.class); + helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 10, PacketInMessage.class); + helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); + helper.registerTypeToClass((short) 12, PortStatusMessage.class); + helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); + helper.registerTypeToClass((short) 19, BarrierOutput.class); + helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); + // init OF v1.0 mapping + helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 1, ErrorMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 4, ExperimenterMessage.class); + helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 10, PacketInMessage.class); + helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); + helper.registerTypeToClass((short) 12, PortStatusMessage.class); + helper.registerTypeToClass((short) 19, MultipartReplyMessage.class); + helper.registerTypeToClass((short) 21, BarrierOutput.class); + helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class); + helper.registerTypeToClass((short) 25, RoleRequestOutput.class); + helper.registerTypeToClass((short) 27, GetAsyncOutput.class); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java index 4ff7c307..9dbd5790 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Action deserializeHeader(ByteBuf input) { - ActionBuilder actionBuilder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - actionBuilder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return actionBuilder.build(); - } - - protected abstract Class getType(); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Action deserializeHeader(ByteBuf input) { + ActionBuilder actionBuilder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + actionBuilder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return actionBuilder.build(); + } + + protected abstract Class getType(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java index 0fae6a61..cddf6f2d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthertypeAction.class, etherType.build()); - input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + EthertypeActionBuilder etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(input.readUnsignedShort())); + builder.addAugmentation(EthertypeAction.class, etherType.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java index b295ec3c..664dfbe3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java index 058d0870..97c10e5c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yangtools.yang.binding.Augmentation; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(final ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(IpAddressAction.class, - createNwAddressAugmentationAndPad(input)); - return builder.build(); - } - - private static Augmentation createNwAddressAugmentationAndPad(final ByteBuf input) { - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - return ipBuilder.build(); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yangtools.yang.binding.Augmentation; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(final ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.addAugmentation(IpAddressAction.class, + createNwAddressAugmentationAndPad(input)); + return builder.build(); + } + + private static Augmentation createNwAddressAugmentationAndPad(final ByteBuf input) { + IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + return ipBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java index 14a1c843..cdbc69e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input)); - return builder.build(); - } - - private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) { - DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); - input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - return dlBuilder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input)); + return builder.build(); + } + + private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) { + DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + return dlBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java index c284fc5e..9c7476d5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); - return builder.build(); - } - - protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) { - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); + return builder.build(); + } + + protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) { + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index 41c989eb..9316971e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Enqueue.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); + QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); + queueBuilder.setQueueId(input.readUnsignedInt()); + builder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Enqueue.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index cfbcbe27..64707081 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Output.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(input.readUnsignedShort()); + builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Output.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java index 2cdc5d0d..95762dc1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer { - - @Override - protected Class getType() { - return SetDlDst.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer { + + @Override + protected Class getType() { + return SetDlDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java index 34b16b4b..9d3d9c80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer { - - @Override - protected Class getType() { - return SetDlSrc.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer { + + @Override + protected Class getType() { + return SetDlSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java index c41021d8..97e1c6bb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer { - - @Override - protected Class getType() { - return SetNwDst.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer { + + @Override + protected Class getType() { + return SetNwDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java index 31550133..55d1e76d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer { - - @Override - protected Class getType() { - return SetNwSrc.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer { + + @Override + protected Class getType() { + return SetNwSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index 70589117..925ecfec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); - tosBuilder.setNwTos(input.readUnsignedByte()); - builder.addAugmentation(NwTosAction.class, tosBuilder.build()); - input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); - return builder.build(); - } - - @Override - protected Class getType() { - return SetNwTos.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + tosBuilder.setNwTos(input.readUnsignedByte()); + builder.addAugmentation(NwTosAction.class, tosBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); + return builder.build(); + } + + @Override + protected Class getType() { + return SetNwTos.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java index 96a41ffd..0bb20dbf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - protected Class getType() { - return SetTpDst.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + protected Class getType() { + return SetTpDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java index 31271a4a..3fce85bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - protected Class getType() { - return SetTpSrc.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + protected Class getType() { + return SetTpSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index cb888a4c..ac511552 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder(); - vlanBuilder.setVlanPcp(input.readUnsignedByte()); - input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); - builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetVlanPcp.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder(); + vlanBuilder.setVlanPcp(input.readUnsignedByte()); + input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); + builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetVlanPcp.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index 4fb33a73..623341a9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(input.readUnsignedShort()); - input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); - builder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetVlanVid.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); + vlanBuilder.setVlanVid(input.readUnsignedShort()); + input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); + builder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetVlanVid.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java index bb5c4a48..dea7afa5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return StripVlan.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return StripVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java index e56c5818..a869084d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return CopyTtlIn.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return CopyTtlIn.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java index 731a82ad..b066b215 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return CopyTtlOut.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return CopyTtlOut.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java index bab50a98..6467e1e6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return DecMplsTtl.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return DecMplsTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java index 8f112ff2..f920f577 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return DecNwTtl.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return DecNwTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index ab186fa8..dbf147d2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13GroupActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(input.readUnsignedInt()); - builder.addAugmentation(GroupIdAction.class, group.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Group.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13GroupActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + GroupIdActionBuilder group = new GroupIdActionBuilder(); + group.setGroupId(input.readUnsignedInt()); + builder.addAugmentation(GroupIdAction.class, group.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Group.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index e47980f4..9e9d54f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public class OF13OutputActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); - input.skipBytes(ActionConstants.OUTPUT_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return Output.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public class OF13OutputActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(input.readUnsignedInt())); + builder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(input.readUnsignedShort()); + builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + input.skipBytes(ActionConstants.OUTPUT_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return Output.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java index 408e5b30..218bedbb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PopMpls.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PopMpls.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java index 99ec0380..7ba8e324 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return PopPbb.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return PopPbb.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java index e31a9bfe..69543ede 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return PopVlan.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return PopVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java index 121e1e96..38ac1821 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushMpls.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushMpls.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java index 6a44f04f..40cf71dc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushPbb.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushPbb.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java index eb0b059d..8b9bbdda 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushVlan.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 0182e8c7..190c3b80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer - implements DeserializerRegistryInjector { - - private DeserializerRegistry registry; - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - int startIndex = input.readerIndex(); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - int oxmClass = input.getUnsignedShort(input.readerIndex()); - // get oxm_field & hasMask byte and extract the field value - int oxmField = input.getUnsignedByte(input.readerIndex() - + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - oxmClass, oxmField); - if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { - long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES - + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); - } - OFDeserializer matchDeserializer = registry.getDeserializer(key); - List entry = new ArrayList<>(); - entry.add(matchDeserializer.deserialize(input)); - matchEntries.setMatchEntries(entry); - builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; - if (paddingRemainder != 0) { - input.skipBytes(EncodeConstants.PADDING - paddingRemainder); - } - return builder.build(); - } - - @Override - protected Class getType() { - return SetField.class; - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.registry = deserializerRegistry; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer + implements DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + int startIndex = input.readerIndex(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + int oxmClass = input.getUnsignedShort(input.readerIndex()); + // get oxm_field & hasMask byte and extract the field value + int oxmField = input.getUnsignedByte(input.readerIndex() + + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + } + OFDeserializer matchDeserializer = registry.getDeserializer(key); + List entry = new ArrayList<>(); + entry.add(matchDeserializer.deserialize(input)); + matchEntries.setMatchEntries(entry); + builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; + if (paddingRemainder != 0) { + input.skipBytes(EncodeConstants.PADDING - paddingRemainder); + } + return builder.build(); + } + + @Override + protected Class getType() { + return SetField.class; + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index 15877640..0a22ae73 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl(input.readUnsignedByte()); - builder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); - input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return SetMplsTtl.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); + mplsTtl.setMplsTtl(input.readUnsignedByte()); + builder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return SetMplsTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index a9a08aa6..f247c3a7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl(input.readUnsignedByte()); - builder.addAugmentation(NwTtlAction.class, nwTtl.build()); - input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return SetNwTtl.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl(input.readUnsignedByte()); + builder.addAugmentation(NwTtlAction.class, nwTtl.build()); + input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return SetNwTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index 0e68c0b0..1df22b1b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueId.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetQueue.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + QueueIdActionBuilder queueId = new QueueIdActionBuilder(); + queueId.setQueueId(input.readUnsignedInt()); + builder.addAugmentation(QueueIdAction.class, queueId.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetQueue.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java index 97db922a..269976ff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterMessageFactory implements OFDeserializer, - DeserializerRegistryInjector { - - /** Experimenter ID index after version, message type and length were read */ - private static final byte EXPERIMENTER_ID_INDEX = 4; - private DeserializerRegistry deserializerRegistry; - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF13_VERSION_ID, expId)); - return deserializer.deserialize(message); - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.deserializerRegistry = deserializerRegistry; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + /** Experimenter ID index after version, message type and length were read */ + private static final byte EXPERIMENTER_ID_INDEX = 4; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java index 7c421538..be6d0004 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class VendorMessageFactory implements OFDeserializer, - DeserializerRegistryInjector { - - private static final byte VENDOR_ID_INDEX = 8; - private DeserializerRegistry deserializerRegistry; - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, expId)); - return deserializer.deserialize(message); - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.deserializerRegistry = deserializerRegistry; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class VendorMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + private static final byte VENDOR_ID_INDEX = 8; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 3f4126ba..78d868a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer - implements DeserializerRegistryInjector { - - private DeserializerRegistry registry; - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - int instructionLength = input.readUnsignedShort(); - input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); - int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH; - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeList( - EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - return builder.build(); - } - - protected abstract Class getType(); - - protected DeserializerRegistry getRegistry() { - return registry; - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.registry = deserializerRegistry; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer + implements DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + int instructionLength = input.readUnsignedShort(); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH; + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList( + EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + return builder.build(); + } + + protected abstract Class getType(); + + protected DeserializerRegistry getRegistry() { + return registry; + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java index f15409f3..38a66452 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractInstructionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Instruction deserializeHeader(ByteBuf rawMessage) { - InstructionBuilder builder = processHeader(rawMessage); - rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return builder.build(); - } - - protected InstructionBuilder processHeader(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - int type = input.readUnsignedShort(); - switch (type) { - case 1: - builder.setType(GotoTable.class); - break; - case 2: - builder.setType(WriteMetadata.class); - break; - case 3: - builder.setType(WriteActions.class); - break; - case 4: - builder.setType(ApplyActions.class); - break; - case 5: - builder.setType(ClearActions.class); - break; - case 6: - builder.setType(Meter.class); - break; - default: - throw new IllegalStateException("Unknown instruction type received, type: " + type); - } - return builder; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Instruction deserializeHeader(ByteBuf rawMessage) { + InstructionBuilder builder = processHeader(rawMessage); + rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return builder.build(); + } + + protected InstructionBuilder processHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + int type = input.readUnsignedShort(); + switch (type) { + case 1: + builder.setType(GotoTable.class); + break; + case 2: + builder.setType(WriteMetadata.class); + break; + case 3: + builder.setType(WriteActions.class); + break; + case 4: + builder.setType(ApplyActions.class); + break; + case 5: + builder.setType(ClearActions.class); + break; + case 6: + builder.setType(Meter.class); + break; + default: + throw new IllegalStateException("Unknown instruction type received, type: " + type); + } + return builder; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java index 7b6319c9..c55aacea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { - - @Override - protected Class getType() { - return ApplyActions.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { + + @Override + protected Class getType() { + return ApplyActions.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index cc2ef5e8..9fd7cec9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = super.processHeader(input); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = - new ActionsInstructionBuilder(); - List actions = new ArrayList<>(); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - return builder.build(); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = super.processHeader(input); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ActionsInstructionBuilder actionsBuilder = + new ActionsInstructionBuilder(); + List actions = new ArrayList<>(); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + return builder.build(); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index 21af10fb..317e69c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(GotoTable.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); - tableBuilder.setTableId(input.readUnsignedByte()); - builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); - input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(GotoTable.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); + tableBuilder.setTableId(input.readUnsignedByte()); + builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); + input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java index ebd626d3..1021987f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class MeterInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Meter.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); - meterBuilder.setMeterId(input.readUnsignedInt()); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); - return builder.build(); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class MeterInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(Meter.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); + meterBuilder.setMeterId(input.readUnsignedInt()); + builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java index 311e5ea7..c60532b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { - - @Override - protected Class getType() { - return WriteActions.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { + + @Override + protected Class getType() { + return WriteActions.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index 419dc974..9412413b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(WriteMetadata.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder(); - byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadata); - metadataBuilder.setMetadata(metadata); - byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataMask); - metadataBuilder.setMetadataMask(metadataMask); - builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(WriteMetadata.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); + MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder(); + byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadata); + metadataBuilder.setMetadata(metadata); + byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataMask); + metadataBuilder.setMetadataMask(metadataMask); + builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java index 9d7329fb..510b5da3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv4AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv4AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder(); - ipv4AddressBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(final ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv4AddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv4AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { + Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder(); + ipv4AddressBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java index d6c4d2b1..ca5ac7ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, - EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder(); - ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); - builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(final ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6AddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, + EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { + Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder(); + ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java index 32383b2f..aa4b5884 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMacAddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH); - } - return builder.build(); - } - - private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); - builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMacAddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH); + } + return builder.build(); + } + + private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder(); + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index d512b59e..1d737b09 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { - - @Override - public MatchEntries deserializeHeader(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - return builder.build(); - } - - /** - * @return oxm_field class - */ - protected abstract Class getOxmField(); - - /** - * @return oxm_class class - */ - protected abstract Class getOxmClass(); - - /** - * Prepares match entry header - sets oxm_class, oxm_field, hasMask - * + sets the buffer.readerIndex() to the end of match entry - * - where augmentation starts - * @param oxmClass oxm class type - * @param oxmField oxm field type - * @param input input bytebuf - * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation - */ - protected MatchEntriesBuilder processHeader(Class oxmClass, - Class oxmField, ByteBuf input) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(oxmClass); - // skip oxm_class (provided) - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setOxmMatchField(oxmField); - boolean hasMask = (input.readUnsignedByte() & 1) != 0; - builder.setHasMask(hasMask); - // skip match entry length - not needed - input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - return builder; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { + + @Override + public MatchEntries deserializeHeader(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + return builder.build(); + } + + /** + * @return oxm_field class + */ + protected abstract Class getOxmField(); + + /** + * @return oxm_class class + */ + protected abstract Class getOxmClass(); + + /** + * Prepares match entry header - sets oxm_class, oxm_field, hasMask + * + sets the buffer.readerIndex() to the end of match entry + * - where augmentation starts + * @param oxmClass oxm class type + * @param oxmField oxm field type + * @param input input bytebuf + * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation + */ + protected MatchEntriesBuilder processHeader(Class oxmClass, + Class oxmField, ByteBuf input) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(oxmClass); + // skip oxm_class (provided) + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setOxmMatchField(oxmField); + boolean hasMask = (input.readUnsignedByte() & 1) != 0; + builder.setHasMask(hasMask); + // skip match entry length - not needed + input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + return builder; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java index d38b82ed..4de031f7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMetadataAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES); - } - return builder.build(); - } - - private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder(); - byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataBytes); - metadata.setMetadata(metadataBytes); - builder.addAugmentation(MetadataMatchEntry.class, metadata.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMetadataAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES); + } + return builder.build(); + } + + private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder(); + byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataBytes); + metadata.setMetadata(metadataBytes); + builder.addAugmentation(MetadataMatchEntry.class, metadata.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java index 43203006..0b3530db 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPortAugmentation(builder, input); - return builder.build(); - } - - private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(input.readUnsignedShort())); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addPortAugmentation(builder, input); + return builder.build(); + } + + private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(input.readUnsignedShort())); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java index bd88623c..35895a9b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); - port.setPortNumber(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortNumberMatchEntry.class, port.build()); - return builder.build(); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); + port.setPortNumber(new PortNumber(input.readUnsignedInt())); + builder.addAugmentation(PortNumberMatchEntry.class, port.build()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java index 41fde206..7a287238 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagDeserializer.class); - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addTcpFlagAugmentation(input, builder); - return builder.build(); - } - - private static void addTcpFlagAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - TcpFlagMatchEntryBuilder tcpFlagMatchEntryBuilder = new TcpFlagMatchEntryBuilder(); - tcpFlagMatchEntryBuilder.setTcpFlag(input.readUnsignedShort()); - } - - @Override - protected Class getOxmField() { - return TcpFlag.class; - } - - @Override - protected Class getOxmClass() { - return Nxm1Class.class; - } +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author brent.salisbury + * + */ +public class NxmTcpFlagDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagDeserializer.class); + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addTcpFlagAugmentation(input, builder); + return builder.build(); + } + + private static void addTcpFlagAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + TcpFlagMatchEntryBuilder tcpFlagMatchEntryBuilder = new TcpFlagMatchEntryBuilder(); + tcpFlagMatchEntryBuilder.setTcpFlag(input.readUnsignedShort()); + } + + @Override + protected Class getOxmField() { + return TcpFlag.class; + } + + @Override + protected Class getOxmClass() { + return Nxm1Class.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java index c2532ab0..2d438398 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addArpOpAugmentation(input, builder); - return builder.build(); - } - - private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); - opcodeBuilder.setOpCode(input.readUnsignedShort()); - builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return ArpOp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpOpAugmentation(input, builder); + return builder.build(); + } + + private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); + opcodeBuilder.setOpCode(input.readUnsignedShort()); + builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return ArpOp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java index 09744aca..b26b9e3a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpSha.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpSha.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java index 8d99b44d..cb83cb24 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpSpa.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpSpa.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java index cba0642e..69ce30a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpTha.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpTha.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java index dddb3ef4..dd7b27c9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpTpa.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpTpa.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java index 257fde06..9e1e6e20 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return EthDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return EthDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java index ebcd01f8..3302a650 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return EthSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return EthSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java index ce4ea0c4..94d08706 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addEthTypeAugmentation(input, builder); - return builder.build(); - } - - private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); - ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return EthType.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addEthTypeAugmentation(input, builder); + return builder.build(); + } + + private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); + ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort())); + builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return EthType.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java index c0df85bd..8ac68433 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4CodeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv4CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv4Code.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4CodeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv4CodeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte()); + builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv4Code.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java index 05f81a3f..4134bb1c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4TypeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv4TypeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv4Type.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4TypeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv4TypeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte()); + builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv4Type.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java index 930a4b31..7cc38f19 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv6CodeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv6CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv6Code.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv6CodeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv6CodeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte()); + builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv6Code.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java index 11f9336c..de155fcb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); - return builder.build(); - } - - @Override - protected Class getOxmField() { - return Icmpv6Type.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte()); + builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + return builder.build(); + } + + @Override + protected Class getOxmField() { + return Icmpv6Type.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java index d9685796..54b826f8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer { - - @Override - protected Class getOxmField() { - return InPhyPort.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer { + + @Override + protected Class getOxmField() { + return InPhyPort.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java index 4f9af4fa..342d2a33 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer { - - @Override - protected Class getOxmField() { - return InPort.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer { + + @Override + protected Class getOxmField() { + return InPort.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index eb92d143..e4880ba9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpDscpAugmentation(input, builder); - return builder.build(); - } - - private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpDscp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpDscpAugmentation(input, builder); + return builder.build(); + } + + private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); + builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpDscp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java index 7a534756..150c6dc6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpEcnAugmentation(input, builder); - return builder.build(); - } - - private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn(input.readUnsignedByte()); - builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpEcn.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpEcnAugmentation(input, builder); + return builder.build(); + } + + private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); + ecnBuilder.setEcn(input.readUnsignedByte()); + builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpEcn.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java index f99ecba8..9e67af39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpProtoAugmentation(input, builder); - return builder.build(); - } - - private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); - protoNumberBuilder.setProtocolNumber(input.readUnsignedByte()); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpProto.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpProtoAugmentation(input, builder); + return builder.build(); + } + + private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); + protoNumberBuilder.setProtocolNumber(input.readUnsignedByte()); + builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpProto.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java index ae63c9d6..9939fed9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv4Dst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv4Dst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java index b03ca001..a84b2fa3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv4Src.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv4Src.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java index f4170d8c..11b5cc3a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6Dst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6Dst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index 26f7f839..7267333c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6ExtHdrAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6ExtHdrAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - int bitmap = input.readUnsignedShort(); - final Boolean nonext = ((bitmap) & (1<<0)) != 0; - final Boolean esp = ((bitmap) & (1<<1)) != 0; - final Boolean auth = ((bitmap) & (1<<2)) != 0; - final Boolean dest = ((bitmap) & (1<<3)) != 0; - final Boolean frag = ((bitmap) & (1<<4)) != 0; - final Boolean router = ((bitmap) & (1<<5)) != 0; - final Boolean hop = ((bitmap) & (1<<6)) != 0; - final Boolean unrep = ((bitmap) & (1<<7)) != 0; - final Boolean unseq = ((bitmap) & (1<<8)) != 0; - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Ipv6Exthdr.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6ExtHdrAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6ExtHdrAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + int bitmap = input.readUnsignedShort(); + final Boolean nonext = ((bitmap) & (1<<0)) != 0; + final Boolean esp = ((bitmap) & (1<<1)) != 0; + final Boolean auth = ((bitmap) & (1<<2)) != 0; + final Boolean dest = ((bitmap) & (1<<3)) != 0; + final Boolean frag = ((bitmap) & (1<<4)) != 0; + final Boolean router = ((bitmap) & (1<<5)) != 0; + final Boolean hop = ((bitmap) & (1<<6)) != 0; + final Boolean unrep = ((bitmap) & (1<<7)) != 0; + final Boolean unseq = ((bitmap) & (1<<8)) != 0; + pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); + builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Ipv6Exthdr.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index bcb7643e..15c8aa07 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6FlabelAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6FlabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); - builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Ipv6Flabel.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6FlabelAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6FlabelAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); + ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); + builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Ipv6Flabel.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java index 9e9c5ab4..3ca7b686 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdSll.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdSll.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java index 01c7dc8c..5b2543c1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdTarget.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdTarget.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java index 9b7f4b80..fabc8d45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdTll.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdTll.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java index bb7942a0..59152b45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6Src.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6Src.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java index 728d42fa..ff8b7ff0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public final class OxmMaskDeserializer { - - private OxmMaskDeserializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Appends mask to match entry (match entry builder) - * @param builder builder which the mask will append to - * @param input input ByteBuf - * @param matchEntryLength mask length - */ - public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input, - int matchEntryLength) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - byte[] mask = new byte[matchEntryLength]; - input.readBytes(mask); - maskBuilder.setMask(mask); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public final class OxmMaskDeserializer { + + private OxmMaskDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Appends mask to match entry (match entry builder) + * @param builder builder which the mask will append to + * @param input input ByteBuf + * @param matchEntryLength mask length + */ + public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input, + int matchEntryLength) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + byte[] mask = new byte[matchEntryLength]; + input.readBytes(mask); + maskBuilder.setMask(mask); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java index b5dcf47c..ae34635b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer { - - @Override - protected Class getOxmField() { - return Metadata.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer { + + @Override + protected Class getOxmField() { + return Metadata.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java index 3fbd2ea0..65ebac39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsBosDeserializer(input, builder); - return builder.build(); - } - - - private static void addMplsBosDeserializer(ByteBuf input, - MatchEntriesBuilder builder) { - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - if (input.readUnsignedByte() != 0) { - bosBuilder.setBos(true); - } else { - bosBuilder.setBos(false); - } - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsBos.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsBosDeserializer(input, builder); + return builder.build(); + } + + + private static void addMplsBosDeserializer(ByteBuf input, + MatchEntriesBuilder builder) { + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + if (input.readUnsignedByte() != 0) { + bosBuilder.setBos(true); + } else { + bosBuilder.setBos(false); + } + builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsBos.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java index fdc657a8..d7c4fe4f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer -implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsLabelAugmentation(input, builder); - return builder.build(); - } - - private static void addMplsLabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); - mplsLabelBuilder.setMplsLabel(input.readUnsignedInt()); - builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsLabel.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer +implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsLabelAugmentation(input, builder); + return builder.build(); + } + + private static void addMplsLabelAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); + mplsLabelBuilder.setMplsLabel(input.readUnsignedInt()); + builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsLabel.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java index f7a06339..10cb8d28 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsTcAugmentation(input, builder); - return builder.build(); - } - - private static void addMplsTcAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc(input.readUnsignedByte()); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsTc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsTcAugmentation(input, builder); + return builder.build(); + } + + private static void addMplsTcAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc(input.readUnsignedByte()); + builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsTc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java index f6378763..e400ba36 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPbbIsidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES); - } - return builder.build(); - } - - private static void addPbbIsidAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - Integer isid = input.readUnsignedMedium(); - isidBuilder.setIsid(isid.longValue()); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - } - - @Override - protected Class getOxmField() { - return PbbIsid.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addPbbIsidAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES); + } + return builder.build(); + } + + private static void addPbbIsidAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + Integer isid = input.readUnsignedMedium(); + isidBuilder.setIsid(isid.longValue()); + builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + } + + @Override + protected Class getOxmField() { + return PbbIsid.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index e608ea63..0985b752 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return SctpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return SctpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index 03e9bf91..087e86b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return SctpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return SctpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index 3a2f1612..1ab75029 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return TcpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return TcpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index 5d213431..e1509dc7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return TcpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return TcpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java index bba63ca5..84a407af 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer { - - @Override - protected Class getOxmField() { - return TunnelId.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer { + + @Override + protected Class getOxmField() { + return TunnelId.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index 201266e1..01d37beb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return UdpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return UdpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index 626d9d40..d4da0752 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return UdpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return UdpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java index 0600d296..332fa751 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanPcpAugmentation(input, builder); - return builder.build(); - } - - private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); - vlanPcpBuilder.setVlanPcp(input.readUnsignedByte()); - builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); - } - - @Override - protected Class getOxmField() { - return VlanPcp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanPcpAugmentation(input, builder); + return builder.build(); + } + + private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); + vlanPcpBuilder.setVlanPcp(input.readUnsignedByte()); + builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); + } + + @Override + protected Class getOxmField() { + return VlanPcp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index 7ba99e2b..0508dbab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanVidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - } - return builder.build(); - } - - private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); - int vidEntryValue = input.readUnsignedShort(); - vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit - vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit - builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); - } - - @Override - protected Class getOxmField() { - return VlanVid.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanVidAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + } + return builder.build(); + } + + private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); + int vidEntryValue = input.readUnsignedShort(); + vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit + vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit + builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); + } + + @Override + protected Class getOxmField() { + return VlanVid.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index d3e74b5c..51539db5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -1,119 +1,119 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10EnqueueActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10OutputActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwTosActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanPcpActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanVidActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10StripVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlInActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlOutActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecMplsTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecNwTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13GroupActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13OutputActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopMplsActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopPbbActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushMplsActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushPbbActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetFieldActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; - -/** - * Initializes serializer registry with action serializers - * @author michal.polkorab - */ -public final class ActionsInitializer { - - private ActionsInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers action serializers into provided registry - * @param serializerRegistry registry to be initialized with action serializers - */ - public static void registerActionSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.0 action serializers - ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( - EncodeConstants.OF10_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); - helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); - helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); - helper.registerSerializer(StripVlan.class, new OF10StripVlanActionSerializer()); - helper.registerSerializer(SetDlSrc.class, new OF10SetDlSrcActionSerializer()); - helper.registerSerializer(SetDlDst.class, new OF10SetDlDstActionSerializer()); - helper.registerSerializer(SetNwSrc.class, new OF10SetNwSrcActionSerializer()); - helper.registerSerializer(SetNwDst.class, new OF10SetNwDstActionSerializer()); - helper.registerSerializer(SetNwTos.class, new OF10SetNwTosActionSerializer()); - helper.registerSerializer(SetTpSrc.class, new OF10SetTpSrcActionSerializer()); - helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); - helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); - // register OF v1.0 action serializers - helper = new ActionSerializerRegistryHelper( - EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); - helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); - helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); - helper.registerSerializer(SetMplsTtl.class, new OF13SetMplsTtlActionSerializer()); - helper.registerSerializer(DecMplsTtl.class, new OF13DecMplsTtlActionSerializer()); - helper.registerSerializer(PushVlan.class, new OF13PushVlanActionSerializer()); - helper.registerSerializer(PopVlan.class, new OF13PopVlanActionSerializer()); - helper.registerSerializer(PushMpls.class, new OF13PushMplsActionSerializer()); - helper.registerSerializer(PopMpls.class, new OF13PopMplsActionSerializer()); - helper.registerSerializer(SetQueue.class, new OF13SetQueueActionSerializer()); - helper.registerSerializer(Group.class, new OF13GroupActionSerializer()); - helper.registerSerializer(SetNwTtl.class, new OF13SetNwTtlActionSerializer()); - helper.registerSerializer(DecNwTtl.class, new OF13DecNwTtlActionSerializer()); - helper.registerSerializer(SetField.class, new OF13SetFieldActionSerializer()); - helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); - helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10EnqueueActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10OutputActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwTosActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanPcpActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanVidActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10StripVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlInActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlOutActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecMplsTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecNwTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13GroupActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13OutputActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopMplsActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopPbbActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushMplsActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushPbbActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetFieldActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; + +/** + * Initializes serializer registry with action serializers + * @author michal.polkorab + */ +public final class ActionsInitializer { + + private ActionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers action serializers into provided registry + * @param serializerRegistry registry to be initialized with action serializers + */ + public static void registerActionSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.0 action serializers + ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF10_VERSION_ID, serializerRegistry); + helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); + helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); + helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); + helper.registerSerializer(StripVlan.class, new OF10StripVlanActionSerializer()); + helper.registerSerializer(SetDlSrc.class, new OF10SetDlSrcActionSerializer()); + helper.registerSerializer(SetDlDst.class, new OF10SetDlDstActionSerializer()); + helper.registerSerializer(SetNwSrc.class, new OF10SetNwSrcActionSerializer()); + helper.registerSerializer(SetNwDst.class, new OF10SetNwDstActionSerializer()); + helper.registerSerializer(SetNwTos.class, new OF10SetNwTosActionSerializer()); + helper.registerSerializer(SetTpSrc.class, new OF10SetTpSrcActionSerializer()); + helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); + helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); + // register OF v1.0 action serializers + helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); + helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); + helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); + helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); + helper.registerSerializer(SetMplsTtl.class, new OF13SetMplsTtlActionSerializer()); + helper.registerSerializer(DecMplsTtl.class, new OF13DecMplsTtlActionSerializer()); + helper.registerSerializer(PushVlan.class, new OF13PushVlanActionSerializer()); + helper.registerSerializer(PopVlan.class, new OF13PopVlanActionSerializer()); + helper.registerSerializer(PushMpls.class, new OF13PushMplsActionSerializer()); + helper.registerSerializer(PopMpls.class, new OF13PopMplsActionSerializer()); + helper.registerSerializer(SetQueue.class, new OF13SetQueueActionSerializer()); + helper.registerSerializer(Group.class, new OF13GroupActionSerializer()); + helper.registerSerializer(SetNwTtl.class, new OF13SetNwTtlActionSerializer()); + helper.registerSerializer(DecNwTtl.class, new OF13DecNwTtlActionSerializer()); + helper.registerSerializer(SetField.class, new OF13SetFieldActionSerializer()); + helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); + helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java index f60898ed..46674e52 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ApplyActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.MeterInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; - -/** - * @author michal.polkorab - * - */ -public final class InstructionsInitializer { - - private InstructionsInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers instruction serializers into provided registry - * @param serializerRegistry registry to be initialized with instruction serializers - */ - public static void registerInstructionSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.3 instruction serializers - InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( - EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); - helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); - helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); - helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer()); - helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer()); - helper.registerSerializer(Meter.class, new MeterInstructionSerializer()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ApplyActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.MeterInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; + +/** + * @author michal.polkorab + * + */ +public final class InstructionsInitializer { + + private InstructionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers instruction serializers into provided registry + * @param serializerRegistry registry to be initialized with instruction serializers + */ + public static void registerInstructionSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.3 instruction serializers + InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); + helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); + helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); + helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); + helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer()); + helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer()); + helper.registerSerializer(Meter.class, new MeterInstructionSerializer()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 4889fcbd..884617fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -1,172 +1,172 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpThaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpTpaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthTypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4CodeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4TypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6CodeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6TypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPhyPortSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPortSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpDscpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpEcnSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpProtoSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6ExtHdrSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6FlabelSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdSllSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTargetSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTllSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMetadataSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsBosSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsLabelSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmPbbIsidSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTunnelIdSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; - -/** - * Initializes serializer registry with match entry serializers - * @author michal.polkorab - */ -public final class MatchEntriesInitializer { - - private MatchEntriesInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers match entry serializers into provided registry - * @param serializerRegistry registry to be initialized with match entry serializers - */ - public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { - // register OF v1.3 OpenflowBasicClass match entry serializers - Class oxmClass = OpenflowBasicClass.class; - MatchEntrySerializerRegistryHelper helper = - new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - oxmClass, serializerRegistry); - helper.registerSerializer(InPort.class, new OxmInPortSerializer()); - helper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); - helper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); - helper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); - helper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); - helper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); - helper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); - helper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); - helper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); - helper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); - helper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); - helper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); - helper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); - helper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); - helper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); - helper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); - helper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); - helper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); - helper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); - helper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); - helper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); - helper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); - helper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); - helper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); - helper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); - helper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); - helper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); - helper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); - helper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); - helper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); - helper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); - helper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); - helper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); - helper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); - helper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); - helper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); - helper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); - helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); - helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); - helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); - - // Register OpenFlow NXM1Class match entry serializer - Class nxm1Class = Nxm1Class.class; - MatchEntrySerializerRegistryHelper nxm1RegistryHelper = - new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - nxm1Class, serializerRegistry); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); - nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpThaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpTpaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthTypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4CodeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4TypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6CodeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6TypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPhyPortSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPortSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpDscpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpEcnSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpProtoSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6ExtHdrSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6FlabelSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdSllSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTargetSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTllSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMetadataSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsBosSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsLabelSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmPbbIsidSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTunnelIdSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; + +/** + * Initializes serializer registry with match entry serializers + * @author michal.polkorab + */ +public final class MatchEntriesInitializer { + + private MatchEntriesInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers match entry serializers into provided registry + * @param serializerRegistry registry to be initialized with match entry serializers + */ + public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { + // register OF v1.3 OpenflowBasicClass match entry serializers + Class oxmClass = OpenflowBasicClass.class; + MatchEntrySerializerRegistryHelper helper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + oxmClass, serializerRegistry); + helper.registerSerializer(InPort.class, new OxmInPortSerializer()); + helper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); + helper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); + helper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); + helper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); + helper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); + helper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); + helper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); + helper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); + helper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); + helper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); + helper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); + helper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); + helper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); + helper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); + helper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); + helper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); + helper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); + helper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); + helper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); + helper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); + helper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); + helper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); + helper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); + helper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); + helper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); + helper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); + helper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); + helper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); + helper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); + helper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); + helper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); + helper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); + helper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); + helper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); + helper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); + helper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); + helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); + helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); + helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); + + // Register OpenFlow NXM1Class match entry serializer + Class nxm1Class = Nxm1Class.class; + MatchEntrySerializerRegistryHelper nxm1RegistryHelper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + nxm1Class, serializerRegistry); + nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); + nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); + nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 70db90be..c3610c13 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -1,113 +1,113 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; - -/** - * @author michal.polkorab - * - */ -public final class MessageFactoryInitializer { - - private MessageFactoryInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers message serializers into provided registry - * @param serializerRegistry registry to be initialized with message serializers - */ - public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.0 message serializers - short version = EncodeConstants.OF10_VERSION_ID; - CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); - registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); - registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); - registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); - registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); - registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); - registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); - registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); - registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory()); - registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory()); - registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory()); - registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory()); - registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory()); - registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); - // register OF v1.3 message serializers - version = EncodeConstants.OF13_VERSION_ID; - registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); - registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); - registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); - registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); - registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); - registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory()); - registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory()); - registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); - registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); - registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); - registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory()); - registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory()); - registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory()); - registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory()); - registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory()); - registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory()); - registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory()); - registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); - registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory()); - registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; + +/** + * @author michal.polkorab + * + */ +public final class MessageFactoryInitializer { + + private MessageFactoryInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers message serializers into provided registry + * @param serializerRegistry registry to be initialized with message serializers + */ + public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.0 message serializers + short version = EncodeConstants.OF10_VERSION_ID; + CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); + registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); + registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); + registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); + registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory()); + registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory()); + registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory()); + registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory()); + registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory()); + registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); + // register OF v1.3 message serializers + version = EncodeConstants.OF13_VERSION_ID; + registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); + registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); + registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); + registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory()); + registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory()); + registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); + registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory()); + registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory()); + registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory()); + registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory()); + registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory()); + registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory()); + registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory()); + registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); + registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory()); + registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java index 8babf572..0ab44159 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionSerializer implements OFSerializer, - HeaderSerializer{ - - @Override - public void serialize(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(getLength()); - } - - @Override - public void serializeHeader(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); - } - - /** - * @return numeric representation of action type - */ - protected abstract int getType(); - - /** - * @return action length - */ - protected abstract int getLength(); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionSerializer implements OFSerializer, + HeaderSerializer{ + + @Override + public void serialize(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(getLength()); + } + + @Override + public void serializeHeader(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); + } + + /** + * @return numeric representation of action type + */ + protected abstract int getType(); + + /** + * @return action length + */ + protected abstract int getLength(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java index 9c4117a4..33858e33 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); - outBuffer.writeShort(ethertype.getEthertype().getValue()); - outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractEthertypeActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); + outBuffer.writeShort(ethertype.getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java index aa82f49e..335d19e4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractHeaderActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java index d7bf73aa..fd7c4b5f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(final Action action, final ByteBuf outBuffer) { - super.serialize(action, outBuffer); - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(action.getAugmentation(IpAddressAction.class).getIpAddress().getValue()); - for (String group : addressGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractIpAddressActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(final Action action, final ByteBuf outBuffer) { + super.serialize(action, outBuffer); + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(action.getAugmentation(IpAddressAction.class).getIpAddress().getValue()); + for (String group : addressGroups) { + outBuffer.writeByte(Short.parseShort(group)); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java index f8c47352..770d1892 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action - .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractMacAddressActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action + .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java index a02df47e..194669a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractPortActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index dfc79768..59ec7d61 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10EnqueueActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.ENQUEUE_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10EnqueueActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); + QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); + outBuffer.writeInt(queueId.getQueueId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.ENQUEUE_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java index b6231cd4..38e45587 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10OutputActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); - } - - @Override - protected int getType() { - return ActionConstants.OUTPUT_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10OutputActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); + outBuffer.writeShort(maxlength.getMaxLength()); + } + + @Override + protected int getType() { + return ActionConstants.OUTPUT_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java index 2e013323..b174b0f9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlDstActionSerializer extends OF10AbstractMacAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_DL_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlDstActionSerializer extends OF10AbstractMacAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_DL_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java index 623767c7..e9f002da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlSrcActionSerializer extends OF10AbstractMacAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_DL_SRC_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlSrcActionSerializer extends OF10AbstractMacAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_DL_SRC_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java index 35a85611..2494ced3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwDstActionSerializer extends OF10AbstractIpAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_NW_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwDstActionSerializer extends OF10AbstractIpAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_NW_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java index c4f259a7..b708b163 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwSrcActionSerializer extends OF10AbstractIpAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_NW_SRC_CODE; - } - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwSrcActionSerializer extends OF10AbstractIpAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_NW_SRC_CODE; + } + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index 0d668248..c75335c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_NW_TOS_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_NW_TOS_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java index 3000de79..929db82b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpDstActionSerializer extends OF10AbstractPortActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_TP_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpDstActionSerializer extends OF10AbstractPortActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_TP_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java index 0280145c..7c062eae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpSrcActionSerializer extends OF10AbstractPortActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_TP_SRC_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpSrcActionSerializer extends OF10AbstractPortActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_TP_SRC_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 29fdafe0..973d026c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_VLAN_PCP_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_VLAN_PCP_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index e788f8d4..afe000c9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_VLAN_VID_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_VLAN_VID_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java index 4bfc2c16..d3903233 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF10StripVlanActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.STRIP_VLAN_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF10StripVlanActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.STRIP_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java index 69d70e59..59020cd1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlInActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.COPY_TTL_IN_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlInActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.COPY_TTL_IN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java index a5b3059a..da6cf058 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlOutActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.COPY_TTL_OUT_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlOutActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.COPY_TTL_OUT_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java index 9f6f741b..6d7be277 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13DecMplsTtlActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.DEC_MPLS_TTL_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13DecMplsTtlActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.DEC_MPLS_TTL_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java index f1610b76..d1f44369 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF13DecNwTtlActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.DEC_NW_TTL_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF13DecNwTtlActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.DEC_NW_TTL_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java index a36fa554..6e87760a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13GroupActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - GroupIdAction groupId = action.getAugmentation(GroupIdAction.class); - outBuffer.writeInt(groupId.getGroupId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.GROUP_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13GroupActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + GroupIdAction groupId = action.getAugmentation(GroupIdAction.class); + outBuffer.writeInt(groupId.getGroupId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.GROUP_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 2ac79f7d..0b6c5658 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13OutputActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeInt(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); - outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.OUTPUT_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13OutputActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeInt(port.getPort().getValue().intValue()); + MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); + outBuffer.writeShort(maxlength.getMaxLength()); + outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.OUTPUT_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java index bd3fac22..2857b4a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopMplsActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_MPLS_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopMplsActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_MPLS_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java index ecf8bea5..8187f226 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopPbbActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_PBB_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopPbbActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_PBB_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java index 960e5fb3..39ffd1a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopVlanActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_VLAN_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopVlanActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java index ca992eec..8c2bd764 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PushMplsActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_MPLS_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PushMplsActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_MPLS_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java index 746c2b4e..732a73cf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PushPbbActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_PBB_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PushPbbActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_PBB_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java index 71795ec6..1dedb85b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF13PushVlanActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_VLAN_CODE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF13PushVlanActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 6b56fd09..65eefec9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -1,71 +1,71 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OF13SetFieldActionSerializer implements OFSerializer, - HeaderSerializer, SerializerRegistryInjector { - - private SerializerRegistry registry; - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); - MatchEntries entry = oxmField.getMatchEntries().get(0); - MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); - if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); - } else { - key.setExperimenterId(null); - } - OFSerializer serializer = registry.getSerializer(key); - serializer.serialize(entry, outBuffer); - int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; - if (paddingRemainder != 0) { - outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - - @Override - public void serializeHeader(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); - outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); - } - - @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { - registry = serializerRegistry; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OF13SetFieldActionSerializer implements OFSerializer, + HeaderSerializer, SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); + MatchEntries entry = oxmField.getMatchEntries().get(0); + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); + } else { + key.setExperimenterId(null); + } + OFSerializer serializer = registry.getSerializer(key); + serializer.serialize(entry, outBuffer); + int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; + if (paddingRemainder != 0) { + outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); + } + outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); + } + + @Override + public void serializeHeader(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); + outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); + } + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index 480bc931..aacebf2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { - - - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); - outBuffer.writeByte(mplsTtl.getMplsTtl()); - outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.SET_MPLS_TTL_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { + + + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); + outBuffer.writeByte(mplsTtl.getMplsTtl()); + outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.SET_MPLS_TTL_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index b30cf5d5..70796dc5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); - outBuffer.writeByte(nwTtl.getNwTtl()); - outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.SET_NW_TTL_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); + outBuffer.writeByte(nwTtl.getNwTtl()); + outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.SET_NW_TTL_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java index c11d14fb..4586b926 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetQueueActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.SET_QUEUE_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetQueueActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); + outBuffer.writeInt(queueId.getQueueId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.SET_QUEUE_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 4b381d3b..217fb120 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer - implements SerializerRegistryInjector { - - private static final TypeKeyMaker ACTION_KEY_MAKER = - TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - - private SerializerRegistry registry; - - @Override - public void serialize(final Instruction instruction, final ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(getType()); - if (instruction.getAugmentation(ActionsInstruction.class) != null) { - List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); - int instructionLength = outBuffer.writerIndex() - startIndex; - outBuffer.setShort(lengthIndex, instructionLength); - } else { - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - } - } - - protected SerializerRegistry getRegistry() { - return registry; - } - - @Override - public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { - registry = serializerRegistry; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer + implements SerializerRegistryInjector { + + private static final TypeKeyMaker ACTION_KEY_MAKER = + TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + + private SerializerRegistry registry; + + @Override + public void serialize(final Instruction instruction, final ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(getType()); + if (instruction.getAugmentation(ActionsInstruction.class) != null) { + List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); + int instructionLength = outBuffer.writerIndex() - startIndex; + outBuffer.setShort(lengthIndex, instructionLength); + } else { + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + } + } + + protected SerializerRegistry getRegistry() { + return registry; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java index f672016e..c5d33317 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractInstructionSerializer implements OFSerializer, - HeaderSerializer { - - @Override - public void serializeHeader(Instruction input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH); - } - - /** - * @return numeric representation of action type - */ - protected abstract int getType(); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractInstructionSerializer implements OFSerializer, + HeaderSerializer { + + @Override + public void serializeHeader(Instruction input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH); + } + + /** + * @return numeric representation of action type + */ + protected abstract int getType(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java index f2f4c271..2aaae19b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.APPLY_ACTIONS_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.APPLY_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java index 85e27d23..00162502 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.CLEAR_ACTIONS_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.CLEAR_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 3c65edff..9e18a12f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class GoToTableInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); - outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); - } - - @Override - protected int getType() { - return InstructionConstants.GOTO_TABLE_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class GoToTableInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); + outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); + } + + @Override + protected int getType() { + return InstructionConstants.GOTO_TABLE_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java index c171f50f..5a8f5ab8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class MeterInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeInt(instruction. - getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); - } - - @Override - protected int getType() { - return InstructionConstants.METER_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class MeterInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeInt(instruction. + getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + } + + @Override + protected int getType() { + return InstructionConstants.METER_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java index f4de32c4..10e20504 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.WRITE_ACTIONS_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.WRITE_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 6c16ea39..43d3e27a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); - outBuffer.writeBytes(metadata.getMetadata()); - outBuffer.writeBytes(metadata.getMetadataMask()); - } - - @Override - protected int getType() { - return InstructionConstants.WRITE_METADATA_TYPE; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); + MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); + outBuffer.writeBytes(metadata.getMetadata()); + outBuffer.writeBytes(metadata.getMetadataMask()); + } + + @Override + protected int getType() { + return InstructionConstants.WRITE_METADATA_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index 1d1907af..4ce543e6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for Ipv4 address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - writeIpv4Address(entry, outBuffer); - writeMask(entry, outBuffer, getValueLength()); - } - - private static void writeIpv4Address(final MatchEntries entry, final ByteBuf out) { - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue()); - for (String group : addressGroups) { - out.writeByte(Short.parseShort(group)); - } - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for Ipv4 address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + writeIpv4Address(entry, outBuffer); + writeMask(entry, outBuffer, getValueLength()); + } + + private static void writeIpv4Address(final MatchEntries entry, final ByteBuf out) { + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue()); + for (String group : addressGroups) { + out.writeByte(Short.parseShort(group)); + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index c83f9d90..496505b8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -1,83 +1,83 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -import com.google.common.collect.Lists; - -/** - * Parent for Ipv6 address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue(); - List address; - if (textAddress.equals("::")) { - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - address = Arrays.asList(tmp); - } else { - address = parseIpv6Address(Lists.newArrayList(ByteBufUtils.COLON_SPLITTER.split(textAddress))); - } - for (String group : address) { - outBuffer.writeShort(Integer.parseInt(group, 16)); - } - writeMask(entry, outBuffer, getValueLength()); - } - - private static List parseIpv6Address(final List addressGroups) { - int countEmpty = 0; - for (String group : addressGroups) { - if (group.equals("")) { - countEmpty++; - } - } - List ready = new ArrayList<>(EncodeConstants.GROUPS_IN_IPV6_ADDRESS); - switch (countEmpty) { - case 0: - ready = addressGroups; - break; - case 1: - int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.size() + 1; - for (String group : addressGroups) { - if (group.equals("")) { - for (int j = 0; j < zerosToBePushed; j++) { - ready.add("0"); - } - } else { - ready.add(group); - } - } - break; - case 2: - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - tmp[EncodeConstants.GROUPS_IN_IPV6_ADDRESS - 1] = - addressGroups.get(addressGroups.size() - 1); - ready = Arrays.asList(tmp); - break; - default: - throw new IllegalStateException("Incorrect ipv6 address"); - } - return ready; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +import com.google.common.collect.Lists; + +/** + * Parent for Ipv6 address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue(); + List address; + if (textAddress.equals("::")) { + String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; + Arrays.fill(tmp, "0"); + address = Arrays.asList(tmp); + } else { + address = parseIpv6Address(Lists.newArrayList(ByteBufUtils.COLON_SPLITTER.split(textAddress))); + } + for (String group : address) { + outBuffer.writeShort(Integer.parseInt(group, 16)); + } + writeMask(entry, outBuffer, getValueLength()); + } + + private static List parseIpv6Address(final List addressGroups) { + int countEmpty = 0; + for (String group : addressGroups) { + if (group.equals("")) { + countEmpty++; + } + } + List ready = new ArrayList<>(EncodeConstants.GROUPS_IN_IPV6_ADDRESS); + switch (countEmpty) { + case 0: + ready = addressGroups; + break; + case 1: + int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.size() + 1; + for (String group : addressGroups) { + if (group.equals("")) { + for (int j = 0; j < zerosToBePushed; j++) { + ready.add("0"); + } + } else { + ready.add(group); + } + } + break; + case 2: + String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; + Arrays.fill(tmp, "0"); + tmp[EncodeConstants.GROUPS_IN_IPV6_ADDRESS - 1] = + addressGroups.get(addressGroups.size() - 1); + ready = Arrays.asList(tmp); + break; + default: + throw new IllegalStateException("Incorrect ipv6 address"); + } + return ready; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index 847a0409..51b62df9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for MAC address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(macAddress)); // 48 b + mask [OF 1.3.2 spec] - writeMask(entry, outBuffer, getValueLength()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for MAC address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(macAddress)); // 48 b + mask [OF 1.3.2 spec] + writeMask(entry, outBuffer, getValueLength()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java index 8b84a88c..5c669647 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for all match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMatchEntrySerializer - implements OFSerializer, HeaderSerializer{ - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - serializeHeader(entry, outBuffer); - } - - @Override - public void serializeHeader(MatchEntries entry, ByteBuf outBuffer) { - outBuffer.writeShort(getOxmClassCode()); - writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), - getValueLength()); - } - - protected static void writeMask(MatchEntries entry, ByteBuf out, int length) { - if (entry.isHasMask()) { - byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask(); - if (mask != null && mask.length != length) { - throw new IllegalArgumentException("incorrect length of mask: "+ - mask.length + ", expected: " + length); - } - out.writeBytes(mask); - } - } - - protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { - int fieldAndMask = fieldValue << 1; - int length = lengthArg; - if (hasMask) { - fieldAndMask |= 1; - length *= 2; - } - out.writeByte(fieldAndMask); - out.writeByte(length); - } - - /** - * @return numeric representation of oxm_field - */ - protected abstract int getOxmFieldCode(); - - /** - * @return numeric representation of oxm_class - */ - protected abstract int getOxmClassCode(); - - /** - * @return match entry value length (without mask length) - */ - protected abstract int getValueLength(); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for all match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMatchEntrySerializer + implements OFSerializer, HeaderSerializer{ + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + serializeHeader(entry, outBuffer); + } + + @Override + public void serializeHeader(MatchEntries entry, ByteBuf outBuffer) { + outBuffer.writeShort(getOxmClassCode()); + writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), + getValueLength()); + } + + protected static void writeMask(MatchEntries entry, ByteBuf out, int length) { + if (entry.isHasMask()) { + byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask(); + if (mask != null && mask.length != length) { + throw new IllegalArgumentException("incorrect length of mask: "+ + mask.length + ", expected: " + length); + } + out.writeBytes(mask); + } + } + + protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { + int fieldAndMask = fieldValue << 1; + int length = lengthArg; + if (hasMask) { + fieldAndMask |= 1; + length *= 2; + } + out.writeByte(fieldAndMask); + out.writeByte(length); + } + + /** + * @return numeric representation of oxm_field + */ + protected abstract int getOxmFieldCode(); + + /** + * @return numeric representation of oxm_class + */ + protected abstract int getOxmClassCode(); + + /** + * @return match entry value length (without mask length) + */ + protected abstract int getValueLength(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java index 0218beb8..b3fedcc6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for metadata based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); - writeMask(entry, outBuffer, getValueLength()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for metadata based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + writeMask(entry, outBuffer, getValueLength()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java index ce972033..394d8c40 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(32-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortNumberSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for port(32-bit) based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmPortNumberSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java index b1c4671c..9dd6a55f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(16-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for port(16-bit) based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmPortSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java index d59e16f3..7d963b8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagSerializer extends AbstractOxmMatchEntrySerializer { - - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagSerializer.class); - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(TcpFlagMatchEntry.class).getTcpFlag()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.NXM_NX_TCP_FLAG; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author brent.salisbury + * + */ +public class NxmTcpFlagSerializer extends AbstractOxmMatchEntrySerializer { + + private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagSerializer.class); + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(TcpFlagMatchEntry.class).getTcpFlag()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.NXM_NX_TCP_FLAG; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java index 4520d9c7..1a37f284 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_OP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_OP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java index 8836d0ea..d4e8c3c0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_SHA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SHA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java index bad5995f..505cf052 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_SPA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java index 637ca043..531b21c6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_THA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_THA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java index 25e6417f..ec6ee771 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_TPA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_TPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java index 8ac6b9d6..c6c07bad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java index 74d75304..5a2df0a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_SRC; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_SRC; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java index 70bf999a..6bd7b575 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java index 82722fc5..664b68b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV4_CODE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java index a5f367fb..6ae6dfaa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV4_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java index 303b116e..7e38d36f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV6_CODE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java index feafa962..adc06c22 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV6_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java index 2aba7e8c..7e6d7a86 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmInPhyPortSerializer extends AbstractOxmPortNumberSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IN_PHY_PORT; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmInPhyPortSerializer extends AbstractOxmPortNumberSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PHY_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java index 2c955077..7a3422e0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmInPortSerializer extends AbstractOxmPortNumberSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IN_PORT; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmInPortSerializer extends AbstractOxmPortNumberSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java index dc1ba5ec..d2cb0416 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_DSCP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_DSCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java index 65bea297..3270eeea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_ECN; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_ECN; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java index 7193f504..d24c0f87 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_PROTO; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_PROTO; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java index df717c18..a7d23c94 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV4_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java index 2c92d022..4b8ddbc7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV4_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java index 4d6299ef..cc892b8d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6DstSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6DstSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java index 4852a4fa..fa7ef802 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField(); - int bitmap = ByteBufUtils.fillBitMask(0, - pseudoField.isNonext(), - pseudoField.isEsp(), - pseudoField.isAuth(), - pseudoField.isDest(), - pseudoField.isFrag(), - pseudoField.isRouter(), - pseudoField.isHop(), - pseudoField.isUnrep(), - pseudoField.isUnseq()); - outBuffer.writeShort(bitmap); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_EXTHDR; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField(); + int bitmap = ByteBufUtils.fillBitMask(0, + pseudoField.isNonext(), + pseudoField.isEsp(), + pseudoField.isAuth(), + pseudoField.isDest(), + pseudoField.isFrag(), + pseudoField.isRouter(), + pseudoField.isHop(), + pseudoField.isUnrep(), + pseudoField.isUnseq()); + outBuffer.writeShort(bitmap); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_EXTHDR; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java index 1e049929..bb6c0450 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_FLABEL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_FLABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java index fed6402f..f5952b8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_SLL; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_SLL; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java index 9037ee6f..a8f32b11 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTargetSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_TARGET; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTargetSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TARGET; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java index c0864da9..e215a2f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_TLL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TLL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java index 7057fe30..9aeca979 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6SrcSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6SrcSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java index 6b0e27de..09099c54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataSerializer extends AbstractOxmMetadataSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.METADATA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_LONG_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataSerializer extends AbstractOxmMetadataSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.METADATA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java index 12f2ec63..52e41c93 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_BOS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_BOS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java index c27936a5..85ec956b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_LABEL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_LABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java index 7a80f40e..ff2b6fe4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_TC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_TC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java index ca740dd5..96c24a68 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.PBB_ISID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_3_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.PBB_ISID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_3_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java index 9327b566..4e3e2738 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.SCTP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java index 1d50c383..96629ff1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.SCTP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java index 22b5093a..c7b42281 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstSerializer extends AbstractOxmPortSerializer{ - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TCP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstSerializer extends AbstractOxmPortSerializer{ + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java index e7bcfd6e..0a8a01e7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TCP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java index 033f7f79..035bb7ff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdSerializer extends AbstractOxmMetadataSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TUNNEL_ID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_LONG_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdSerializer extends AbstractOxmMetadataSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TUNNEL_ID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java index 5f110390..bd4e705f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.UDP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java index 2e091b44..5929909a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.UDP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java index ba181fa0..ad7e9643 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.VLAN_PCP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_PCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java index 775b91a8..975cc3d0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class); - int vlanVidValue = vlanVid.getVlanVid(); - if (vlanVid.isCfiBit()) { - short cfi = 1 << 12; // 13-th bit - vlanVidValue = vlanVidValue | cfi; - } - - outBuffer.writeShort(vlanVidValue); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.VLAN_VID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class); + int vlanVidValue = vlanVid.getVlanVid(); + if (vlanVid.isCfiBit()) { + short cfi = 1 << 12; // 13-th bit + vlanVidValue = vlanVidValue | cfi; + } + + outBuffer.writeShort(vlanVidValue); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_VID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java index 490251cc..05812e8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - - -/** - * @author michal.polkorab - * @param type the key maker is based on - */ -public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { - - private short version; - - /** - * @param version openflow wire version - */ - public AbstractCodeKeyMaker(short version) { - this.version = version; - - } - - /** - * @return the version - */ - public short getVersion() { - return version; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + + +/** + * @author michal.polkorab + * @param type the key maker is based on + */ +public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { + + private short version; + + /** + * @param version openflow wire version + */ + public AbstractCodeKeyMaker(short version) { + this.version = version; + + } + + /** + * @return the version + */ + public short getVersion() { + return version; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java index 3a804afc..f2e736fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - - -/** - * @author michal.polkorab - * @param type the key maker is based on - */ -public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { - - private short version; - - /** - * @param version openflow wire version - */ - public AbstractTypeKeyMaker(short version) { - this.version = version; - - } - - /** - * @return the version - */ - public short getVersion() { - return version; - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + + +/** + * @author michal.polkorab + * @param type the key maker is based on + */ +public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { + + private short version; + + /** + * @param version openflow wire version + */ + public AbstractTypeKeyMaker(short version) { + this.version = version; + + } + + /** + * @return the version + */ + public short getVersion() { + return version; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java index cb7b051e..d05b8cd8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java @@ -1,107 +1,107 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -/** - * @author michal.polkorab - * - */ -public final class ActionConstants { - - /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ - public static final byte OUTPUT_CODE = 0; - /** Openflow v1.0 OFPAT_SET_VLAN_VID code */ - public static final byte SET_VLAN_VID_CODE = 1; - /** Openflow v1.0 OFPAT_SET_VLAN_PCP code */ - public static final byte SET_VLAN_PCP_CODE = 2; - /** Openflow v1.0 OFPAT_STRIP_VLAN code */ - public static final byte STRIP_VLAN_CODE = 3; - /** Openflow v1.0 OFPAT_SET_DL_SRC code */ - public static final byte SET_DL_SRC_CODE = 4; - /** Openflow v1.0 OFPAT_SET_DL_DST code */ - public static final byte SET_DL_DST_CODE = 5; - /** Openflow v1.0 OFPAT_SET_NW_SRC code */ - public static final byte SET_NW_SRC_CODE = 6; - /** Openflow v1.0 OFPAT_SET_NW_DST code */ - public static final byte SET_NW_DST_CODE = 7; - /** Openflow v1.0 OFPAT_SET_NW_TOS code */ - public static final byte SET_NW_TOS_CODE = 8; - /** Openflow v1.0 OFPAT_SET_TP_SRC code */ - public static final byte SET_TP_SRC_CODE = 9; - /** Openflow v1.0 OFPAT_SET_TP_DST code */ - public static final byte SET_TP_DST_CODE = 10; - /** Openflow v1.0 OFPAT_ENQUEUE code */ - public static final byte ENQUEUE_CODE = 11; - /** Openflow v1.3 OFPAT_COPY_TTL_OUT code */ - public static final byte COPY_TTL_OUT_CODE = 11; - /** Openflow v1.3 OFPAT_COPY_TTL_IN code */ - public static final byte COPY_TTL_IN_CODE = 12; - /** Openflow v1.3 OFPAT_SET_MPLS_TTL code */ - public static final byte SET_MPLS_TTL_CODE = 15; - /** Openflow v1.3 OFPAT_DEC_MPLS_TTL code */ - public static final byte DEC_MPLS_TTL_CODE = 16; - /** Openflow v1.3 OFPAT_PUSH_VLAN code */ - public static final byte PUSH_VLAN_CODE = 17; - /** Openflow v1.3 OFPAT_POP_VLAN code */ - public static final byte POP_VLAN_CODE = 18; - /** Openflow v1.3 OFPAT_PUSH_MPLS code */ - public static final byte PUSH_MPLS_CODE = 19; - /** Openflow v1.3 OFPAT_POP_MPLS code */ - public static final byte POP_MPLS_CODE = 20; - /** Openflow v1.3 OFPAT_SET_QUEUE code */ - public static final byte SET_QUEUE_CODE = 21; - /** Openflow v1.3 OFPAT_GROUP code */ - public static final byte GROUP_CODE = 22; - /** Openflow v1.3 OFPAT_SET_NW_TTL code */ - public static final byte SET_NW_TTL_CODE = 23; - /** Openflow v1.3 OFPAT_DEC_NW_TTL code */ - public static final byte DEC_NW_TTL_CODE = 24; - /** Openflow v1.3 OFPAT_SET_FIELD code */ - public static final int SET_FIELD_CODE = 25; - /** Openflow v1.3 OFPAT_PUSH_PBB code */ - public static final byte PUSH_PBB_CODE = 26; - /** Openflow v1.3 OFPAT_POP_PBB code */ - public static final byte POP_PBB_CODE = 27; - - /** Padding in OFPAT_OUTPUT (OF v1.3) */ - public static final byte OUTPUT_PADDING = 6; - /** Padding in OFPAT_SET_VLAN_VID (OF v1.3) */ - public static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2; - /** Padding in OFPAT_SET_VLAN_PCP (OF v1.3) */ - public static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3; - /** Padding in OFPAT_SET_NW_TOS (OF v1.3) */ - public static final byte PADDING_IN_SET_NW_TOS_ACTION = 3; - /** Padding in OFPAT_ENQUEUE (OF v1.3) */ - public static final int PADDING_IN_ENQUEUE_ACTION = 6; - /** Padding in OFPAT_SET_MPLS_TTL (OF v1.3) */ - public static final byte SET_MPLS_TTL_PADDING = 3; - /** Padding in OFPAT_SET_NW_TTL (OF v1.3) */ - public static final byte SET_NW_TTL_PADDING = 3; - /** Padding in OFPAT_SET_DL_SRC and OFPAT_SET_DL_DST (OF v1.3) */ - public static final byte PADDING_IN_DL_ADDRESS_ACTION = 6; - /** Padding in OFPAT_SET_TP_SRC and OFPAT_SET_TP_DST (OF v1.3) */ - public static final byte PADDING_IN_TP_PORT_ACTION = 2; - /** Padding in action header (OF v1.3) */ - public static final byte PADDING_IN_ACTION_HEADER = 4; - /** Padding in OFPAT_PUSH_VLAN, OFPAT_PUSH_MPLS, OFPAT_POP_MPLS - * and OFPAT_PUSH_PBB (OF v1.3) */ - public static final byte ETHERTYPE_ACTION_PADDING = 2; - - /** Most common action length */ - public static final byte GENERAL_ACTION_LENGTH = 8; - /** Action larger than GENERAL_ACTION_LENGTH - currently - * only 16 bytes long actions for both OF v1.0 & v1.3*/ - public static final byte LARGER_ACTION_LENGTH = 16; - /** Action header size */ - public static final byte ACTION_IDS_LENGTH = 4; - - private ActionConstants() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +/** + * @author michal.polkorab + * + */ +public final class ActionConstants { + + /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ + public static final byte OUTPUT_CODE = 0; + /** Openflow v1.0 OFPAT_SET_VLAN_VID code */ + public static final byte SET_VLAN_VID_CODE = 1; + /** Openflow v1.0 OFPAT_SET_VLAN_PCP code */ + public static final byte SET_VLAN_PCP_CODE = 2; + /** Openflow v1.0 OFPAT_STRIP_VLAN code */ + public static final byte STRIP_VLAN_CODE = 3; + /** Openflow v1.0 OFPAT_SET_DL_SRC code */ + public static final byte SET_DL_SRC_CODE = 4; + /** Openflow v1.0 OFPAT_SET_DL_DST code */ + public static final byte SET_DL_DST_CODE = 5; + /** Openflow v1.0 OFPAT_SET_NW_SRC code */ + public static final byte SET_NW_SRC_CODE = 6; + /** Openflow v1.0 OFPAT_SET_NW_DST code */ + public static final byte SET_NW_DST_CODE = 7; + /** Openflow v1.0 OFPAT_SET_NW_TOS code */ + public static final byte SET_NW_TOS_CODE = 8; + /** Openflow v1.0 OFPAT_SET_TP_SRC code */ + public static final byte SET_TP_SRC_CODE = 9; + /** Openflow v1.0 OFPAT_SET_TP_DST code */ + public static final byte SET_TP_DST_CODE = 10; + /** Openflow v1.0 OFPAT_ENQUEUE code */ + public static final byte ENQUEUE_CODE = 11; + /** Openflow v1.3 OFPAT_COPY_TTL_OUT code */ + public static final byte COPY_TTL_OUT_CODE = 11; + /** Openflow v1.3 OFPAT_COPY_TTL_IN code */ + public static final byte COPY_TTL_IN_CODE = 12; + /** Openflow v1.3 OFPAT_SET_MPLS_TTL code */ + public static final byte SET_MPLS_TTL_CODE = 15; + /** Openflow v1.3 OFPAT_DEC_MPLS_TTL code */ + public static final byte DEC_MPLS_TTL_CODE = 16; + /** Openflow v1.3 OFPAT_PUSH_VLAN code */ + public static final byte PUSH_VLAN_CODE = 17; + /** Openflow v1.3 OFPAT_POP_VLAN code */ + public static final byte POP_VLAN_CODE = 18; + /** Openflow v1.3 OFPAT_PUSH_MPLS code */ + public static final byte PUSH_MPLS_CODE = 19; + /** Openflow v1.3 OFPAT_POP_MPLS code */ + public static final byte POP_MPLS_CODE = 20; + /** Openflow v1.3 OFPAT_SET_QUEUE code */ + public static final byte SET_QUEUE_CODE = 21; + /** Openflow v1.3 OFPAT_GROUP code */ + public static final byte GROUP_CODE = 22; + /** Openflow v1.3 OFPAT_SET_NW_TTL code */ + public static final byte SET_NW_TTL_CODE = 23; + /** Openflow v1.3 OFPAT_DEC_NW_TTL code */ + public static final byte DEC_NW_TTL_CODE = 24; + /** Openflow v1.3 OFPAT_SET_FIELD code */ + public static final int SET_FIELD_CODE = 25; + /** Openflow v1.3 OFPAT_PUSH_PBB code */ + public static final byte PUSH_PBB_CODE = 26; + /** Openflow v1.3 OFPAT_POP_PBB code */ + public static final byte POP_PBB_CODE = 27; + + /** Padding in OFPAT_OUTPUT (OF v1.3) */ + public static final byte OUTPUT_PADDING = 6; + /** Padding in OFPAT_SET_VLAN_VID (OF v1.3) */ + public static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2; + /** Padding in OFPAT_SET_VLAN_PCP (OF v1.3) */ + public static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3; + /** Padding in OFPAT_SET_NW_TOS (OF v1.3) */ + public static final byte PADDING_IN_SET_NW_TOS_ACTION = 3; + /** Padding in OFPAT_ENQUEUE (OF v1.3) */ + public static final int PADDING_IN_ENQUEUE_ACTION = 6; + /** Padding in OFPAT_SET_MPLS_TTL (OF v1.3) */ + public static final byte SET_MPLS_TTL_PADDING = 3; + /** Padding in OFPAT_SET_NW_TTL (OF v1.3) */ + public static final byte SET_NW_TTL_PADDING = 3; + /** Padding in OFPAT_SET_DL_SRC and OFPAT_SET_DL_DST (OF v1.3) */ + public static final byte PADDING_IN_DL_ADDRESS_ACTION = 6; + /** Padding in OFPAT_SET_TP_SRC and OFPAT_SET_TP_DST (OF v1.3) */ + public static final byte PADDING_IN_TP_PORT_ACTION = 2; + /** Padding in action header (OF v1.3) */ + public static final byte PADDING_IN_ACTION_HEADER = 4; + /** Padding in OFPAT_PUSH_VLAN, OFPAT_PUSH_MPLS, OFPAT_POP_MPLS + * and OFPAT_PUSH_PBB (OF v1.3) */ + public static final byte ETHERTYPE_ACTION_PADDING = 2; + + /** Most common action length */ + public static final byte GENERAL_ACTION_LENGTH = 8; + /** Action larger than GENERAL_ACTION_LENGTH - currently + * only 16 bytes long actions for both OF v1.0 & v1.3*/ + public static final byte LARGER_ACTION_LENGTH = 16; + /** Action header size */ + public static final byte ACTION_IDS_LENGTH = 4; + + private ActionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java index a3fb7113..2f48763a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public ActionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - */ - public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new ActionDeserializerKey(version, code, - null), deserializer); - } -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public ActionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new ActionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index d941f547..912ec8b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - */ -public class ActionSerializerRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param objectType - * @param serializerRegistry - */ - public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param actionType - * @param serializer - */ - public void registerSerializer(Class actionType, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, - actionType, null), serializer); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + */ +public class ActionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param objectType + * @param serializerRegistry + */ + public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param actionType + * @param serializer + */ + public void registerSerializer(Class actionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, + actionType, null), serializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java index 52c2a4de..f5be1f6c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; - -import io.netty.buffer.ByteBuf; - -/** - * @author michal.polkorab - */ -public interface CodeKeyMaker { - - /** - * @param input buffer that will be the needed data gathered from - * @return key for deserializer lookup - */ - abstract MessageCodeKey make(ByteBuf input); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; + +import io.netty.buffer.ByteBuf; + +/** + * @author michal.polkorab + */ +public interface CodeKeyMaker { + + /** + * @param input buffer that will be the needed data gathered from + * @return key for deserializer lookup + */ + abstract MessageCodeKey make(ByteBuf input); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 9b21226b..7713e355 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -1,90 +1,90 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public abstract class CodeKeyMakerFactory { - - /** - * @param version - * @return - */ - public static CodeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int oxmClass = input.getUnsignedShort(input.readerIndex()); - int oxmField = input.getUnsignedByte(input.readerIndex() - + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), - oxmClass, oxmField); - if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { - long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES - + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); - return key; - } - key.setExperimenterId(null); - return key; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createActionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ExperimenterActionDeserializerKey(getVersion(), expId); - } - ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); - return actionDeserializerKey; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createInstructionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ExperimenterInstructionDeserializerKey(getVersion(), expId); - } - return new InstructionDeserializerKey(getVersion(), type, null); - } - }; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public abstract class CodeKeyMakerFactory { + + /** + * @param version + * @return + */ + public static CodeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int oxmClass = input.getUnsignedShort(input.readerIndex()); + int oxmField = input.getUnsignedByte(input.readerIndex() + + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + return key; + } + key.setExperimenterId(null); + return key; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createActionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterActionDeserializerKey(getVersion(), expId); + } + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); + return actionDeserializerKey; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createInstructionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterInstructionDeserializerKey(getVersion(), expId); + } + return new InstructionDeserializerKey(getVersion(), type, null); + } + }; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java index 0ce8d54e..35cfef79 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; - -/** - * @author michal.polkorab - * - */ -public class CommonMessageRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version - * @param serializerRegistry - */ - public CommonMessageRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * @param msgType - * @param serializer - */ - public void registerSerializer(Class msgType, OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; + +/** + * @author michal.polkorab + * + */ +public class CommonMessageRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version + * @param serializerRegistry + */ + public CommonMessageRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * @param msgType + * @param serializer + */ + public void registerSerializer(Class msgType, OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java index 2476c4e9..7d9479a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -/** - * @author michal.polkorab - * - */ -public final class InstructionConstants { - - /** Openflow v1.3 OFPIT_GOTO_TABLE code */ - public static final byte GOTO_TABLE_TYPE = 1; - /** Openflow v1.3 OFPIT_WRITE_METADATA code */ - public static final byte WRITE_METADATA_TYPE = 2; - /** Openflow v1.3 OFPIT_WRITE_ACTIONS code */ - public static final byte WRITE_ACTIONS_TYPE = 3; - /** Openflow v1.3 OFPIT_APPLY_ACTIONS code */ - public static final byte APPLY_ACTIONS_TYPE = 4; - /** Openflow v1.3 OFPIT_CLEAR_ACTIONS code */ - public static final byte CLEAR_ACTIONS_TYPE = 5; - /** Openflow v1.3 OFPIT_METER code */ - public static final byte METER_TYPE = 6; - - /** PADDING in OFPIT_GOTO_TABLE */ - public static final byte PADDING_IN_GOTO_TABLE = 3; - /** PADDING in OFPIT_WRITE_METADATA */ - public static final byte PADDING_IN_WRITE_METADATA = 4; - /** PADDING in OFPIT_WRITE_ACTIONS, OFPIT_APPLY_ACTIONS - * and OFPIT_CLEAR_ACTIONS */ - public static final byte PADDING_IN_ACTIONS_INSTRUCTION = 4; - - /** Openflow v1.3 header length (padded) */ - public static final byte STANDARD_INSTRUCTION_LENGTH = 8; - /** Openflow v1.3 OFPIT_WRITE_METADATA length */ - public static final byte WRITE_METADATA_LENGTH = 24; - /** Openflow v1.3 header length (only type and length fields) */ - public static final byte INSTRUCTION_IDS_LENGTH = 4; - - private InstructionConstants() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +/** + * @author michal.polkorab + * + */ +public final class InstructionConstants { + + /** Openflow v1.3 OFPIT_GOTO_TABLE code */ + public static final byte GOTO_TABLE_TYPE = 1; + /** Openflow v1.3 OFPIT_WRITE_METADATA code */ + public static final byte WRITE_METADATA_TYPE = 2; + /** Openflow v1.3 OFPIT_WRITE_ACTIONS code */ + public static final byte WRITE_ACTIONS_TYPE = 3; + /** Openflow v1.3 OFPIT_APPLY_ACTIONS code */ + public static final byte APPLY_ACTIONS_TYPE = 4; + /** Openflow v1.3 OFPIT_CLEAR_ACTIONS code */ + public static final byte CLEAR_ACTIONS_TYPE = 5; + /** Openflow v1.3 OFPIT_METER code */ + public static final byte METER_TYPE = 6; + + /** PADDING in OFPIT_GOTO_TABLE */ + public static final byte PADDING_IN_GOTO_TABLE = 3; + /** PADDING in OFPIT_WRITE_METADATA */ + public static final byte PADDING_IN_WRITE_METADATA = 4; + /** PADDING in OFPIT_WRITE_ACTIONS, OFPIT_APPLY_ACTIONS + * and OFPIT_CLEAR_ACTIONS */ + public static final byte PADDING_IN_ACTIONS_INSTRUCTION = 4; + + /** Openflow v1.3 header length (padded) */ + public static final byte STANDARD_INSTRUCTION_LENGTH = 8; + /** Openflow v1.3 OFPIT_WRITE_METADATA length */ + public static final byte WRITE_METADATA_LENGTH = 24; + /** Openflow v1.3 header length (only type and length fields) */ + public static final byte INSTRUCTION_IDS_LENGTH = 4; + + private InstructionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java index 2b4ea9da..44a6a884 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - */ - public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new InstructionDeserializerKey(version, code, - null), deserializer); - } -} +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new InstructionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index 3ee13cb8..f89fd0a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - */ -public class InstructionSerializerRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param serializerRegistry - */ - public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param instructionType - * @param serializer - */ - public void registerSerializer(Class instructionType, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, - instructionType, null), serializer); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + */ +public class InstructionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param serializerRegistry + */ + public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param instructionType + * @param serializer + */ + public void registerSerializer(Class instructionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, + instructionType, null), serializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index 6e32f86f..93d3c3e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -public final class ListDeserializer { - - private ListDeserializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Deserializes items into list - * @param version openflow wire version - * @param length length of list in ByteBuf (bytes) - * @param input input buffer - * @param keyMaker creates keys for deserializer lookup - * @param registry stores deserializers - * @return list of items - */ - public static List deserializeList(short version, int length, - ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { - List items = null; - if (input.readableBytes() > 0) { - items = new ArrayList<>(); - int startIndex = input.readerIndex(); - while ((input.readerIndex() - startIndex) < length){ - OFDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); - E item = deserializer.deserialize(input); - items.add(item); - } - } - return items; - } - - /** - * Deserializes headers of items into list - * @param version openflow wire version - * @param length length of list in ByteBuf (bytes) - * @param input input buffer - * @param keyMaker creates keys for deserializer lookup - * @param registry stores deserializers - * @return list of items - */ - public static List deserializeHeaders(short version, int length, - ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { - List items = null; - if (input.readableBytes() > 0) { - items = new ArrayList<>(); - int startIndex = input.readerIndex(); - while ((input.readerIndex() - startIndex) < length){ - HeaderDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); - E item = deserializer.deserializeHeader(input); - items.add(item); - } - } - return items; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +public final class ListDeserializer { + + private ListDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Deserializes items into list + * @param version openflow wire version + * @param length length of list in ByteBuf (bytes) + * @param input input buffer + * @param keyMaker creates keys for deserializer lookup + * @param registry stores deserializers + * @return list of items + */ + public static List deserializeList(short version, int length, + ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { + List items = null; + if (input.readableBytes() > 0) { + items = new ArrayList<>(); + int startIndex = input.readerIndex(); + while ((input.readerIndex() - startIndex) < length){ + OFDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); + E item = deserializer.deserialize(input); + items.add(item); + } + } + return items; + } + + /** + * Deserializes headers of items into list + * @param version openflow wire version + * @param length length of list in ByteBuf (bytes) + * @param input input buffer + * @param keyMaker creates keys for deserializer lookup + * @param registry stores deserializers + * @return list of items + */ + public static List deserializeHeaders(short version, int length, + ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { + List items = null; + if (input.readableBytes() > 0) { + items = new ArrayList<>(); + int startIndex = input.readerIndex(); + while ((input.readerIndex() - startIndex) < length){ + HeaderDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); + E item = deserializer.deserializeHeader(input); + items.add(item); + } + } + return items; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index 58a96352..f085377f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Serializes list items and their headers - * @author michal.polkorab - * @param - */ -public abstract class ListSerializer { - - /** - * Serializes item list - * @param list list of items to be serialized - * @param keyMaker creates key for registry lookup - * @param registry stores serializers - * @param outBuffer output buffer - */ - public static void serializeList(List list, - TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { - if (list != null) { - for (E item : list) { - OFSerializer serializer = registry.getSerializer(keyMaker.make(item)); - serializer.serialize(item, outBuffer); - } - } - } - - /** - * Serializes headers of items in list - * @param list list of items to be serialized - * @param keyMaker creates key for registry lookup - * @param registry stores serializers - * @param outBuffer output buffer - */ - public static void serializeHeaderList(List list, - TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { - if (list != null) { - for (E item : list) { - HeaderSerializer serializer = registry.getSerializer(keyMaker.make(item)); - serializer.serializeHeader(item, outBuffer); - } - } - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * Serializes list items and their headers + * @author michal.polkorab + * @param + */ +public abstract class ListSerializer { + + /** + * Serializes item list + * @param list list of items to be serialized + * @param keyMaker creates key for registry lookup + * @param registry stores serializers + * @param outBuffer output buffer + */ + public static void serializeList(List list, + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + if (list != null) { + for (E item : list) { + OFSerializer serializer = registry.getSerializer(keyMaker.make(item)); + serializer.serialize(item, outBuffer); + } + } + } + + /** + * Serializes headers of items in list + * @param list list of items to be serialized + * @param keyMaker creates key for registry lookup + * @param registry stores serializers + * @param outBuffer output buffer + */ + public static void serializeHeaderList(List list, + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + if (list != null) { + for (E item : list) { + HeaderSerializer serializer = registry.getSerializer(keyMaker.make(item)); + serializer.serializeHeader(item, outBuffer); + } + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index e9e1c10e..e666f11e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -1,47 +1,47 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class MatchEntryDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - private int oxmClass; - - /** - * @param version wire protocol version - * @param oxmClass oxm_class that will be used for match entry deserializer - * registration - * @param deserializerRegistry registry to be filled with message deserializers - */ - public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, - DeserializerRegistry deserializerRegistry) { - this.version = version; - this.oxmClass = oxmClass; - this.registry = deserializerRegistry; - } - - /** - * Registers match entry deserializer under provided oxmfield () - * @param oxmField oxm_field value/code - * @param deserializer deserializer instance - */ - public void register(int oxmField, OFGeneralDeserializer deserializer) { - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); - key.setExperimenterId(null); - registry.registerDeserializer(key, deserializer); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + private int oxmClass; + + /** + * @param version wire protocol version + * @param oxmClass oxm_class that will be used for match entry deserializer + * registration + * @param deserializerRegistry registry to be filled with message deserializers + */ + public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, + DeserializerRegistry deserializerRegistry) { + this.version = version; + this.oxmClass = oxmClass; + this.registry = deserializerRegistry; + } + + /** + * Registers match entry deserializer under provided oxmfield () + * @param oxmField oxm_field value/code + * @param deserializer deserializer instance + */ + public void register(int oxmField, OFGeneralDeserializer deserializer) { + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); + key.setExperimenterId(null); + registry.registerDeserializer(key, deserializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 0bbd6ab9..e3f49e30 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * @param OXM class - */ -public class MatchEntrySerializerRegistryHelper { - - private short version; - private Class generalClass; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param generalClass - * @param serializerRegistry - */ - public MatchEntrySerializerRegistryHelper(short version, Class generalClass, - SerializerRegistry serializerRegistry) { - this.version = version; - this.generalClass = generalClass; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param specificClass - * @param serializer - */ - public void registerSerializer( - Class specificClass, OFGeneralSerializer serializer) { - MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); - key.setExperimenterId(null); - serializerRegistry.registerSerializer(key, serializer); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * @param OXM class + */ +public class MatchEntrySerializerRegistryHelper { + + private short version; + private Class generalClass; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param generalClass + * @param serializerRegistry + */ + public MatchEntrySerializerRegistryHelper(short version, Class generalClass, + SerializerRegistry serializerRegistry) { + this.version = version; + this.generalClass = generalClass; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param specificClass + * @param serializer + */ + public void registerSerializer( + Class specificClass, OFGeneralSerializer serializer) { + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); + key.setExperimenterId(null); + serializerRegistry.registerSerializer(key, serializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java index 78f27eac..9a608b2d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; - -/** - * Used for common structures translation / conversion - * - * @author michal.polkorab - */ -public abstract class OpenflowUtils { - - /** - * Creates PortState (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortStateV10 createPortState(long input){ - final Boolean psLinkDown = ((input) & (1<<0)) != 0; - final Boolean psBlocked = ((input) & (1<<1)) != 0; - final Boolean psLive = ((input) & (1<<2)) != 0; - final Boolean psStpListen = ((input) & (1<<8)) == 0; - final Boolean psStpLearn = ((input) & (1<<8)) != 0; - final Boolean psStpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 - final Boolean psStpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 - final Boolean psStpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 - return new PortStateV10(psBlocked, psLinkDown, psLive, psStpBlock, psStpForward, psStpLearn, psStpListen, psStpMask); - } - - /** - * Creates PortConfig (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortConfigV10 createPortConfig(long input){ - final Boolean pcPortDown = ((input) & (1<<0)) != 0; - final Boolean pcNoStp = ((input) & (1<<1)) != 0; - final Boolean pcNoRecv = ((input) & (1<<2)) != 0; - final Boolean pcNoRecvStp = ((input) & (1<<3)) != 0; - final Boolean pcNoFlood = ((input) & (1<<4)) != 0; - final Boolean pcNoFwd = ((input) & (1<<5)) != 0; - final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; - return new PortConfigV10(pcNoFlood, pcNoFwd, pcNoPacketIn, pcNoRecv, pcNoRecvStp, pcNoStp, pcPortDown); - } - - /** - * Creates PortFeatures (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortFeaturesV10 createPortFeatures(long input){ - final Boolean pf10mbHd = ((input) & (1<<0)) != 0; - final Boolean pf10mbFd = ((input) & (1<<1)) != 0; - final Boolean pf100mbHd = ((input) & (1<<2)) != 0; - final Boolean pf100mbFd = ((input) & (1<<3)) != 0; - final Boolean pf1gbHd = ((input) & (1<<4)) != 0; - final Boolean pf1gbFd = ((input) & (1<<5)) != 0; - final Boolean pf10gbFd = ((input) & (1<<6)) != 0; - final Boolean pfCopper = ((input) & (1<<7)) != 0; - final Boolean pfFiber = ((input) & (1<<8)) != 0; - final Boolean pfAutoneg = ((input) & (1<<9)) != 0; - final Boolean pfPause = ((input) & (1<<10)) != 0; - final Boolean pfPauseAsym = ((input) & (1<<11)) != 0; - return new PortFeaturesV10(pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, - pf1gbFd, pf1gbHd, pfAutoneg, pfCopper, pfFiber, pfPause, pfPauseAsym); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; + +/** + * Used for common structures translation / conversion + * + * @author michal.polkorab + */ +public abstract class OpenflowUtils { + + /** + * Creates PortState (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortStateV10 createPortState(long input){ + final Boolean psLinkDown = ((input) & (1<<0)) != 0; + final Boolean psBlocked = ((input) & (1<<1)) != 0; + final Boolean psLive = ((input) & (1<<2)) != 0; + final Boolean psStpListen = ((input) & (1<<8)) == 0; + final Boolean psStpLearn = ((input) & (1<<8)) != 0; + final Boolean psStpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 + final Boolean psStpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 + final Boolean psStpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 + return new PortStateV10(psBlocked, psLinkDown, psLive, psStpBlock, psStpForward, psStpLearn, psStpListen, psStpMask); + } + + /** + * Creates PortConfig (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortConfigV10 createPortConfig(long input){ + final Boolean pcPortDown = ((input) & (1<<0)) != 0; + final Boolean pcNoStp = ((input) & (1<<1)) != 0; + final Boolean pcNoRecv = ((input) & (1<<2)) != 0; + final Boolean pcNoRecvStp = ((input) & (1<<3)) != 0; + final Boolean pcNoFlood = ((input) & (1<<4)) != 0; + final Boolean pcNoFwd = ((input) & (1<<5)) != 0; + final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; + return new PortConfigV10(pcNoFlood, pcNoFwd, pcNoPacketIn, pcNoRecv, pcNoRecvStp, pcNoStp, pcPortDown); + } + + /** + * Creates PortFeatures (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortFeaturesV10 createPortFeatures(long input){ + final Boolean pf10mbHd = ((input) & (1<<0)) != 0; + final Boolean pf10mbFd = ((input) & (1<<1)) != 0; + final Boolean pf100mbHd = ((input) & (1<<2)) != 0; + final Boolean pf100mbFd = ((input) & (1<<3)) != 0; + final Boolean pf1gbHd = ((input) & (1<<4)) != 0; + final Boolean pf1gbFd = ((input) & (1<<5)) != 0; + final Boolean pf10gbFd = ((input) & (1<<6)) != 0; + final Boolean pfCopper = ((input) & (1<<7)) != 0; + final Boolean pfFiber = ((input) & (1<<8)) != 0; + final Boolean pfAutoneg = ((input) & (1<<9)) != 0; + final Boolean pfPause = ((input) & (1<<10)) != 0; + final Boolean pfPauseAsym = ((input) & (1<<11)) != 0; + return new PortFeaturesV10(pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, + pf1gbFd, pf1gbHd, pfAutoneg, pfCopper, pfFiber, pfPause, pfPauseAsym); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 0fc66083..7c9ec2b5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; - -/** - * @author michal.polkorab - * - */ -public class SimpleDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param experimenterID TODO - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - * @param deserializer deserializer instance - */ - public void registerDeserializer(int code, - Long experimenterID, Class deserializedObjectClass, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new MessageCodeKey(version, code, - deserializedObjectClass), deserializer); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; + +/** + * @author michal.polkorab + * + */ +public class SimpleDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param experimenterID TODO + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + * @param deserializer deserializer instance + */ + public void registerDeserializer(int code, + Long experimenterID, Class deserializedObjectClass, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new MessageCodeKey(version, code, + deserializedObjectClass), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index a9dab19e..02b0307b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; - -/** - * @author michal.polkorab - * @param - */ -public interface TypeKeyMaker { - - /** - * @param entry - * @return key that will be used for serializer lookup in - * the serializer registry - */ - abstract MessageTypeKey make(T entry); - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; + +/** + * @author michal.polkorab + * @param + */ +public interface TypeKeyMaker { + + /** + * @param entry + * @return key that will be used for serializer lookup in + * the serializer registry + */ + abstract MessageTypeKey make(T entry); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 1d3875df..2c5b7def 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Creates KeyMakers - * @author michal.polkorab - */ -public abstract class TypeKeyMakerFactory { - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MatchEntrySerializerKey make(MatchEntries entry) { - MatchEntrySerializerKey key; - key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), - entry.getOxmMatchField()); - if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); - return key; - } - key.setExperimenterId(null); - return key; - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createActionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MessageTypeKey make(Action entry) { - if (entry.getType().equals(Experimenter.class)) { - return new ExperimenterActionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); - } - return new ActionSerializerKey<>(getVersion(), entry.getType(), null); - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createInstructionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MessageTypeKey make(Instruction entry) { - if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common - .instruction.rev130731.Experimenter.class)) { - return new ExperimenterInstructionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdInstruction.class) - .getExperimenter().getValue()); - } - return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); - } - }; - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Creates KeyMakers + * @author michal.polkorab + */ +public abstract class TypeKeyMakerFactory { + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MatchEntrySerializerKey make(MatchEntries entry) { + MatchEntrySerializerKey key; + key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), + entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); + return key; + } + key.setExperimenterId(null); + return key; + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createActionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MessageTypeKey make(Action entry) { + if (entry.getType().equals(Experimenter.class)) { + return new ExperimenterActionSerializerKey(getVersion(), + entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); + } + return new ActionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createInstructionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MessageTypeKey make(Instruction entry) { + if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common + .instruction.rev130731.Experimenter.class)) { + return new ExperimenterInstructionSerializerKey(getVersion(), + entry.getAugmentation(ExperimenterIdInstruction.class) + .getExperimenter().getValue()); + } + return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index abf7695d..0484ea83 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import java.util.Map; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassInitHelper { - - private short version; - private Map> messageClassMap; - - /** - * Constructor - * @param version protocol wire version - * @param messageClassMap map which stores type to class mapping - */ - public TypeToClassInitHelper(short version, Map> messageClassMap) { - this.version = version; - this.messageClassMap = messageClassMap; - } - - /** - * Registers Class int the type to class mapping - * @param type code value for message type / class - * @param clazz corresponding code -> class - */ - public void registerTypeToClass(short type, Class clazz) { - messageClassMap.put(new TypeToClassKey(version, type), clazz); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import java.util.Map; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassInitHelper { + + private short version; + private Map> messageClassMap; + + /** + * Constructor + * @param version protocol wire version + * @param messageClassMap map which stores type to class mapping + */ + public TypeToClassInitHelper(short version, Map> messageClassMap) { + this.version = version; + this.messageClassMap = messageClassMap; + } + + /** + * Registers Class int the type to class mapping + * @param type code value for message type / class + * @param clazz corresponding code -> class + */ + public void registerTypeToClass(short type, Class clazz) { + messageClassMap.put(new TypeToClassKey(version, type), clazz); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java index 098f9322..0f6b9caf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassKey { - - private short version; - private int type; - - /** - * Constructor - * @param version wire protocol version - * @param type message type / code - */ - public TypeToClassKey(short version, int type) { - this.version = version; - this.type = type; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + type; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TypeToClassKey other = (TypeToClassKey) obj; - if (type != other.type) { - return false; - } - if (version != other.version) { - return false; - } - return true; - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassKey { + + private short version; + private int type; + + /** + * Constructor + * @param version wire protocol version + * @param type message type / code + */ + public TypeToClassKey(short version, int type) { + this.version = version; + this.type = type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + type; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TypeToClassKey other = (TypeToClassKey) obj; + if (type != other.type) { + return false; + } + if (version != other.version) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index c5f18729..aea5890e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.statistics; - -import java.util.concurrent.atomic.AtomicLong; -/** - * Counts statistics - * - * @author madamjak - */ -public class Counter { - - private AtomicLong counterValue; - private AtomicLong counterLastReadValue; - - /** - * Default constructor - */ - public Counter() { - counterValue = new AtomicLong(0L); - counterLastReadValue = new AtomicLong(0L); - } - - /** - * Increment current counter value - */ - public void incrementCounter(){ - counterValue.incrementAndGet(); - } - - /** - * return the last read value of counter. This value can be set during the reading of current counter value, - * for detail see method getCounterValue(boolean modifyLastReadValue). - * @return the counterLastReadValue - */ - public long getCounterLastReadValue() { - return counterLastReadValue.get(); - } - - /** - * get current value of counter and rewrite CounterLastReadValue by current value - * @return the current value of counter - */ - public long getCounterValue() { - return getCounterValue(true); - } - - /** - * get current counter value - * @param modifyLastReadValue - * true - CounterLastReadValue will be rewritten by current CounterValue - * false - no change CounterLastReadValue - * @return the current value of counter - */ - public long getCounterValue(boolean modifyLastReadValue) { - if(modifyLastReadValue){ - counterLastReadValue.set(counterValue.get()); - } - return counterValue.get(); - } - - /** - * set current counter value and CounterLastReadValue to 0 (zero) - */ - public void reset(){ - counterValue.set(0l); - counterLastReadValue.set(0l); - } - - /** - * @return last and current count for specified statistic - */ - public String getStat() { - long cntPrevVal = getCounterLastReadValue(); - long cntCurValue = getCounterValue(); - return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.statistics; + +import java.util.concurrent.atomic.AtomicLong; +/** + * Counts statistics + * + * @author madamjak + */ +public class Counter { + + private AtomicLong counterValue; + private AtomicLong counterLastReadValue; + + /** + * Default constructor + */ + public Counter() { + counterValue = new AtomicLong(0L); + counterLastReadValue = new AtomicLong(0L); + } + + /** + * Increment current counter value + */ + public void incrementCounter(){ + counterValue.incrementAndGet(); + } + + /** + * return the last read value of counter. This value can be set during the reading of current counter value, + * for detail see method getCounterValue(boolean modifyLastReadValue). + * @return the counterLastReadValue + */ + public long getCounterLastReadValue() { + return counterLastReadValue.get(); + } + + /** + * get current value of counter and rewrite CounterLastReadValue by current value + * @return the current value of counter + */ + public long getCounterValue() { + return getCounterValue(true); + } + + /** + * get current counter value + * @param modifyLastReadValue + * true - CounterLastReadValue will be rewritten by current CounterValue + * false - no change CounterLastReadValue + * @return the current value of counter + */ + public long getCounterValue(boolean modifyLastReadValue) { + if(modifyLastReadValue){ + counterLastReadValue.set(counterValue.get()); + } + return counterValue.get(); + } + + /** + * set current counter value and CounterLastReadValue to 0 (zero) + */ + public void reset(){ + counterValue.set(0l); + counterLastReadValue.set(0l); + } + + /** + * @return last and current count for specified statistic + */ + public String getStat() { + long cntPrevVal = getCounterLastReadValue(); + long cntCurValue = getCounterValue(); + return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java index 0dd7faad..b021745d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.statistics; - -/** - * Enumeration of events to be counted with StatisticsCounters - * @author madamjak - * - */ -public enum CounterEventTypes { - /** - * enter message to OFJ and pass to downstream - */ - DS_ENTERED_OFJAVA, - /** - * flow-mod is entered - */ - DS_FLOW_MODS_ENTERED, - /** - * encode message successfully - */ - DS_ENCODE_SUCCESS, - /** - * fail encode message - */ - DS_ENCODE_FAIL, - /** - * flow-mod encoded and sent to downstream - */ - DS_FLOW_MODS_SENT, - /** - * receive message and pass to upstream - */ - US_RECEIVED_IN_OFJAVA, - /** - * decode message successfully - */ - US_DECODE_SUCCESS, - /** - * fail decode message - */ - US_DECODE_FAIL, - /** - * pass message to consumer (end of upstream) - */ - US_MESSAGE_PASS; +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.statistics; + +/** + * Enumeration of events to be counted with StatisticsCounters + * @author madamjak + * + */ +public enum CounterEventTypes { + /** + * enter message to OFJ and pass to downstream + */ + DS_ENTERED_OFJAVA, + /** + * flow-mod is entered + */ + DS_FLOW_MODS_ENTERED, + /** + * encode message successfully + */ + DS_ENCODE_SUCCESS, + /** + * fail encode message + */ + DS_ENCODE_FAIL, + /** + * flow-mod encoded and sent to downstream + */ + DS_FLOW_MODS_SENT, + /** + * receive message and pass to upstream + */ + US_RECEIVED_IN_OFJAVA, + /** + * decode message successfully + */ + US_DECODE_SUCCESS, + /** + * fail decode message + */ + US_DECODE_FAIL, + /** + * pass message to consumer (end of upstream) + */ + US_MESSAGE_PASS; } \ 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 index 75e1faac..fff5292a 100644 --- a/openflow-protocol-impl/src/main/resources/log4j.xml +++ b/openflow-protocol-impl/src/main/resources/log4j.xml @@ -1,28 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java index 3baeb944..7ab8bfcc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core; - -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import io.netty.channel.ChannelHandlerContext; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketEncoderTest { - - @Mock ChannelHandlerContext ctx; - @Mock GenericFutureListener> listener; - @Mock SerializationFactory factory; - - private UdpMessageListenerWrapper wrapper; - private InetSocketAddress address = new InetSocketAddress("10.0.0.1", 6653); - private List out; - - /** - * Initializes mocks and other objects - * @param version openflow protocol wire version - */ - public void startUp(Short version) { - MockitoAnnotations.initMocks(this); - out = new ArrayList<>(); - HelloInputBuilder builder = new HelloInputBuilder(); - builder.setVersion(version); - HelloInput hello = builder.build(); - wrapper = new UdpMessageListenerWrapper(hello, listener, address); - } - - /** - * Tests encoding - */ - @Test - public void testCorrectEncode() { - startUp((short) EncodeConstants.OF13_VERSION_ID); - OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); - encoder.setSerializationFactory(factory); - try { - encoder.encode(ctx, wrapper, out); - } catch (Exception e) { - Assert.fail(); - } - } - - /** - * Tests encoding - */ - @Test - public void testIncorrectEncode() { - startUp(null); - OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); - encoder.setSerializationFactory(factory); - try { - encoder.encode(ctx, wrapper, out); - } catch (Exception e) { - verify(wrapper, times(1)).getListener(); - Assert.assertEquals("List should be empty", 0, out.size()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketEncoderTest { + + @Mock ChannelHandlerContext ctx; + @Mock GenericFutureListener> listener; + @Mock SerializationFactory factory; + + private UdpMessageListenerWrapper wrapper; + private InetSocketAddress address = new InetSocketAddress("10.0.0.1", 6653); + private List out; + + /** + * Initializes mocks and other objects + * @param version openflow protocol wire version + */ + public void startUp(Short version) { + MockitoAnnotations.initMocks(this); + out = new ArrayList<>(); + HelloInputBuilder builder = new HelloInputBuilder(); + builder.setVersion(version); + HelloInput hello = builder.build(); + wrapper = new UdpMessageListenerWrapper(hello, listener, address); + } + + /** + * Tests encoding + */ + @Test + public void testCorrectEncode() { + startUp((short) EncodeConstants.OF13_VERSION_ID); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + Assert.fail(); + } + } + + /** + * Tests encoding + */ + @Test + public void testIncorrectEncode() { + startUp(null); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + verify(wrapper, times(1)).getListener(); + Assert.assertEquals("List should be empty", 0, out.size()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java index cf50b626..0b001d9b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import io.netty.channel.Channel; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; - -/** - * @author michal.polkorab - * - */ -public class ChannelOutboundQueueTest { - - @Mock Channel channel; - - /** - * Initialize mocks - */ - public ChannelOutboundQueueTest() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test incorrect queue creation handling - */ - @Test(expected=IllegalArgumentException.class) - public void testIncorrectQueueCreation() { - new ChannelOutboundQueue(channel, 0, null); - } - - /** - * Test correct enqueue handling - */ - @Test - public void testEnqueue() { - ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); - boolean enqueued; - enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); - Assert.assertTrue("Enqueue problem", enqueued); - enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); - Assert.assertFalse("Enqueue problem", enqueued); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import io.netty.channel.Channel; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; + +/** + * @author michal.polkorab + * + */ +public class ChannelOutboundQueueTest { + + @Mock Channel channel; + + /** + * Initialize mocks + */ + public ChannelOutboundQueueTest() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test incorrect queue creation handling + */ + @Test(expected=IllegalArgumentException.class) + public void testIncorrectQueueCreation() { + new ChannelOutboundQueue(channel, 0, null); + } + + /** + * Test correct enqueue handling + */ + @Test + public void testEnqueue() { + ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); + boolean enqueued; + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertTrue("Enqueue problem", enqueued); + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertFalse("Enqueue problem", enqueued); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java index 77d9e912..c9f52772 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; - -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; -import org.opendaylight.yangtools.yang.binding.DataObject; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - -/** - * @author michal.polkorab - * @author madamjak - * - */ -public class ConnectionAdapterImplTest { - - private static final int RPC_RESPONSE_EXPIRATION = 1; - private static final RemovalListener> REMOVAL_LISTENER = - new RemovalListener>() { - @Override - public void onRemoval( - final RemovalNotification> notification) { - notification.getValue().discard(); - } - }; - - @Mock SocketChannel channel; - @Mock ChannelPipeline pipeline; - @Mock OpenflowProtocolListener messageListener; - @Mock SystemNotificationsListener systemListener; - @Mock ConnectionReadyListener readyListener; - @Mock Cache> mockCache; - @Mock ChannelFuture channelFuture; +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ - private ConnectionAdapterImpl adapter; - private Cache> cache; - - /** - * Initializes ConnectionAdapter - */ - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(channel.pipeline()).thenReturn(pipeline); - adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); - adapter.setMessageListener(messageListener); - adapter.setSystemListener(systemListener); - adapter.setConnectionReadyListener(readyListener); - cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) - .removalListener(REMOVAL_LISTENER).build(); +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; +import org.opendaylight.yangtools.yang.binding.DataObject; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author michal.polkorab + * @author madamjak + * + */ +public class ConnectionAdapterImplTest { + + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock SocketChannel channel; + @Mock ChannelPipeline pipeline; + @Mock OpenflowProtocolListener messageListener; + @Mock SystemNotificationsListener systemListener; + @Mock ConnectionReadyListener readyListener; + @Mock Cache> mockCache; + @Mock ChannelFuture channelFuture; + + private ConnectionAdapterImpl adapter; + private Cache> cache; + + /** + * Initializes ConnectionAdapter + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(channel.pipeline()).thenReturn(pipeline); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter.setMessageListener(messageListener); + adapter.setSystemListener(systemListener); + adapter.setConnectionReadyListener(readyListener); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); when(channel.disconnect()).thenReturn(channelFuture); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications - */ - @Test - public void testConsume() { - DataObject message = new EchoRequestMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); - message = new ErrorMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message); - message = new ExperimenterMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message); - message = new FlowRemovedMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message); - message = new HelloMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onHelloMessage((HelloMessage) message); - message = new MultipartReplyMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message); - message = new PacketInMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message); - message = new PortStatusMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message); - message = new SwitchIdleEventBuilder().build(); - adapter.consume(message); - verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message); - message = new DisconnectEventBuilder().build(); - adapter.consume(message); - verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message); - message = new EchoRequestMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc - */ - @Test - public void testConsume2() { - adapter.setResponseCache(mockCache); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); - barrierBuilder.setXid(42L); - BarrierOutput barrier = barrierBuilder.build(); - adapter.consume(barrier); - verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc - */ - @Test - public void testConsume3() { - BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); - inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - inputBuilder.setXid(42L); - BarrierInput barrierInput = inputBuilder.build(); - RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); - ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, - "failure", mockCache, key); - cache.put(key, listener); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); - barrierBuilder.setXid(42L); - BarrierOutput barrierOutput = barrierBuilder.build(); - adapter.consume(barrierOutput); - ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); - Assert.assertNull("Listener was not discarded", ifPresent); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications + */ + @Test + public void testConsume() { + DataObject message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + message = new ErrorMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message); + message = new ExperimenterMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message); + message = new FlowRemovedMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message); + message = new HelloMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onHelloMessage((HelloMessage) message); + message = new MultipartReplyMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message); + message = new PacketInMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message); + message = new PortStatusMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message); + message = new SwitchIdleEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message); + message = new DisconnectEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message); + message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc + */ + @Test + public void testConsume2() { + adapter.setResponseCache(mockCache); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrier = barrierBuilder.build(); + adapter.consume(barrier); + verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc + */ + @Test + public void testConsume3() { + BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); + inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + inputBuilder.setXid(42L); + BarrierInput barrierInput = inputBuilder.build(); + RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); + ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, + "failure", mockCache, key); + cache.put(key, listener); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrierOutput = barrierBuilder.build(); + adapter.consume(barrierOutput); + ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); + Assert.assertNull("Listener was not discarded", ifPresent); } /** * Test IsAlive method diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java index 18992b62..3be4ba4f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class MessageListenerWrapperTest { - - /** - * Test MessageListenerWrapper creation - */ - @Test - public void test() { - HelloInputBuilder builder = new HelloInputBuilder(); - HelloInput hello = builder.build(); - SimpleRpcListener listener = new SimpleRpcListener(hello, "Error"); - MessageListenerWrapper wrapper = new MessageListenerWrapper(hello, listener); - Assert.assertEquals("Wrong message", hello, wrapper.getMsg()); - Assert.assertEquals("Wrong listener", listener, wrapper.getListener()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class MessageListenerWrapperTest { + + /** + * Test MessageListenerWrapper creation + */ + @Test + public void test() { + HelloInputBuilder builder = new HelloInputBuilder(); + HelloInput hello = builder.build(); + SimpleRpcListener listener = new SimpleRpcListener(hello, "Error"); + MessageListenerWrapper wrapper = new MessageListenerWrapper(hello, listener); + Assert.assertEquals("Wrong message", hello, wrapper.getMsg()); + Assert.assertEquals("Wrong listener", listener, wrapper.getListener()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java index 32b6b931..ec57cb8f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java @@ -1,132 +1,132 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import static org.junit.Assert.fail; - -import java.util.Collections; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; -import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.util.concurrent.SettableFuture; - -/** - * @author michal.polkorab - * - */ -public class ResponseExpectedRpcListenerTest { - - private static final RemovalListener> REMOVAL_LISTENER = - new RemovalListener>() { - @Override - public void onRemoval( - final RemovalNotification> notification) { - notification.getValue().discard(); - } - }; - private static final int RPC_RESPONSE_EXPIRATION = 1; - private Cache> responseCache = CacheBuilder.newBuilder() - .concurrencyLevel(1) - .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) - .removalListener(REMOVAL_LISTENER).build(); - - /** - * Test object creation - */ - @Test(expected=NullPointerException.class) - public void testCreation() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", null, key); - } - - /** - * Test object creation - */ - @Test(expected=NullPointerException.class) - public void testCreation2() { - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); - } - - /** - * Test object creation - */ - @Test - public void testDiscard() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - listener.discard(); - RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", - ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); - try { - Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), - listener.getResult().get().getErrors().iterator().next().getMessage()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test object creation - */ - @Test - public void testCompleted() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - BarrierInputBuilder barrierBuilder = new BarrierInputBuilder(); - BarrierInput barrierInput = barrierBuilder.build(); - listener.completed(barrierInput); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); - try { - Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test object creation - */ - @Test - public void testOperationSuccessful() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - listener.operationSuccessful(); - ResponseExpectedRpcListener present = responseCache.getIfPresent(key); - Assert.assertEquals(present, listener); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class ResponseExpectedRpcListenerTest { + + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + private static final int RPC_RESPONSE_EXPIRATION = 1; + private Cache> responseCache = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", null, key); + } + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation2() { + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); + } + + /** + * Test object creation + */ + @Test + public void testDiscard() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.discard(); + RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", + ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); + try { + Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), + listener.getResult().get().getErrors().iterator().next().getMessage()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testCompleted() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + BarrierInputBuilder barrierBuilder = new BarrierInputBuilder(); + BarrierInput barrierInput = barrierBuilder.build(); + listener.completed(barrierInput); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testOperationSuccessful() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.operationSuccessful(); + ResponseExpectedRpcListener present = responseCache.getIfPresent(key); + Assert.assertEquals(present, listener); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java index d5a7499c..fff2ea02 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import io.netty.util.concurrent.Future; - -import java.util.Collections; -import java.util.concurrent.ExecutionException; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.util.concurrent.SettableFuture; - -/** - * @author michal.polkorab - * - */ -public class SimpleRpcListenerTest { - - @Mock Future future; - - /** - * Initializes mocks - */ - @Before - public void startUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test SimpleRpcListener creation - */ - @Test - public void test() { - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - Assert.assertEquals("Wrong message", "MESSAGE", listener.takeMessage()); - Assert.assertEquals("Wrong message", listener, listener.takeListener()); - } - - /** - * Test rpc success - */ - @Test - public void testSuccessfulRpc() { - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationSuccessful(); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); - try { - Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test rpc success - */ - @Test - public void testOperationComplete() { - when(future.isSuccess()).thenReturn(false); - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationComplete(future); - verify(future, times(1)).cause(); - try { - Assert.assertEquals("Wrong result", 1, listener.getResult().get().getErrors().size()); - } catch (InterruptedException | ExecutionException e) { - Assert.fail(); - } - } - - /** - * Test rpc success - */ - @Test - public void testOperationComplete2() { - when(future.isSuccess()).thenReturn(true); - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationComplete(future); - verify(future, times(0)).cause(); - try { - Assert.assertEquals("Wrong result", 0, listener.getResult().get().getErrors().size()); - Assert.assertEquals("Wrong result", true, listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - Assert.fail(); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.util.concurrent.Future; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class SimpleRpcListenerTest { + + @Mock Future future; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test SimpleRpcListener creation + */ + @Test + public void test() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + Assert.assertEquals("Wrong message", "MESSAGE", listener.takeMessage()); + Assert.assertEquals("Wrong message", listener, listener.takeListener()); + } + + /** + * Test rpc success + */ + @Test + public void testSuccessfulRpc() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationSuccessful(); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete() { + when(future.isSuccess()).thenReturn(false); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(1)).cause(); + try { + Assert.assertEquals("Wrong result", 1, listener.getResult().get().getErrors().size()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete2() { + when(future.isSuccess()).thenReturn(true); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(0)).cause(); + try { + Assert.assertEquals("Wrong result", 0, listener.getResult().get().getErrors().size()); + Assert.assertEquals("Wrong result", true, listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 0c792fa2..8fa76e80 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -1,182 +1,182 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; -import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @author michal.polkorab - * - */ -public class SwitchConnectionProviderImplTest { - - @Mock SwitchConnectionHandler handler; - - private static final int SWITCH_IDLE_TIMEOUT = 2000; - private static final int WAIT_TIMEOUT = 2000; - private InetAddress startupAddress; - private TlsConfiguration tlsConfiguration; - private SwitchConnectionProviderImpl provider; - private ConnectionConfigurationImpl config; - - /** - * Creates new {@link SwitchConnectionProvider} instance for each test - * @param protocol communication protocol - */ - public void startUp(TransportProtocol protocol) { - MockitoAnnotations.initMocks(this); - config = null; - if (protocol != null) { - createConfig(protocol); - } - provider = new SwitchConnectionProviderImpl(); - } - - private void createConfig(TransportProtocol protocol) { - try { - startupAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - tlsConfiguration = null; - if (protocol.equals(TransportProtocol.TLS)) { - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, - "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, - "/selfSignedController", PathType.CLASSPATH) ; - } - config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); - config.setTransferProtocol(protocol); - } - - /** - * Tests provider startup - without configuration and {@link SwitchConnectionHandler} - */ - @Test - public void testStartup1() { - provider = new SwitchConnectionProviderImpl(); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); - } - } - - /** - * Tests provider startup - without configuration - */ - @Test - public void testStartup2() { - startUp(null); - provider.setSwitchConnectionHandler(handler); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); - } - } - - /** - * Tests provider startup - without {@link SwitchConnectionHandler} - */ - @Test - public void testStartup3() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.IllegalStateException:" - + " SwitchConnectionHandler is not set", e.getMessage()); - } - } - - /** - * Tests correct provider startup - over TCP - */ - @Test - public void testStartup4() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider startup - over TLS - */ - @Test - public void testStartup5() { - startUp(TransportProtocol.TLS); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider startup - over UDP - */ - @Test - public void testStartup6() { - startUp(TransportProtocol.UDP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider shutdown - */ - @Test - public void testShutdown() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - Assert.assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); - } - } - +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @author michal.polkorab + * + */ +public class SwitchConnectionProviderImplTest { + + @Mock SwitchConnectionHandler handler; + + private static final int SWITCH_IDLE_TIMEOUT = 2000; + private static final int WAIT_TIMEOUT = 2000; + private InetAddress startupAddress; + private TlsConfiguration tlsConfiguration; + private SwitchConnectionProviderImpl provider; + private ConnectionConfigurationImpl config; + + /** + * Creates new {@link SwitchConnectionProvider} instance for each test + * @param protocol communication protocol + */ + public void startUp(TransportProtocol protocol) { + MockitoAnnotations.initMocks(this); + config = null; + if (protocol != null) { + createConfig(protocol); + } + provider = new SwitchConnectionProviderImpl(); + } + + private void createConfig(TransportProtocol protocol) { + try { + startupAddress = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + tlsConfiguration = null; + if (protocol.equals(TransportProtocol.TLS)) { + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; + } + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config.setTransferProtocol(protocol); + } + + /** + * Tests provider startup - without configuration and {@link SwitchConnectionHandler} + */ + @Test + public void testStartup1() { + provider = new SwitchConnectionProviderImpl(); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without configuration + */ + @Test + public void testStartup2() { + startUp(null); + provider.setSwitchConnectionHandler(handler); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without {@link SwitchConnectionHandler} + */ + @Test + public void testStartup3() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.IllegalStateException:" + + " SwitchConnectionHandler is not set", e.getMessage()); + } + } + + /** + * Tests correct provider startup - over TCP + */ + @Test + public void testStartup4() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over TLS + */ + @Test + public void testStartup5() { + startUp(TransportProtocol.TLS); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over UDP + */ + @Test + public void testStartup6() { + startUp(TransportProtocol.UDP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider shutdown + */ + @Test + public void testShutdown() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + Assert.assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + } + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java index d456332b..965e299b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import static org.junit.Assert.assertEquals; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class DeserializationFactoryTest { - - /** - * Test deserializer lookup & deserialization - */ - @Test - public void test() { - DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); - registry.init(); - DeserializationFactory factory = new DeserializationFactory(); - factory.setRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeByte(0); - buffer.writeShort(EncodeConstants.OFHEADER_SIZE); - buffer.writeInt(1234); - factory.deserialize(buffer, EncodeConstants.OF13_VERSION_ID); - assertEquals("Deserialization failed", 0, buffer.readableBytes()); - } - - /** - * Test deserializer lookup & deserialization - */ - @Test(expected=NullPointerException.class) - public void testNotExistingDeserializer() { - DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); - registry.init(); - DeserializationFactory factory = new DeserializationFactory(); - factory.setRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeByte(0); - buffer.writeShort(EncodeConstants.OFHEADER_SIZE); - buffer.writeInt(1234); - factory.deserialize(buffer, (short) 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class DeserializationFactoryTest { + + /** + * Test deserializer lookup & deserialization + */ + @Test + public void test() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, EncodeConstants.OF13_VERSION_ID); + assertEquals("Deserialization failed", 0, buffer.readableBytes()); + } + + /** + * Test deserializer lookup & deserialization + */ + @Test(expected=NullPointerException.class) + public void testNotExistingDeserializer() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, (short) 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index fb65cee6..65395c16 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassMapInitializerTest { - - private Map> messageClassMap; - - /** - * Tests correct map initialization - */ - @Test - public void test() { - messageClassMap = new HashMap<>(); - TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); - short version = EncodeConstants.OF10_VERSION_ID; - assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); - assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); - assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); - assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); - assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); - assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); - assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); - assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); - assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); - assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); - assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); - assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); - assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); - version = EncodeConstants.OF13_VERSION_ID; - assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); - assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); - assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); - assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); - assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); - assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); - assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); - assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); - assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); - assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); - assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 19))); - assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); - assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); - assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); - assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassMapInitializerTest { + + private Map> messageClassMap; + + /** + * Tests correct map initialization + */ + @Test + public void test() { + messageClassMap = new HashMap<>(); + TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + version = EncodeConstants.OF13_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); + assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); + assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java index ac167642..b05730f2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterMessageFactoryTest { - - @Mock DeserializerRegistry registry; - @Mock OFDeserializer deserializer; - @Mock ExperimenterMessage message; - - /** - * Initializes mocks - */ - @Before - public void startUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test deserializer lookup correctness - */ - @Test - public void test() { - when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); - when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); - - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); - ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); - factory.injectDeserializerRegistry(registry); - ExperimenterMessage deserializedMessage = factory.deserialize(buffer); - Assert.assertEquals("Wrong return value", message, deserializedMessage); - Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock OFDeserializer deserializer; + @Mock ExperimenterMessage message; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test deserializer lookup correctness + */ + @Test + public void test() { + when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); + when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); + + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); + ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); + factory.injectDeserializerRegistry(registry); + ExperimenterMessage deserializedMessage = factory.deserialize(buffer); + Assert.assertEquals("Wrong return value", message, deserializedMessage); + Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index d5a1c779..0e8813ea 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -1,317 +1,317 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsReplyMessageFactoryTest { - - private OFDeserializer statsFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - statsFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class)); - } - - /** - * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization - */ - @Test - public void testDesc() { - final int DESC_STR_LEN = 256; - final int SERIAL_NUM_LEN = 32; - ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); - - String mfrDesc = "Manufacturer description"; - byte[] mfrDescBytes = new byte[256]; - mfrDescBytes = mfrDesc.getBytes(); - bb.writeBytes(mfrDescBytes); - bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); - - String hwDesc = "Hardware description"; - byte[] hwDescBytes = new byte[256]; - hwDescBytes = hwDesc.getBytes(); - bb.writeBytes(hwDescBytes); - bb.writeZero(DESC_STR_LEN - hwDescBytes.length); - - String swDesc = "Software description"; - byte[] swDescBytes = new byte[256]; - swDescBytes = swDesc.getBytes(); - bb.writeBytes(swDescBytes); - bb.writeZero(DESC_STR_LEN - swDescBytes.length); - - String serialNum = "SN0123456789"; - byte[] serialNumBytes = new byte[32]; - serialNumBytes = serialNum.getBytes(); - bb.writeBytes(serialNumBytes); - bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); - - String dpDesc = "switch3 in room 3120"; - byte[] dpDescBytes = new byte[256]; - dpDescBytes = dpDesc.getBytes(); - bb.writeBytes(dpDescBytes); - bb.writeZero(DESC_STR_LEN - dpDescBytes.length); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyDesc message = messageCase.getMultipartReplyDesc(); - Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc()); - Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc()); - Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc()); - Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum()); - Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization - */ - @Test - public void testFlow() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 68 01 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " - + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " - + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong tableId", 1, message.getFlowStats().get(0).getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 2, message.getFlowStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 3, message.getFlowStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); - Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getFlowStats().get(0).getCookie()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getFlowStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), - message.getFlowStats().get(0).getByteCount()); - Action action1 = message.getFlowStats().get(0).getAction().get(0); - Assert.assertEquals("Wrong action type", Output.class, action1.getType()); - Assert.assertEquals("Wrong action port", 1, action1.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong action port", 2, action1.getAugmentation(MaxLengthAction.class) - .getMaxLength().intValue()); - Action action2 = message.getFlowStats().get(0).getAction().get(1); - Assert.assertEquals("Wrong action type", SetVlanVid.class, action2.getType()); - Assert.assertEquals("Wrong action port", 3, action2.getAugmentation(VlanVidAction.class) - .getVlanVid().intValue()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization - */ - @Test - public void testAggregate() { - ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " - + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packet-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getPacketCount()); - Assert.assertEquals("Wrong byte-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), - message.getByteCount()); - Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization - */ - @Test - public void testTable() { - ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " - + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTable message = messageCase.getMultipartReplyTable(); - Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); - Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName()); - Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, - false, false, false), message.getTableStats().get(0).getWildcards()); - Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue()); - Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); - Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); - Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), - message.getTableStats().get(0).getMatchedCount()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Port) for correct deserialization - */ - @Test - public void testPort() { - ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 " - + "00 FF 00 00 00 00 00 00 " - + "FF 01 01 01 01 01 01 01 FF 02 02 02 02 02 02 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); - Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), - message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getCollisions()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization - */ - @Test - public void testQueue() { - ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " - + "00 FF 00 00 00 00 00 10 " - + "FF 02 03 02 03 02 03 02 " - + "FF 02 02 02 02 02 02 02 " - + "FF 02 03 02 03 02 03 02"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); - Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), - message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getQueueStats().get(0).getTxErrors()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsReplyMessageFactoryTest { + + private OFDeserializer statsFactory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + statsFactory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class)); + } + + /** + * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization + */ + @Test + public void testDesc() { + final int DESC_STR_LEN = 256; + final int SERIAL_NUM_LEN = 32; + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); + + String mfrDesc = "Manufacturer description"; + byte[] mfrDescBytes = new byte[256]; + mfrDescBytes = mfrDesc.getBytes(); + bb.writeBytes(mfrDescBytes); + bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); + + String hwDesc = "Hardware description"; + byte[] hwDescBytes = new byte[256]; + hwDescBytes = hwDesc.getBytes(); + bb.writeBytes(hwDescBytes); + bb.writeZero(DESC_STR_LEN - hwDescBytes.length); + + String swDesc = "Software description"; + byte[] swDescBytes = new byte[256]; + swDescBytes = swDesc.getBytes(); + bb.writeBytes(swDescBytes); + bb.writeZero(DESC_STR_LEN - swDescBytes.length); + + String serialNum = "SN0123456789"; + byte[] serialNumBytes = new byte[32]; + serialNumBytes = serialNum.getBytes(); + bb.writeBytes(serialNumBytes); + bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); + + String dpDesc = "switch3 in room 3120"; + byte[] dpDescBytes = new byte[256]; + dpDescBytes = dpDesc.getBytes(); + bb.writeBytes(dpDescBytes); + bb.writeZero(DESC_STR_LEN - dpDescBytes.length); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyDesc message = messageCase.getMultipartReplyDesc(); + Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc()); + Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc()); + Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc()); + Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum()); + Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization + */ + @Test + public void testFlow() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 68 01 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " + + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " + + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong tableId", 1, message.getFlowStats().get(0).getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 2, message.getFlowStats().get(0).getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 3, message.getFlowStats().get(0).getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); + Assert.assertEquals("Wrong cookie", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getFlowStats().get(0).getCookie()); + Assert.assertEquals("Wrong packetCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getFlowStats().get(0).getPacketCount()); + Assert.assertEquals("Wrong byteCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + message.getFlowStats().get(0).getByteCount()); + Action action1 = message.getFlowStats().get(0).getAction().get(0); + Assert.assertEquals("Wrong action type", Output.class, action1.getType()); + Assert.assertEquals("Wrong action port", 1, action1.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Assert.assertEquals("Wrong action port", 2, action1.getAugmentation(MaxLengthAction.class) + .getMaxLength().intValue()); + Action action2 = message.getFlowStats().get(0).getAction().get(1); + Assert.assertEquals("Wrong action type", SetVlanVid.class, action2.getType()); + Assert.assertEquals("Wrong action port", 3, action2.getAugmentation(VlanVidAction.class) + .getVlanVid().intValue()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization + */ + @Test + public void testAggregate() { + ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " + + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); + Assert.assertEquals("Wrong packet-count", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getPacketCount()); + Assert.assertEquals("Wrong byte-count", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + message.getByteCount()); + Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization + */ + @Test + public void testTable() { + ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + + MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTable message = messageCase.getMultipartReplyTable(); + Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); + Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName()); + Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, + false, false, false), message.getTableStats().get(0).getWildcards()); + Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue()); + Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); + Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); + Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); + Assert.assertEquals("Wrong lookupCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + message.getTableStats().get(0).getLookupCount()); + Assert.assertEquals("Wrong matchedCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), + message.getTableStats().get(0).getMatchedCount()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Port) for correct deserialization + */ + @Test + public void testPort() { + ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 " + + "00 FF 00 00 00 00 00 00 " + + "FF 01 01 01 01 01 01 01 FF 02 02 02 02 02 02 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); + Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); + Assert.assertEquals("Wrong rxPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + message.getPortStats().get(0).getRxPackets()); + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + message.getPortStats().get(0).getTxPackets()); + Assert.assertEquals("Wrong rxBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxBytes()); + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxBytes()); + Assert.assertEquals("Wrong rxDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxDropped()); + Assert.assertEquals("Wrong txDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxDropped()); + Assert.assertEquals("Wrong rxErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxErrors()); + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxErrors()); + Assert.assertEquals("Wrong rxFrameErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxFrameErr()); + Assert.assertEquals("Wrong rxOverErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxOverErr()); + Assert.assertEquals("Wrong rxCrcErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxCrcErr()); + Assert.assertEquals("Wrong collisions", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getCollisions()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization + */ + @Test + public void testQueue() { + ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " + + "00 FF 00 00 00 00 00 10 " + + "FF 02 03 02 03 02 03 02 " + + "FF 02 02 02 02 02 02 02 " + + "FF 02 03 02 03 02 03 02"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); + Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); + Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getQueueStats().get(0).getTxBytes()); + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + message.getQueueStats().get(0).getTxPackets()); + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getQueueStats().get(0).getTxErrors()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java index d293efcb..0c9707ca 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.util.ByteBufUtils; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class VendorMessageFactoryTest { - - @Mock DeserializerRegistry registry; - @Mock ExperimenterMessageFactory deserializer; - - /** - * Tests {@link VendorMessageFactory#deserialize(ByteBuf)} - */ - @Test - public void test() { - Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); - VendorMessageFactory factory = new VendorMessageFactory(); - factory.injectDeserializerRegistry(registry); - factory.deserialize(buffer); - - Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); - Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock ExperimenterMessageFactory deserializer; + + /** + * Tests {@link VendorMessageFactory#deserialize(ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); + VendorMessageFactory factory = new VendorMessageFactory(); + factory.injectDeserializerRegistry(registry); + factory.deserialize(buffer); + + Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java index 6e4de3f9..28fecce1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartReplyExperimenterTest { - - @Mock DeserializerRegistry registry; - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyExperimenter() { - factory.injectDeserializerRegistry(registry); - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " - + "00 00 00 01 00 00 00 02"); // expID, expType - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyExperimenter() { + factory.injectDeserializerRegistry(registry); + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01 00 00 00 02"); // expID, expType + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index ecb206e4..d1c5e35f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -1,136 +1,136 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyFlowTest { - - private OFDeserializer factory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - factory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ - // first flow stat - "00 48 08 00 "+ // length, tableId, padding - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00 "+ - // second flow stat - "00 48 08 00 "+ // length, tableId, padding - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size()); - FlowStats flowStats1 = message.getFlowStats().get(0); - Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); - Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); - Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); - flowStats1 = message.getFlowStats().get(1); - Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); - Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); - Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyFlowTest { + + private OFDeserializer factory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ + // first flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00 "+ + // second flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size()); + FlowStats flowStats1 = message.getFlowStats().get(0); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + flowStats1 = message.getFlowStats().get(1); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java index 906d87fd..5ac385c7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java @@ -1,104 +1,104 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyGroupFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyGroupFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ - "00 00 00 0F "+// types - "00 00 00 0F "+// capabilities - "00 00 00 01 "+// max groups - "00 00 00 02 "+// max groups - "00 00 00 03 "+// max groups - "00 00 00 04 "+// max groups - "0F FF 98 01 "+// actions bitmap (all actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00"// actions bitmap (no actions included) - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyGroupFeaturesCase messageCase = - (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); - Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes()); - Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), - message.getCapabilities()); - Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue()); - Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue()); - Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue()); - Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue()); - Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, - true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3)); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - * (with different group types and capabilities) - */ - @Test - public void testMultipartReplyGroupFeatures2() { - ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ - "00 00 00 00 "+// types - "00 00 00 00 "+// capabilities - "00 00 00 01 "+// max groups - "00 00 00 02 "+// max groups - "00 00 00 03 "+// max groups - "00 00 00 04 "+// max groups - "00 00 00 00 "+// actions bitmap (all actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00"// actions bitmap (no actions included) - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyGroupFeaturesCase messageCase = - (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); - Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes()); - Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), - message.getCapabilities()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyGroupFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyGroupFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 0F "+// types + "00 00 00 0F "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "0F FF 98 01 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), + message.getCapabilities()); + Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue()); + Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue()); + Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue()); + Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue()); + Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, + true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + * (with different group types and capabilities) + */ + @Test + public void testMultipartReplyGroupFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 00 "+// types + "00 00 00 00 "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "00 00 00 00 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), + message.getCapabilities()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java index 208bea19..453c755d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyMeterFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyMeterFeatures(){ - ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ - "00 00 00 0A " + // maxMeter - "00 00 00 06 " + // bandTypes - "00 00 00 0F " + // capabilities - "07 08 00 00" // maxBands, maxColor, padding - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); - Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue()); - Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes()); - Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities()); - Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue()); - Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyMeterFeatures2(){ - ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ - "00 00 00 09 " + // maxMeter - "00 00 00 00 " + // bandTypes - "00 00 00 00 " + // capabilities - "03 04 00 00" // maxBands, maxColor, padding - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); - Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); - Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes()); - Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities()); - Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); - Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyMeterFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 0A " + // maxMeter + "00 00 00 06 " + // bandTypes + "00 00 00 0F " + // capabilities + "07 08 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures2(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 09 " + // maxMeter + "00 00 00 00 " + // bandTypes + "00 00 00 00 " + // capabilities + "03 04 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java index 139ea08a..f397831d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -1,122 +1,122 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyPortDescTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyPortDesc() { - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyPortDesc() { - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + - // first port desc - "00 01 02 03 00 00 00 00 " + // portNo, padding - "08 00 27 00 B0 EB 00 00 " + // mac address, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name - "00 00 00 65 " + //port config - "00 00 00 07 " + //port state - "00 00 00 81 " + //current features - "00 00 FF FF " + //advertised features - "00 00 C1 89 " + //supported features - "00 00 C5 8D " + //peer features - "00 00 00 81 " + //curr speed - "00 00 00 80 " + //max speed - // second port desc - "00 00 00 01 00 00 00 00 " + // portNo, padding - "08 00 27 00 B0 EB 00 00 " + // mac address, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name - "00 00 00 00 " + //port config - "00 00 00 00 " + //port state - "00 00 00 00 " + //current features - "00 00 00 00 " + //advertised features - "00 00 00 00 " + //supported features - "00 00 00 00 " + //peer features - "00 00 00 05 " + //curr speed - "00 00 00 06" //max speed - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); - Ports port = message.getPorts().get(0); - Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); - Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); - Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, - false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures()); - Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, - true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, - false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures()); - Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, - false, false, true, false, false, false, true, true, true), port.getPeerFeatures()); - Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue()); - Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); - port = message.getPorts().get(1); - Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); - Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); - Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getCurrentFeatures()); - Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getSupportedFeatures()); - Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getPeerFeatures()); - Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); - Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyPortDescTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + + // first port desc + "00 01 02 03 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 65 " + //port config + "00 00 00 07 " + //port state + "00 00 00 81 " + //current features + "00 00 FF FF " + //advertised features + "00 00 C1 89 " + //supported features + "00 00 C5 8D " + //peer features + "00 00 00 81 " + //curr speed + "00 00 00 80 " + //max speed + // second port desc + "00 00 00 01 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 00 " + //port config + "00 00 00 00 " + //port state + "00 00 00 00 " + //current features + "00 00 00 00 " + //advertised features + "00 00 00 00 " + //supported features + "00 00 00 00 " + //peer features + "00 00 00 05 " + //curr speed + "00 00 00 06" //max speed + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); + Ports port = message.getPorts().get(0); + Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, + false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, + false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, + false, false, true, false, false, false, true, true, true), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); + port = message.getPorts().get(1); + Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java index 64ad0970..2b223ca2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java @@ -1,187 +1,187 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyTableFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyTableFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyTableFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ - // first table feature - "00 40 01 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ - "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 01 "+// metadata match - "00 00 00 00 00 00 00 02 "+// metadata write - "00 00 00 00 "+// config - "00 00 00 2A "+// max entries - // second table feature - "00 40 02 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" - + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 03 "+// metadata match - "00 00 00 00 00 00 00 04 "+// metadata write - "00 00 00 03 "+// config - "00 00 00 2B" // max entries - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size()); - TableFeatures feature = message.getTableFeatures().get(0); - Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); - feature = message.getTableFeatures().get(1); - Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyTableFeatures2() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ - "00 B0 01 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ - "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 01 "+// metadata match - "00 00 00 00 00 00 00 02 "+// metadata write - "00 00 00 00 "+// config - "00 00 00 2A "+// max entries - "00 00 00 04 00 00 00 00 "+ - "00 01 00 04 00 00 00 00 "+ - "00 02 00 08 01 02 03 04 "+ - "00 03 00 07 05 06 07 00 "+ - "00 04 00 04 00 00 00 00 "+ - "00 05 00 04 00 00 00 00 "+ - "00 06 00 04 00 00 00 00 "+ - "00 07 00 04 00 00 00 00 "+ - "00 08 00 04 00 00 00 00 "+ - "00 0A 00 04 00 00 00 00 "+ - "00 0C 00 04 00 00 00 00 "+ - "00 0D 00 04 00 00 00 00 "+ - "00 0E 00 04 00 00 00 00 "+ - "00 0F 00 04 00 00 00 00" - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size()); - TableFeatures feature = message.getTableFeatures().get(0); - Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); - Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, - feature.getTableFeatureProperties().get(0).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, - feature.getTableFeatureProperties().get(1).getType()); - TableFeatureProperties property = feature.getTableFeatureProperties().get(2); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, - property.getType()); - List tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) - .getNextTableIds(); - Assert.assertEquals("Wrong next table id size", 4, tableIds.size()); - Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue()); - property = feature.getTableFeatureProperties().get(3); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, - property.getType()); - tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) - .getNextTableIds(); - Assert.assertEquals("Wrong next table id size", 3, tableIds.size()); - Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, - feature.getTableFeatureProperties().get(4).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, - feature.getTableFeatureProperties().get(5).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, - feature.getTableFeatureProperties().get(6).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, - feature.getTableFeatureProperties().get(7).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, - feature.getTableFeatureProperties().get(8).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, - feature.getTableFeatureProperties().get(9).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, - feature.getTableFeatureProperties().get(10).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, - feature.getTableFeatureProperties().get(11).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, - feature.getTableFeatureProperties().get(12).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, - feature.getTableFeatureProperties().get(13).getType()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyTableFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + // first table feature + "00 40 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + // second table feature + "00 40 02 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 03 "+// metadata match + "00 00 00 00 00 00 00 04 "+// metadata write + "00 00 00 03 "+// config + "00 00 00 2B" // max entries + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + feature = message.getTableFeatures().get(1); + Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + "00 B0 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + "00 00 00 04 00 00 00 00 "+ + "00 01 00 04 00 00 00 00 "+ + "00 02 00 08 01 02 03 04 "+ + "00 03 00 07 05 06 07 00 "+ + "00 04 00 04 00 00 00 00 "+ + "00 05 00 04 00 00 00 00 "+ + "00 06 00 04 00 00 00 00 "+ + "00 07 00 04 00 00 00 00 "+ + "00 08 00 04 00 00 00 00 "+ + "00 0A 00 04 00 00 00 00 "+ + "00 0C 00 04 00 00 00 00 "+ + "00 0D 00 04 00 00 00 00 "+ + "00 0E 00 04 00 00 00 00 "+ + "00 0F 00 04 00 00 00 00" + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, + feature.getTableFeatureProperties().get(0).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, + feature.getTableFeatureProperties().get(1).getType()); + TableFeatureProperties property = feature.getTableFeatureProperties().get(2); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, + property.getType()); + List tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 4, tableIds.size()); + Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue()); + property = feature.getTableFeatureProperties().get(3); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, + property.getType()); + tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 3, tableIds.size()); + Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, + feature.getTableFeatureProperties().get(4).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, + feature.getTableFeatureProperties().get(5).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, + feature.getTableFeatureProperties().get(6).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, + feature.getTableFeatureProperties().get(7).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, + feature.getTableFeatureProperties().get(8).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, + feature.getTableFeatureProperties().get(9).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, + feature.getTableFeatureProperties().get(10).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, + feature.getTableFeatureProperties().get(11).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, + feature.getTableFeatureProperties().get(12).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, + feature.getTableFeatureProperties().get(13).getType()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java index 6ef4153d..0df462fe 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class OF10StatsReplyExperimenterTest { - - @Mock DeserializerRegistry registry; - - /** - * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation - */ - @Test - public void test() { - OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); - factory.injectDeserializerRegistry(registry); - - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " - + "00 00 00 01"); // expID - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + /** + * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation + */ + @Test + public void test() { + OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); + factory.injectDeserializerRegistry(registry); + + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01"); // expID + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java index dcfbe924..b7a76b42 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class AbstractInstructionDeserializerTest { - - /** - * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different - * instruction types - */ - @Test(expected=IllegalStateException.class) - public void test() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); - GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); - instruction = deserializer.deserializeHeader(buffer); - // exception expected - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class AbstractInstructionDeserializerTest { + + /** + * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different + * instruction types + */ + @Test(expected=IllegalStateException.class) + public void test() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); + GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); + instruction = deserializer.deserializeHeader(buffer); + // exception expected + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java index 49b11872..3b464f39 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrDeserializerTest { - - /** - * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); - - buffer.skipBytes(4); // skip XID - OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", - new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), - entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); - Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrDeserializerTest { + + /** + * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); + + buffer.skipBytes(4); // skip XID + OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", + new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), + entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java index 9b0d1a4d..2c29dce1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelDeserializerTest { - - /** - * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 38 04 00 00 00 02"); - - buffer.skipBytes(4); // skip XID - OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelDeserializerTest { + + /** + * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 38 04 00 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java index 0cf62839..d0983876 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataDeserializerTest { - - /** - * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 04 08 00 00 00 00 00 00 00 03"); - - buffer.skipBytes(4); // skip XID - OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataDeserializerTest { + + /** + * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 04 08 00 00 00 00 00 00 00 03"); + + buffer.skipBytes(4); // skip XID + OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java index e8a379c7..728260e2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosDeserializerTest { - - /** - * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 48 01 00"); - - buffer.skipBytes(4); // skip XID - OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosDeserializerTest { + + /** + * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 48 01 00"); + + buffer.skipBytes(4); // skip XID + OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java index b33c8a26..ab3e125e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidDeserializerTest { - - /** - * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 4A 03 00 00 02"); - - buffer.skipBytes(4); // skip XID - OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidDeserializerTest { + + /** + * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4A 03 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java index a51cc122..e765ba65 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidDeserializerTest { - - /** - * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A"); - - buffer.skipBytes(4); // skip XID - OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 10, - entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, - entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidDeserializerTest { + + /** + * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A"); + + buffer.skipBytes(4); // skip XID + OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 10, + entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + Assert.assertEquals("Wrong entry value", false, + entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java index 28add5c6..3ffbca70 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization; - -import static org.junit.Assert.assertEquals; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class SerializationFactoryTest { - - /** - * Test serializer lookup & serialization - */ - @Test - public void test() { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - SerializationFactory factory = new SerializationFactory(); - factory.setSerializerTable(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - HelloInputBuilder helloBuilder = new HelloInputBuilder(); - helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - helloBuilder.setXid(123456L); - helloBuilder.setElements(null); - factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build()); - assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes()); - } - - /** - * Test serializer not found scenario - */ - @Test(expected=IllegalStateException.class) - public void testNotExistingSerializer() { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - SerializationFactory factory = new SerializationFactory(); - factory.setSerializerTable(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - HelloInputBuilder helloBuilder = new HelloInputBuilder(); - helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - helloBuilder.setXid(123456L); - helloBuilder.setElements(null); - factory.messageToBuffer((short) 0, buffer, helloBuilder.build()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class SerializationFactoryTest { + + /** + * Test serializer lookup & serialization + */ + @Test + public void test() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build()); + assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes()); + } + + /** + * Test serializer not found scenario + */ + @Test(expected=IllegalStateException.class) + public void testNotExistingSerializer() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer((short) 0, buffer, helloBuilder.build()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java index 17b3f7ad..77cc5c32 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -1,129 +1,129 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterInputMessageFactoryTest { - - @Mock SerializerRegistry registry; - @Mock OFSerializer serializer; - private OFSerializer expFactory; - - /** - * Sets up ExperimenterInputMessageFactory - * @param real true if setup should use real registry, false when mock is desired - */ - public void startUp(boolean real) { - MockitoAnnotations.initMocks(this); - expFactory = new ExperimenterInputMessageFactory(); - if (real) { - SerializerRegistry realRegistry = new SerializerRegistryImpl(); - realRegistry.init(); - ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry); - } else { - ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry); - } - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test(expected=IllegalStateException.class) - public void testV10Real() throws Exception { - startUp(true); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test(expected=IllegalStateException.class) - public void testV13Real() throws Exception { - startUp(true); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test - public void testV10() throws Exception { - startUp(false); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - Mockito.when(registry.getSerializer( - (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test - public void testV13() throws Exception { - startUp(false); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - Mockito.when(registry.getSerializer( - (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock OFSerializer serializer; + private OFSerializer expFactory; + + /** + * Sets up ExperimenterInputMessageFactory + * @param real true if setup should use real registry, false when mock is desired + */ + public void startUp(boolean real) { + MockitoAnnotations.initMocks(this); + expFactory = new ExperimenterInputMessageFactory(); + if (real) { + SerializerRegistry realRegistry = new SerializerRegistryImpl(); + realRegistry.init(); + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry); + } else { + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry); + } + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV10Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV13Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV10() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV13() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 9e38a5c6..cfb64acc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -1,303 +1,303 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.factories; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestInputFactoryTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Testing OF10StatsRequestInputFactory (Desc) for correct serialization - * @throws Exception - */ - @Test - public void testDesc() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); - MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); - caseBuilder.setMultipartRequestDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Flow) for correct serialization - * @throws Exception - */ - @Test - public void testFlow() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPFLOW); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); - MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, - true, true, true, true)); - matchBuilder.setNwSrcMask((short) 8); - matchBuilder.setNwDstMask((short) 16); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - flowBuilder.setMatchV10(matchBuilder.build()); - flowBuilder.setTableId((short) 1); - flowBuilder.setOutPort(42L); - caseBuilder.setMultipartRequestFlow(flowBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt()); - Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); - byte[] dlSrc = new byte[6]; - out.readBytes(dlSrc); - Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); - byte[] dlDst = new byte[6]; - out.readBytes(dlDst); - Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); - Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); - Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); - Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); - Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); - Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); - Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization - * @throws Exception - */ - @Test - public void testAggregate() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPAGGREGATE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); - MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, - false, false, false, false, false, false)); - matchBuilder.setNwSrcMask((short) 32); - matchBuilder.setNwDstMask((short) 32); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - flowBuilder.setMatchV10(matchBuilder.build()); - flowBuilder.setTableId((short) 42); - flowBuilder.setOutPort(6653L); - caseBuilder.setMultipartRequestFlow(flowBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt()); - Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); - byte[] dlSrc = new byte[6]; - out.readBytes(dlSrc); - Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); - byte[] dlDst = new byte[6]; - out.readBytes(dlDst); - Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); - Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); - Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); - Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); - Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); - Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); - Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Table) for correct serialization - * @throws Exception - */ - @Test - public void testTable() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPTABLE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); - MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); - caseBuilder.setMultipartRequestTable(tableBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Port) for correct serialization - * @throws Exception - */ - @Test - public void testPort() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPPORTSTATS); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); - MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); - portBuilder.setPortNo(15L); - caseBuilder.setMultipartRequestPortStats(portBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 20); - Assert.assertEquals("Wrong type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Queue) for correct serialization - * @throws Exception - */ - @Test - public void testQueue() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPQUEUE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); - MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); - queueBuilder.setPortNo(15L); - queueBuilder.setQueueId(16L); - caseBuilder.setMultipartRequestQueue(queueBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 20); - Assert.assertEquals("Wrong type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestInputFactoryTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Testing OF10StatsRequestInputFactory (Desc) for correct serialization + * @throws Exception + */ + @Test + public void testDesc() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); + caseBuilder.setMultipartRequestDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Flow) for correct serialization + * @throws Exception + */ + @Test + public void testFlow() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPFLOW); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, + true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + flowBuilder.setMatchV10(matchBuilder.build()); + flowBuilder.setTableId((short) 1); + flowBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt()); + Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + out.readBytes(dlSrc); + Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + out.readBytes(dlDst); + Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); + Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); + Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); + Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); + Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); + Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization + * @throws Exception + */ + @Test + public void testAggregate() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPAGGREGATE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, + false, false, false, false, false, false)); + matchBuilder.setNwSrcMask((short) 32); + matchBuilder.setNwDstMask((short) 32); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + flowBuilder.setMatchV10(matchBuilder.build()); + flowBuilder.setTableId((short) 42); + flowBuilder.setOutPort(6653L); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt()); + Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + out.readBytes(dlSrc); + Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + out.readBytes(dlDst); + Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); + Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); + Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); + Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); + Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); + Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Table) for correct serialization + * @throws Exception + */ + @Test + public void testTable() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPTABLE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); + caseBuilder.setMultipartRequestTable(tableBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Port) for correct serialization + * @throws Exception + */ + @Test + public void testPort() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPPORTSTATS); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); + portBuilder.setPortNo(15L); + caseBuilder.setMultipartRequestPortStats(portBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 20); + Assert.assertEquals("Wrong type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Queue) for correct serialization + * @throws Exception + */ + @Test + public void testQueue() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPQUEUE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); + queueBuilder.setPortNo(15L); + queueBuilder.setQueueId(16L); + caseBuilder.setMultipartRequestQueue(queueBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 20); + Assert.assertEquals("Wrong type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java index df1c3455..c14e4dc3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class VendorInputMessageFactoryTest { - - @Mock SerializerRegistry registry; - @Mock ExperimenterInputMessageFactory serializer; - - /** - * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} - */ - @Test - public void test() { - Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) - .thenReturn(serializer); - VendorInputMessageFactory factory = new VendorInputMessageFactory(); - factory.injectSerializerRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(12345L); - builder.setExperimenter(new ExperimenterId(42L)); - builder.setExpType(84L); - ExperimenterInput experimenterInput = builder.build(); - - factory.serialize(experimenterInput, buffer); - Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock ExperimenterInputMessageFactory serializer; + + /** + * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) + .thenReturn(serializer); + VendorInputMessageFactory factory = new VendorInputMessageFactory(); + factory.injectSerializerRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(12345L); + builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(84L); + ExperimenterInput experimenterInput = builder.build(); + + factory.serialize(experimenterInput, buffer); + Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java index b5b93b89..4b476037 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartRequestExperimenterTest { - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) - .thenReturn(serializer); - MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); - multipartFactory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java index db068d71..b747e3e7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestGroupDescTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - GroupDesc case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPGROUPDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); - MultipartRequestGroupDescBuilder descBuilder = new MultipartRequestGroupDescBuilder(); - descBuilder.setEmpty(true); - caseBuilder.setMultipartRequestGroupDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); + MultipartRequestGroupDescBuilder descBuilder = new MultipartRequestGroupDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java index 2097974a..ff0012e0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestGroupFeaturesTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - GroupFeatures case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPGROUPFEATURES); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); - MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder(); - featuresBuilder.setEmpty(true); - caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); + MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java index 3eb74b1b..7f04ba49 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestMeterFeaturesTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - MeterFeatures case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPMETERFEATURES); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); - MultipartRequestMeterFeaturesBuilder featuresBuilder = new MultipartRequestMeterFeaturesBuilder(); - featuresBuilder.setEmpty(true); - caseBuilder.setMultipartRequestMeterFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestMeterFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - MeterFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPMETERFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); + MultipartRequestMeterFeaturesBuilder featuresBuilder = new MultipartRequestMeterFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestMeterFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java index 2172e822..fd8365d2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestPortDescTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - PortDesc case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPPORTDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); - MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder(); - descBuilder.setEmpty(true); - caseBuilder.setMultipartRequestPortDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 13, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestPortDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - PortDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPPORTDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); + MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestPortDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index 86f0fef4..6ece7679 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -1,467 +1,467 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartRequestTableFeaturesTest { - - private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = - MultipartRequestInputFactoryTest.PADDING_IN_MULTIPART_REQUEST_MESSAGE; - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - Mockito.when(mockRegistry.getSerializer((MessageTypeKey)Matchers.any())) - .thenReturn(serializer); - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * @throws Exception - * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO - */ - @Test - public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.forValue(12)); - builder.setFlags(new MultipartRequestFlags(true)); - MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); - MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); - List tableFeaturesList = new ArrayList<>(); - TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(65L); - List properties = new ArrayList<>(); - TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); - NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = - new NextTableRelatedTableFeaturePropertyBuilder(); - List nextIds = new ArrayList<>(); - nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); - nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); - nextPropBuilder.setNextTableIds(nextIds); - propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); - nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); - nextIds = new ArrayList<>(); - nextPropBuilder.setNextTableIds(nextIds); - propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); - InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = - new InstructionRelatedTableFeaturePropertyBuilder(); - List insIds = new ArrayList<>(); - InstructionBuilder insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); - insIds.add(insBuilder.build()); - insPropBuilder.setInstruction(insIds); - propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); - insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); - insIds = new ArrayList<>(); - insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteMetadata.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(ApplyActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(Meter.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(ClearActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); - insIds.add(insBuilder.build()); - insPropBuilder.setInstruction(insIds); - propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(67L); - properties = new ArrayList<>(); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); - ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - actions.add(actionBuilder.build()); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); - OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(InPhyPort.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(InPort.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(IpProto.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(IpEcn.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - featuresBuilder.setTableFeatures(tableFeaturesList); - caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 296); - Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); - Assert.assertEquals("Wrong length", 120, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); - Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); - Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * @throws Exception - * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO - */ - @Test - public void testMultipartRequestTableFeaturesExperimenter() throws Exception { - MultipartRequestInputFactory factory = new MultipartRequestInputFactory(); - factory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.forValue(12)); - builder.setFlags(new MultipartRequestFlags(true)); - MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); - MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); - List tableFeaturesList = new ArrayList<>(); - TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(65L); - List properties = new ArrayList<>(); - TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); - ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(new ExperimenterId(42L)); - propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); - expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(new ExperimenterId(43L)); - propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - featuresBuilder.setTableFeatures(tableFeaturesList); - caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - factory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 80); - Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); - Assert.assertEquals("Wrong length", 64, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); - Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), - Matchers.any(ByteBuf.class)); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestTableFeaturesTest { + + private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = + MultipartRequestInputFactoryTest.PADDING_IN_MULTIPART_REQUEST_MESSAGE; + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + Mockito.when(mockRegistry.getSerializer((MessageTypeKey)Matchers.any())) + .thenReturn(serializer); + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * @throws Exception + * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO + */ + @Test + public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.forValue(12)); + builder.setFlags(new MultipartRequestFlags(true)); + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); + NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = + new NextTableRelatedTableFeaturePropertyBuilder(); + List nextIds = new ArrayList<>(); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); + nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + nextIds = new ArrayList<>(); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); + InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = + new InstructionRelatedTableFeaturePropertyBuilder(); + List insIds = new ArrayList<>(); + InstructionBuilder insBuilder = new InstructionBuilder(); + insBuilder.setType(WriteActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(GotoTable.class); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); + insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + insIds = new ArrayList<>(); + insBuilder = new InstructionBuilder(); + insBuilder.setType(WriteMetadata.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(ApplyActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(Meter.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(ClearActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(GotoTable.class); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(67L); + properties = new ArrayList<>(); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); + ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + actions.add(actionBuilder.build()); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); + OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpProto.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 296); + Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + Assert.assertEquals("Wrong length", 120, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * @throws Exception + * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO + */ + @Test + public void testMultipartRequestTableFeaturesExperimenter() throws Exception { + MultipartRequestInputFactory factory = new MultipartRequestInputFactory(); + factory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.forValue(12)); + builder.setFlags(new MultipartRequestFlags(true)); + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); + ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(42L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); + expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(43L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 80); + Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + Assert.assertEquals("Wrong length", 64, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); + Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), + Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java index 8ffcdd7d..724b55e5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestTableTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - Table case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPTABLE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); - MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder(); - tablesBuilder.setEmpty(true); - caseBuilder.setMultipartRequestTable(tablesBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestTableTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - Table case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPTABLE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder(); + tablesBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tablesBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 448c5298..2831e6d5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestAggregateTest { - - private SerializerRegistry registry; - private OFSerializer statsFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - statsFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link OF10StatsRequestInputFactory} for correct serialization - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPAGGREGATE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); - MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, - true, true, true, true)); - matchBuilder.setNwSrcMask((short) 8); - matchBuilder.setNwDstMask((short) 16); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - aggBuilder.setMatchV10(matchBuilder.build()); - aggBuilder.setTableId((short) 5); - aggBuilder.setOutPort(42L); - caseBuilder.setMultipartRequestAggregate(aggBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - statsFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(40); // skip match check - Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestAggregateTest { + + private SerializerRegistry registry; + private OFSerializer statsFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + statsFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link OF10StatsRequestInputFactory} for correct serialization + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPAGGREGATE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, + true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + aggBuilder.setMatchV10(matchBuilder.build()); + aggBuilder.setTableId((short) 5); + aggBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestAggregate(aggBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + statsFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(40); // skip match check + Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java index b26d4ffe..00a76683 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class OF10StatsRequestExperimenterTest { - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) - .thenReturn(serializer); - OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); - multipartFactory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.factories.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java index 78b15e9e..1f1c8bf8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpSerializerTest { - - OxmArpOpSerializer serializer = new OxmArpOpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1402, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareArpOpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_OP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { - MatchEntriesBuilder builder = prepareArpOpHeader(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(value); - builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpOp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpSerializerTest { + + OxmArpOpSerializer serializer = new OxmArpOpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1402, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_OP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); + opBuilder.setOpCode(value); + builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpOp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java index c23b9dbd..b0dc9276 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaSerializerTest { - - OxmArpThaSerializer serializer = new OxmArpThaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpTha.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaSerializerTest { + + OxmArpThaSerializer serializer = new OxmArpThaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java index 7af95a1b..83d6afe7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaSerializerTest { - - OxmArpSpaSerializer serializer = new OxmArpSpaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SPA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpSpa.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaSerializerTest { + + OxmArpSpaSerializer serializer = new OxmArpSpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java index 714d6973..cc0f5d4c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaSerializerTest { - - OxmArpShaSerializer serializer = new OxmArpShaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpSha.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaSerializerTest { + + OxmArpShaSerializer serializer = new OxmArpShaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java index 8a68a4c4..90b51395 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaSerializerTest { - - OxmArpTpaSerializer serializer = new OxmArpTpaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_TPA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpTpa.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaSerializerTest { + + OxmArpTpaSerializer serializer = new OxmArpTpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_TPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java index 3f0d6837..3a34fdde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstSerializerTest { - - OxmEthDstSerializer serializer = new OxmEthDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstSerializerTest { + + OxmEthDstSerializer serializer = new OxmEthDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java index 4aed8e13..984899c1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcSerializerTest { - - OxmEthSrcSerializer serializer = new OxmEthSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcSerializerTest { + + OxmEthSrcSerializer serializer = new OxmEthSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java index 23f32491..ae82abc9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java @@ -1,111 +1,111 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeSerializerTest { - - OxmEthTypeSerializer serializer = new OxmEthTypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 65535, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); - EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); - typeBuilder.setEthType(new EtherType(type)); - builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthType.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeSerializerTest { + + OxmEthTypeSerializer serializer = new OxmEthTypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 65535, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); + typeBuilder.setEthType(new EtherType(type)); + builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthType.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java index 69dbad6c..ec559978 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeSerializerTest { - - OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 200, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Code(value); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv4Code.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeSerializerTest { + + OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 200, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Code(value); + builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java index 3b9d2109..1c0c08ba 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeSerializerTest { - - OxmIcmpv4TypeSerializer serializer = new OxmIcmpv4TypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 128, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Type(value); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv4Type.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeSerializerTest { + + OxmIcmpv4TypeSerializer serializer = new OxmIcmpv4TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 128, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Type(value); + builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java index ed3089c0..f4525441 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeSerializerTest { - - OxmIcmpv6CodeSerializer serializer = new OxmIcmpv6CodeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 101, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_CODE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Code(value); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv6Code.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_CODE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeSerializerTest { + + OxmIcmpv6CodeSerializer serializer = new OxmIcmpv6CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 101, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Code(value); + builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java index 2c2a60ea..1c4240ad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeSerializerTest { - - OxmIcmpv6TypeSerializer serializer = new OxmIcmpv6TypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 123, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Type(value); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv6Type.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeSerializerTest { + + OxmIcmpv6TypeSerializer serializer = new OxmIcmpv6TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Type(value); + builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java index 34d9a9f2..0373589c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpSerializerTest { - - OxmIpDscpSerializer serializer = new OxmIpDscpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 58, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IP_DSCP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp(value)); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(IpDscp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IP_DSCP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpSerializerTest { + + OxmIpDscpSerializer serializer = new OxmIpDscpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 58, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_DSCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp(value)); + builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpDscp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_DSCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java index fbeb425a..2672e807 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoSerializerTest { - - OxmIpProtoSerializer serializer = new OxmIpProtoSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry((short) 123); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 123, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IP_PROTO, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(short value) { - MatchEntriesBuilder builder = prepareHeader(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); - protoBuilder.setProtocolNumber(value); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(IpProto.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IP_PROTO, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoSerializerTest { + + OxmIpProtoSerializer serializer = new OxmIpProtoSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_PROTO, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(short value) { + MatchEntriesBuilder builder = prepareHeader(false); + ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + protoBuilder.setProtocolNumber(value); + builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpProto.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_PROTO, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java index 00c3dc87..69499578 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstSerializerTest { - - OxmIpv4DstSerializer serializer = new OxmIpv4DstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv4Dst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstSerializerTest { + + OxmIpv4DstSerializer serializer = new OxmIpv4DstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Dst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java index 5b2834b9..69866caa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcSerializerTest { - - OxmIpv4SrcSerializer serializer = new OxmIpv4SrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv4Src.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcSerializerTest { + + OxmIpv4SrcSerializer serializer = new OxmIpv4SrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Src.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java index 1983b1d9..0924f100 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrSerializerTest { - - OxmIpv6ExtHdrSerializer serializer = new OxmIpv6ExtHdrSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, - new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 358, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, - new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 153, buffer.readUnsignedShort()); - byte[] tmp = new byte[2]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_EXTHDR, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(flags); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6Exthdr.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_EXTHDR, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrSerializerTest { + + OxmIpv6ExtHdrSerializer serializer = new OxmIpv6ExtHdrSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, + new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 358, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, + new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 153, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_EXTHDR, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + pseudoBuilder.setPseudoField(flags); + builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6Exthdr.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_EXTHDR, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java index a3e4ff63..52df5db1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -1,120 +1,120 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllSerializerTest { - - OxmIpv6NdSllSerializer serializer = new OxmIpv6NdSllSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_SLL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6NdSll.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_SLL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllSerializerTest { + + OxmIpv6NdSllSerializer serializer = new OxmIpv6NdSllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_SLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdSll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_SLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java index 017652d9..6c6e8d31 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -1,120 +1,120 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllSerializerTest { - - OxmIpv6NdTllSerializer serializer = new OxmIpv6NdTllSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_TLL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6NdTll.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_TLL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllSerializerTest { + + OxmIpv6NdTllSerializer serializer = new OxmIpv6NdTllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_TLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdTll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_TLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java index e8e53f17..fbe202dc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataSerializerTest { - - OxmMetadataSerializer serializer = new OxmMetadataSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.METADATA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Metadata.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.METADATA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataSerializerTest { + + OxmMetadataSerializer serializer = new OxmMetadataSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.METADATA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Metadata.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.METADATA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java index 27c5d504..6c22ec4a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosSerializerTest { - - OxmMplsBosSerializer serializer = new OxmMplsBosSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_BOS, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(bos); - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsBos.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_BOS, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosSerializerTest { + + OxmMplsBosSerializer serializer = new OxmMplsBosSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_BOS, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + bosBuilder.setBos(bos); + builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsBos.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_BOS, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java index 77e07f8a..c20890b9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelSerializerTest { - - OxmMplsLabelSerializer serializer = new OxmMplsLabelSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 168535, buffer.readUnsignedInt()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_LABEL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(label); - builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsLabel.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelSerializerTest { + + OxmMplsLabelSerializer serializer = new OxmMplsLabelSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 168535, buffer.readUnsignedInt()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_LABEL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); + labelBuilder.setMplsLabel(label); + builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsLabel.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java index 8a387b6c..d851b755 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcSerializerTest { - - OxmMplsTcSerializer serializer = new OxmMplsTcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 16, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_TC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc(value); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsTc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcSerializerTest { + + OxmMplsTcSerializer serializer = new OxmMplsTcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 16, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_TC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc(value); + builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsTc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java index 974ecb76..f2cbf897 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidSerializerTest { - - OxmPbbIsidSerializer serializer = new OxmPbbIsidSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 12345, buffer.readUnsignedMedium()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 6789, buffer.readUnsignedMedium()); - byte[] tmp = new byte[3]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.PBB_ISID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { - MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(value); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(PbbIsid.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidSerializerTest { + + OxmPbbIsidSerializer serializer = new OxmPbbIsidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 12345, buffer.readUnsignedMedium()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 6789, buffer.readUnsignedMedium()); + byte[] tmp = new byte[3]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.PBB_ISID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { + MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + isidBuilder.setIsid(value); + builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(PbbIsid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java index 606696c8..e56c5c0d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstSerializerTest { - - OxmSctpDstSerializer serializer = new OxmSctpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(SctpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstSerializerTest { + + OxmSctpDstSerializer serializer = new OxmSctpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java index a28c60fe..6c3890c4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcSerializerTest { - - OxmSctpSrcSerializer serializer = new OxmSctpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(SctpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcSerializerTest { + + OxmSctpSrcSerializer serializer = new OxmSctpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java index fb560554..b912aed3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstSerializerTest { - - OxmTcpDstSerializer serializer = new OxmTcpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TcpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstSerializerTest { + + OxmTcpDstSerializer serializer = new OxmTcpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java index 9e532640..c156b2f5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcSerializerTest { - - OxmTcpSrcSerializer serializer = new OxmTcpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(512); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 512, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TcpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcSerializerTest { + + OxmTcpSrcSerializer serializer = new OxmTcpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(512); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 512, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java index cd4029ec..35f2986e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdSerializerTest { - - OxmTunnelIdSerializer serializer = new OxmTunnelIdSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TUNNEL_ID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TunnelId.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdSerializerTest { + + OxmTunnelIdSerializer serializer = new OxmTunnelIdSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TUNNEL_ID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TunnelId.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java index 4cf55588..1cafb491 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstSerializerTest { - - OxmUdpDstSerializer serializer = new OxmUdpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(2048); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 2048, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(UdpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstSerializerTest { + + OxmUdpDstSerializer serializer = new OxmUdpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(2048); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 2048, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java index 7348307d..d4989830 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcSerializerTest { - - OxmUdpSrcSerializer serializer = new OxmUdpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(1024); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1024, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(UdpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcSerializerTest { + + OxmUdpSrcSerializer serializer = new OxmUdpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(1024); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1024, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java index 0ce0f64a..ba08ad08 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpSerializerTest { - - OxmVlanPcpSerializer serializer = new OxmVlanPcpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 42, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_PCP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp(value); - builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(VlanPcp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpSerializerTest { + + OxmVlanPcpSerializer serializer = new OxmVlanPcpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 42, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_PCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); + pcpBuilder.setVlanPcp(value); + builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanPcp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java index 3e9bf62c..f0ae6dea 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidSerializerTest { - - OxmVlanVidSerializer serializer = new OxmVlanVidSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4596, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 500, buffer.readUnsignedShort()); - byte[] tmp = new byte[2]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_VID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { - MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); - vlanBuilder.setVlanVid(500); - vlanBuilder.setCfiBit(cfiBit); - builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(VlanVid.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidSerializerTest { + + OxmVlanVidSerializer serializer = new OxmVlanVidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4596, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 500, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_VID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { + MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); + vlanBuilder.setVlanVid(500); + vlanBuilder.setCfiBit(cfiBit); + builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanVid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index e0dfb8f7..d7d29d84 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -1,166 +1,166 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class ActionsDeserializerTest { - - private static final Logger LOGGER = LoggerFactory - .getLogger(ActionsDeserializerTest.class); - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing actions deserialization - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00 " - + "00 0B 00 08 00 00 00 00 " - + "00 0C 00 08 00 00 00 00 " - + "00 0F 00 08 03 00 00 00 " - + "00 10 00 08 00 00 00 00 " - + "00 11 00 08 00 04 00 00 " - + "00 12 00 08 00 00 00 00 " - + "00 13 00 08 00 05 00 00 " - + "00 14 00 08 00 06 00 00 " - + "00 15 00 08 00 00 00 07 " - + "00 16 00 08 00 00 00 08 " - + "00 17 00 08 09 00 00 00 " - + "00 18 00 08 00 00 00 00 " - + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " - + "00 1A 00 08 00 0A 00 00 " - + "00 1B 00 08 00 00 00 00"); - - message.skipBytes(4); // skip XID - LOGGER.info("bytes: " + message.readableBytes()); - - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", 1, - actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong action max-length", 2, - actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); - Assert.assertEquals("Wrong action value", 3, - actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); - Assert.assertEquals("Wrong action value", 4, - actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); - Assert.assertEquals("Wrong action value", 5, - actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); - Assert.assertEquals("Wrong action value", 6, - actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); - Assert.assertEquals("Wrong action value", 7, - actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); - Assert.assertEquals("Wrong action value", 8, - actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); - Assert.assertEquals("Wrong action value", 9, - actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); - List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); - Assert.assertEquals("Wrong number of fields", 1, entries.size()); - Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); - Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); - Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); - Assert.assertEquals("Wrong match entry value", 11, - entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); - Assert.assertEquals("Wrong action value", 10, - actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); - Assert.assertTrue("Unread data in message", message.readableBytes() == 0); - } - - /** - * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)} - */ - @Test - public void testDeserializeHeader() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04"); - - message.skipBytes(4); // skip XID - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); - Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); - } -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class ActionsDeserializerTest { + + private static final Logger LOGGER = LoggerFactory + .getLogger(ActionsDeserializerTest.class); + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing actions deserialization + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00 " + + "00 0B 00 08 00 00 00 00 " + + "00 0C 00 08 00 00 00 00 " + + "00 0F 00 08 03 00 00 00 " + + "00 10 00 08 00 00 00 00 " + + "00 11 00 08 00 04 00 00 " + + "00 12 00 08 00 00 00 00 " + + "00 13 00 08 00 05 00 00 " + + "00 14 00 08 00 06 00 00 " + + "00 15 00 08 00 00 00 07 " + + "00 16 00 08 00 00 00 08 " + + "00 17 00 08 09 00 00 00 " + + "00 18 00 08 00 00 00 00 " + + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " + + "00 1A 00 08 00 0A 00 00 " + + "00 1B 00 08 00 00 00 00"); + + message.skipBytes(4); // skip XID + LOGGER.info("bytes: " + message.readableBytes()); + + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertEquals("Wrong action port", 1, + actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong action max-length", 2, + actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); + Assert.assertEquals("Wrong action value", 3, + actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); + Assert.assertEquals("Wrong action value", 4, + actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); + Assert.assertEquals("Wrong action value", 5, + actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); + Assert.assertEquals("Wrong action value", 6, + actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); + Assert.assertEquals("Wrong action value", 7, + actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); + Assert.assertEquals("Wrong action value", 8, + actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); + Assert.assertEquals("Wrong action value", 9, + actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); + List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); + Assert.assertEquals("Wrong number of fields", 1, entries.size()); + Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); + Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); + Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); + Assert.assertEquals("Wrong match entry value", 11, + entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); + Assert.assertEquals("Wrong action value", 10, + actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); + Assert.assertTrue("Unread data in message", message.readableBytes() == 0); + } + + /** + * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)} + */ + @Test + public void testDeserializeHeader() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04"); + + message.skipBytes(4); // skip XID + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); + Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); + Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java index 06bbf1e4..fcae5712 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java @@ -1,135 +1,135 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class CodeKeyMakerFactoryTest { - - /** - * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testMatchEntriesKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 32768, 0), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testExperimenterMatchEntriesKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); - comparationKey.setExperimenterId(1L); - Assert.assertEquals("Wrong key", comparationKey, codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} - */ - @Test - public void testActionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0, null), codeKey); - Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} - */ - @Test - public void testExperimenterActionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 65535, 1L), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} - */ - @Test - public void testInstructionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0, null), codeKey); - Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} - */ - @Test - public void testExperimenterInstructionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 65535, 1L), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class CodeKeyMakerFactoryTest { + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 32768, 0), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); + comparationKey.setExperimenterId(1L); + Assert.assertEquals("Wrong key", comparationKey, codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 112437b5..adb6941e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class InstructionsDeserializerTest { - - - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing instructions translation - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 01 00 08 0A 00 00 00 00 02 00 18 00 00 00 00 " - + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " - + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " - + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00"); - - message.skipBytes(4); // skip XID - - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Instruction i1 = instructions.get(0); - Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName()); - Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue()); - Instruction i2 = instructions.get(1); - Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName()); - Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), - i2.getAugmentation(MetadataInstruction.class).getMetadata()); - Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), - i2.getAugmentation(MetadataInstruction.class).getMetadataMask()); - Instruction i3 = instructions.get(2); - Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName()); - Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size()); - Instruction i4 = instructions.get(3); - Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName()); - Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); - Instruction i5 = instructions.get(4); - Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); - Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); - Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong action", 53, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 80, action2.getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Instruction i6 = instructions.get(5); - Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); - Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); - action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(QueueIdAction.class).getQueueId().intValue()); - action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 5, action2.getAugmentation(MplsTtlAction.class).getMplsTtl().intValue()); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class InstructionsDeserializerTest { + + + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing instructions translation + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 01 00 08 0A 00 00 00 00 02 00 18 00 00 00 00 " + + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " + + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " + + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00"); + + message.skipBytes(4); // skip XID + + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Instruction i1 = instructions.get(0); + Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName()); + Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue()); + Instruction i2 = instructions.get(1); + Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName()); + Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), + i2.getAugmentation(MetadataInstruction.class).getMetadata()); + Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), + i2.getAugmentation(MetadataInstruction.class).getMetadataMask()); + Instruction i3 = instructions.get(2); + Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName()); + Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size()); + Instruction i4 = instructions.get(3); + Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName()); + Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + Instruction i5 = instructions.get(4); + Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); + Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); + Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output", + action1.getType().getName()); + Assert.assertEquals("Wrong action", 37, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong action", 53, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group", + action2.getType().getName()); + Assert.assertEquals("Wrong action", 80, action2.getAugmentation(GroupIdAction.class).getGroupId().intValue()); + Instruction i6 = instructions.get(5); + Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); + Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); + action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue", + action1.getType().getName()); + Assert.assertEquals("Wrong action", 37, action1.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl", + action2.getType().getName()); + Assert.assertEquals("Wrong action", 5, action2.getAugmentation(MplsTtlAction.class).getMplsTtl().intValue()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java index 446533a9..fb622cd8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import java.util.List; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class ListDeserializerTest { - - @Mock CodeKeyMaker keyMaker; - @Mock DeserializerRegistry registry; - - /** - * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} - */ - @Test - public void test() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - List list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - 42, buffer, keyMaker, registry); - - Assert.assertNull("List is not null", list); - } - - /** - * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} - */ - @Test - public void test2() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - List list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, - 42, buffer, keyMaker, registry); - - Assert.assertNull("List is not null", list); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import java.util.List; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListDeserializerTest { + + @Mock CodeKeyMaker keyMaker; + @Mock DeserializerRegistry registry; + + /** + * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } + + /** + * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test2() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java index f314a3ae..15c367ad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class ListSerializerTest { - - @Mock TypeKeyMaker keyMaker; - @Mock SerializerRegistry registry; - - /** - * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)} - * with null List - */ - @Test - public void test() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer); - - Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListSerializerTest { + + @Mock TypeKeyMaker keyMaker; + @Mock SerializerRegistry registry; + + /** + * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)} + * with null List + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer); + + Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 36d9a9ce..a3ad2abb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -1,516 +1,516 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class MatchDeserializerTest { - - private OFDeserializer matchDeserializer; - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - matchDeserializer = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EMPTY_VALUE, Match.class)); - } - - /** - * Testing Ipv4 address deserialization - */ - @Test - public void testIpv4Address() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 12); - key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), - entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - } - - /** - * Testing Ipv6 address deserialization - */ - @Test - public void testIpv6Address() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 26); - key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), - entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - } - - /** - * Testing match deserialization - */ - @Test - public void testMatch() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC " - + "80 00 00 04 00 00 00 01 " - + "80 00 02 04 00 00 00 02 " - + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 " - + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 " - + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 " - + "80 00 0A 02 00 09 " - + "80 00 0D 04 00 0A 00 0B " - + "80 00 0E 01 0C " - + "80 00 10 01 0D " - + "80 00 12 01 0E " - + "80 00 14 01 0F " - + "80 00 17 08 0A 00 00 01 00 00 FF 00 " - + "80 00 19 08 0A 00 00 02 00 00 00 FF " - + "80 00 1A 02 00 03 " - + "80 00 1C 02 00 04 " - + "80 00 1E 02 00 05 " - + "80 00 20 02 00 06 " - + "80 00 22 02 00 07 " - + "80 00 24 02 00 08 " - + "80 00 26 01 05 " - + "80 00 28 01 07 " - + "80 00 2A 02 00 10 " - + "80 00 2D 08 0A 00 00 09 00 00 FF 00 " - + "80 00 2F 08 0A 00 00 0A 00 00 00 FF " - + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 " - + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 " - + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 " - + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 " - + "80 00 39 08 00 00 00 02 00 00 00 03 " - + "80 00 3A 01 15 " - + "80 00 3C 01 17 " - + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget - + "80 00 40 06 00 05 00 00 00 01 " - + "80 00 42 06 00 05 00 00 00 02 " - + "80 00 44 04 00 00 02 03 " - + "80 00 46 01 03 " - + "80 00 48 01 01 " - + "80 00 4B 06 00 00 02 00 00 01 " - + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " - + "80 00 4F 04 00 00 03 04 " - + "00 00 00 00"); - - Match match = matchDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size()); - List entries = match.getMatchEntries(); - MatchEntries entry0 = entries.get(0); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass()); - Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask()); - Assert.assertEquals("Wrong entry value", 1, - entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry1 = entries.get(1); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass()); - Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry2 = entries.get(2); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); - Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), - entry2.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry3 = entries.get(3); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), - entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), - entry3.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry4 = entries.get(4); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), - entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), - entry4.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry5 = entries.get(5); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask()); - Assert.assertEquals("Wrong entry value", 9, - entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue()); - MatchEntries entry6 = entries.get(6); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); - Assert.assertEquals("Wrong entry value", 10, - entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, - entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), - entry6.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry7 = entries.get(7); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask()); - Assert.assertEquals("Wrong entry value", 12, - entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue()); - MatchEntries entry8 = entries.get(8); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask()); - Assert.assertEquals("Wrong entry value", 13, - entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue()); - MatchEntries entry9 = entries.get(9); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask()); - Assert.assertEquals("Wrong entry value", 14, - entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue()); - MatchEntries entry10 = entries.get(10); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask()); - Assert.assertEquals("Wrong entry value", 15, - entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue()); - MatchEntries entry11 = entries.get(11); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), - entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry11.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry12 = entries.get(12); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), - entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry12.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry13 = entries.get(13); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); - Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask()); - Assert.assertEquals("Wrong entry value", 3, - entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry14 = entries.get(14); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass()); - Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask()); - Assert.assertEquals("Wrong entry value", 4, - entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry15 = entries.get(15); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass()); - Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask()); - Assert.assertEquals("Wrong entry value", 5, - entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry16 = entries.get(16); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass()); - Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask()); - Assert.assertEquals("Wrong entry value", 6, - entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry17 = entries.get(17); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass()); - Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask()); - Assert.assertEquals("Wrong entry value", 7, - entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry18 = entries.get(18); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass()); - Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask()); - Assert.assertEquals("Wrong entry value", 8, - entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry19 = entries.get(19); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask()); - Assert.assertEquals("Wrong entry value", 5, - entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue()); - MatchEntries entry20 = entries.get(20); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask()); - Assert.assertEquals("Wrong entry value", 7, - entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue()); - MatchEntries entry21 = entries.get(21); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask()); - Assert.assertEquals("Wrong entry value", 16, - entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue()); - MatchEntries entry22 = entries.get(22); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), - entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry22.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry23 = entries.get(23); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), - entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry23.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry24 = entries.get(24); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), - entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), - entry24.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry25 = entries.get(25); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), - entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), - entry25.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry26 = entries.get(26); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), - entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), - entry26.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry27 = entries.get(27); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), - entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), - entry27.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry28 = entries.get(28); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), - entry28.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry29 = entries.get(29); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); - Assert.assertEquals("Wrong entry value", 21, - entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); - MatchEntries entry30 = entries.get(30); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); - Assert.assertEquals("Wrong entry value", 23, - entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); - MatchEntries entry31 = entries.get(31); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), - entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - MatchEntries entry32 = entries.get(32); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), - entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry33 = entries.get(33); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"), - entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry34 = entries.get(34); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask()); - Assert.assertEquals("Wrong entry value", 515, - entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); - MatchEntries entry35 = entries.get(35); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask()); - Assert.assertEquals("Wrong entry value", 3, - entry35.getAugmentation(TcMatchEntry.class).getTc().intValue()); - MatchEntries entry36 = entries.get(36); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask()); - Assert.assertEquals("Wrong entry value", true, - entry36.getAugmentation(BosMatchEntry.class).isBos()); - MatchEntries entry37 = entries.get(37); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass()); - Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"), - entry37.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry38 = entries.get(38); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass()); - Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"), - entry38.getAugmentation(MetadataMatchEntry.class).getMetadata()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"), - entry38.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry39 = entries.get(39); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); - Assert.assertEquals("Wrong entry value", - new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), - entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), - entry39.getAugmentation(MaskMatchEntry.class).getMask()); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } - - /** - * Testing header deserialization - */ - @Test - public void testHeaders() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 12); - key.setExperimenterId(null); - HeaderDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); - } - - /** - * Testing standard match type - */ - @Test - public void testStandardMatch() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01"); - - Match match = matchDeserializer.deserialize(buffer); - - Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class MatchDeserializerTest { + + private OFDeserializer matchDeserializer; + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, + EncodeConstants.EMPTY_VALUE, Match.class)); + } + + /** + * Testing Ipv4 address deserialization + */ + @Test + public void testIpv4Address() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), + entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + } + + /** + * Testing Ipv6 address deserialization + */ + @Test + public void testIpv6Address() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 26); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), + entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + } + + /** + * Testing match deserialization + */ + @Test + public void testMatch() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC " + + "80 00 00 04 00 00 00 01 " + + "80 00 02 04 00 00 00 02 " + + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 " + + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 " + + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 " + + "80 00 0A 02 00 09 " + + "80 00 0D 04 00 0A 00 0B " + + "80 00 0E 01 0C " + + "80 00 10 01 0D " + + "80 00 12 01 0E " + + "80 00 14 01 0F " + + "80 00 17 08 0A 00 00 01 00 00 FF 00 " + + "80 00 19 08 0A 00 00 02 00 00 00 FF " + + "80 00 1A 02 00 03 " + + "80 00 1C 02 00 04 " + + "80 00 1E 02 00 05 " + + "80 00 20 02 00 06 " + + "80 00 22 02 00 07 " + + "80 00 24 02 00 08 " + + "80 00 26 01 05 " + + "80 00 28 01 07 " + + "80 00 2A 02 00 10 " + + "80 00 2D 08 0A 00 00 09 00 00 FF 00 " + + "80 00 2F 08 0A 00 00 0A 00 00 00 FF " + + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 " + + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 " + + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 " + + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 " + + "80 00 39 08 00 00 00 02 00 00 00 03 " + + "80 00 3A 01 15 " + + "80 00 3C 01 17 " + + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget + + "80 00 40 06 00 05 00 00 00 01 " + + "80 00 42 06 00 05 00 00 00 02 " + + "80 00 44 04 00 00 02 03 " + + "80 00 46 01 03 " + + "80 00 48 01 01 " + + "80 00 4B 06 00 00 02 00 00 01 " + + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " + + "80 00 4F 04 00 00 03 04 " + + "00 00 00 00"); + + Match match = matchDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType()); + Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size()); + List entries = match.getMatchEntries(); + MatchEntries entry0 = entries.get(0); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass()); + Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask()); + Assert.assertEquals("Wrong entry value", 1, + entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + MatchEntries entry1 = entries.get(1); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass()); + Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + MatchEntries entry2 = entries.get(2); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); + Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), + entry2.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry3 = entries.get(3); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), + entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), + entry3.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry4 = entries.get(4); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), + entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), + entry4.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry5 = entries.get(5); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask()); + Assert.assertEquals("Wrong entry value", 9, + entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue()); + MatchEntries entry6 = entries.get(6); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); + Assert.assertEquals("Wrong entry value", 10, + entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + Assert.assertEquals("Wrong entry value", false, + entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), + entry6.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry7 = entries.get(7); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask()); + Assert.assertEquals("Wrong entry value", 12, + entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue()); + MatchEntries entry8 = entries.get(8); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask()); + Assert.assertEquals("Wrong entry value", 13, + entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue()); + MatchEntries entry9 = entries.get(9); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask()); + Assert.assertEquals("Wrong entry value", 14, + entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue()); + MatchEntries entry10 = entries.get(10); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask()); + Assert.assertEquals("Wrong entry value", 15, + entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue()); + MatchEntries entry11 = entries.get(11); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), + entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + entry11.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry12 = entries.get(12); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), + entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + entry12.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry13 = entries.get(13); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); + Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask()); + Assert.assertEquals("Wrong entry value", 3, + entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry14 = entries.get(14); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass()); + Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask()); + Assert.assertEquals("Wrong entry value", 4, + entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry15 = entries.get(15); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass()); + Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask()); + Assert.assertEquals("Wrong entry value", 5, + entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry16 = entries.get(16); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass()); + Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask()); + Assert.assertEquals("Wrong entry value", 6, + entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry17 = entries.get(17); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass()); + Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask()); + Assert.assertEquals("Wrong entry value", 7, + entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry18 = entries.get(18); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass()); + Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask()); + Assert.assertEquals("Wrong entry value", 8, + entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry19 = entries.get(19); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask()); + Assert.assertEquals("Wrong entry value", 5, + entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue()); + MatchEntries entry20 = entries.get(20); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask()); + Assert.assertEquals("Wrong entry value", 7, + entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue()); + MatchEntries entry21 = entries.get(21); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask()); + Assert.assertEquals("Wrong entry value", 16, + entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue()); + MatchEntries entry22 = entries.get(22); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), + entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + entry22.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry23 = entries.get(23); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), + entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + entry23.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry24 = entries.get(24); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), + entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), + entry24.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry25 = entries.get(25); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), + entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), + entry25.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry26 = entries.get(26); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), + entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + Assert.assertArrayEquals("Wrong entry mask", + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), + entry26.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry27 = entries.get(27); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), + entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + Assert.assertArrayEquals("Wrong entry mask", + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), + entry27.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry28 = entries.get(28); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), + entry28.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry29 = entries.get(29); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); + Assert.assertEquals("Wrong entry value", 21, + entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); + MatchEntries entry30 = entries.get(30); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); + Assert.assertEquals("Wrong entry value", 23, + entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); + MatchEntries entry31 = entries.get(31); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), + entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + MatchEntries entry32 = entries.get(32); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), + entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + MatchEntries entry33 = entries.get(33); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"), + entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + MatchEntries entry34 = entries.get(34); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask()); + Assert.assertEquals("Wrong entry value", 515, + entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); + MatchEntries entry35 = entries.get(35); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask()); + Assert.assertEquals("Wrong entry value", 3, + entry35.getAugmentation(TcMatchEntry.class).getTc().intValue()); + MatchEntries entry36 = entries.get(36); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask()); + Assert.assertEquals("Wrong entry value", true, + entry36.getAugmentation(BosMatchEntry.class).isBos()); + MatchEntries entry37 = entries.get(37); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass()); + Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"), + entry37.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry38 = entries.get(38); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass()); + Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"), + entry38.getAugmentation(MetadataMatchEntry.class).getMetadata()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"), + entry38.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry39 = entries.get(39); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); + Assert.assertEquals("Wrong entry value", + new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), + entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), + entry39.getAugmentation(MaskMatchEntry.class).getMask()); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } + + /** + * Testing header deserialization + */ + @Test + public void testHeaders() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + HeaderDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); + } + + /** + * Testing standard match type + */ + @Test + public void testStandardMatch() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01"); + + Match match = matchDeserializer.deserialize(buffer); + + Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); + Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 100f38c0..3e83bf4b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -1,135 +1,135 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10ActionsDeserializerTest { - - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct deserialization of actions (OF v1.0) - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " - + "00 01 00 08 10 10 00 00 " - + "00 02 00 08 25 00 00 00 " - + "00 03 00 08 00 00 00 00 " - + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " - + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " - + "00 06 00 08 0A 00 00 01 " - + "00 07 00 08 0B 00 00 02 " - + "00 08 00 08 01 00 00 00 " - + "00 09 00 08 00 02 00 00 " - + "00 0A 00 08 00 03 00 00 " - + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); - - message.skipBytes(4); // skip XID - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); - List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong number of actions", 12, actions.size()); - Action action1 = actions.get(0); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Output", action1.getType().getName()); - Assert.assertEquals("Wrong port", 16, - action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong max-length", 8192, - action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Action action2 = actions.get(1); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); - Assert.assertEquals("Wrong vlan-vid", 4112, - action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); - Action action3 = actions.get(2); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); - Assert.assertEquals("Wrong vlan-pcp", 37, - action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); - Action action4 = actions.get(3); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); - Action action5 = actions.get(4); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); - Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), - ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action6 = actions.get(5); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); - Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), - ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action7 = actions.get(6); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); - Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), - action7.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action8 = actions.get(7); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); - Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), - action8.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action9 = actions.get(8); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); - Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); - Action action10 = actions.get(9); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); - Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Action action11 = actions.get(10); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); - Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Action action12 = actions.get(11); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); - Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong queue-id", 48, - action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10ActionsDeserializerTest { + + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct deserialization of actions (OF v1.0) + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " + + "00 01 00 08 10 10 00 00 " + + "00 02 00 08 25 00 00 00 " + + "00 03 00 08 00 00 00 00 " + + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " + + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " + + "00 06 00 08 0A 00 00 01 " + + "00 07 00 08 0B 00 00 02 " + + "00 08 00 08 01 00 00 00 " + + "00 09 00 08 00 02 00 00 " + + "00 0A 00 08 00 03 00 00 " + + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); + + message.skipBytes(4); // skip XID + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Assert.assertEquals("Wrong number of actions", 12, actions.size()); + Action action1 = actions.get(0); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.Output", action1.getType().getName()); + Assert.assertEquals("Wrong port", 16, + action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong max-length", 8192, + action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Action action2 = actions.get(1); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); + Assert.assertEquals("Wrong vlan-vid", 4112, + action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); + Action action3 = actions.get(2); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); + Assert.assertEquals("Wrong vlan-pcp", 37, + action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); + Action action4 = actions.get(3); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); + Action action5 = actions.get(4); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); + Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), + ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + Action action6 = actions.get(5); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); + Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), + ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + Action action7 = actions.get(6); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); + Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), + action7.getAugmentation(IpAddressAction.class).getIpAddress()); + Action action8 = actions.get(7); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); + Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), + action8.getAugmentation(IpAddressAction.class).getIpAddress()); + Action action9 = actions.get(8); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); + Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); + Action action10 = actions.get(9); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); + Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Action action11 = actions.get(10); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); + Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Action action12 = actions.get(11); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); + Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Assert.assertEquals("Wrong queue-id", 48, + action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index 4a80e8c3..3b72cb4d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -1,219 +1,219 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public class OF10ActionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct serialization of actions (OF v1.0) - */ - @Test - public void test() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(32); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanVid.class); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(15); - actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanPcp.class); - VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); - pcpBuilder.setVlanPcp((short) 16); - actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(StripVlan.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlSrc.class); - DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlDst.class); - dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwSrc.class); - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwDst.class); - ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTos.class); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); - tosBuilder.setNwTos((short) 204); - actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpSrc.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6653L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpDst.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6633L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Enqueue.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6613L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(400L); - actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 42, out.readUnsignedShort()); - Assert.assertEquals("Wrong max-length", 32, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - out.readBytes(data); - Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - out.readBytes(data); - Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte()); - Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); - Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); - } - +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public class OF10ActionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct serialization of actions (OF v1.0) + */ + @Test + public void test() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(32); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetVlanVid.class); + VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); + vlanBuilder.setVlanVid(15); + actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetVlanPcp.class); + VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); + pcpBuilder.setVlanPcp((short) 16); + actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(StripVlan.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetDlSrc.class); + DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); + dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); + actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetDlDst.class); + dlBuilder = new DlAddressActionBuilder(); + dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); + actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwSrc.class); + IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); + actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwDst.class); + ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); + actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTos.class); + NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + tosBuilder.setNwTos((short) 204); + actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetTpSrc.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6653L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetTpDst.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6633L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(Enqueue.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6613L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); + queueBuilder.setQueueId(400L); + actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 42, out.readUnsignedShort()); + Assert.assertEquals("Wrong max-length", 32, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + out.readBytes(data); + Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + out.readBytes(data); + Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte()); + Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); + Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index f801dee3..4f01fd20 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -1,287 +1,287 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ActionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct serialization of actions - */ - @Test - public void test() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlOut.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlIn.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetMplsTtl.class); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl((short) 4); - actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecMplsTtl.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(16)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopVlan.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(17)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(18)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetQueue.class); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(1234L); - actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Group.class); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(555L); - actionBuilder.addAugmentation(GroupIdAction.class, group.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 8); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecNwTtl.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); - matchBuilder.setOxmClass(OpenflowBasicClass.class); - matchBuilder.setOxmMatchField(InPort.class); - matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); - entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushPbb.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(19)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing correct serialization of actions - */ - @Test - public void testHeaders() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); - matchBuilder.setOxmClass(OpenflowBasicClass.class); - matchBuilder.setOxmMatchField(InPort.class); - matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); - entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ActionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct serialization of actions + */ + @Test + public void test() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(52); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(CopyTtlOut.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(CopyTtlIn.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetMplsTtl.class); + MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); + mplsTtl.setMplsTtl((short) 4); + actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(DecMplsTtl.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushVlan.class); + EthertypeActionBuilder etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(16)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopVlan.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushMpls.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(17)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopMpls.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(18)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetQueue.class); + QueueIdActionBuilder queueId = new QueueIdActionBuilder(); + queueId.setQueueId(1234L); + actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(Group.class); + GroupIdActionBuilder group = new GroupIdActionBuilder(); + group.setGroupId(555L); + actionBuilder.addAugmentation(GroupIdAction.class, group.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTtl.class); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl((short) 8); + actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(DecNwTtl.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetField.class); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + matchBuilder.setOxmClass(OpenflowBasicClass.class); + matchBuilder.setOxmMatchField(InPort.class); + matchBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); + portBuilder.setPortNumber(new PortNumber(1L)); + matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + entries.add(matchBuilder.build()); + matchEntries.setMatchEntries(entries); + actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushPbb.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(19)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopPbb.class); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing correct serialization of actions + */ + @Test + public void testHeaders() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(52); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetField.class); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + matchBuilder.setOxmClass(OpenflowBasicClass.class); + matchBuilder.setOxmMatchField(InPort.class); + matchBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); + portBuilder.setPortNumber(new PortNumber(1L)); + matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + entries.add(matchBuilder.build()); + matchEntries.setMatchEntries(entries); + actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 902f8b58..68fe7510 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -1,196 +1,196 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public class OF13InstructionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing instructions translation - */ - @Test - public void test() { - List instructions = new ArrayList<>(); - // Goto_table instruction - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); - TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); - tableIdBuilder.setTableId((short) 5); - builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); - instructions.add(builder.build()); - builder = new InstructionBuilder(); - // Write_metadata instruction - builder.setType(WriteMetadata.class); - MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); - metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); - metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); - builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); - instructions.add(builder.build()); - // Clear_actions instruction - builder = new InstructionBuilder(); - builder.setType(ClearActions.class); - instructions.add(builder.build()); - // Meter instruction - builder = new InstructionBuilder(); - builder.setType(Meter.class); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); - meterBuilder.setMeterId(42L); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); - instructions.add(builder.build()); - // Write_actions instruction - builder = new InstructionBuilder(); - builder.setType(WriteActions.class); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(45L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); - maxBuilder.setMaxLength(55); - actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 64); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); - actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - instructions.add(builder.build()); - // Apply_actions instruction - builder = new InstructionBuilder(); - builder.setType(ApplyActions.class); - actionsBuilder = new ActionsInstructionBuilder(); - actions = new ArrayList<>(); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); - ethertypeBuilder.setEthertype(new EtherType(14)); - actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); - actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - instructions.add(builder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(instructions, TypeKeyMakerFactory - .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); - out.skipBytes(4); - byte[] actual = new byte[8]; - out.readBytes(actual); - Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", - ByteBufUtils.bytesToHexString(actual)); - actual = new byte[8]; - out.readBytes(actual); - Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", - ByteBufUtils.bytesToHexString(actual)); - Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Not all data were read", out.readableBytes() == 0); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public class OF13InstructionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing instructions translation + */ + @Test + public void test() { + List instructions = new ArrayList<>(); + // Goto_table instruction + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(GotoTable.class); + TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); + tableIdBuilder.setTableId((short) 5); + builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); + instructions.add(builder.build()); + builder = new InstructionBuilder(); + // Write_metadata instruction + builder.setType(WriteMetadata.class); + MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); + metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); + metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); + builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); + instructions.add(builder.build()); + // Clear_actions instruction + builder = new InstructionBuilder(); + builder.setType(ClearActions.class); + instructions.add(builder.build()); + // Meter instruction + builder = new InstructionBuilder(); + builder.setType(Meter.class); + MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); + meterBuilder.setMeterId(42L); + builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + instructions.add(builder.build()); + // Write_actions instruction + builder = new InstructionBuilder(); + builder.setType(WriteActions.class); + ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(45L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); + maxBuilder.setMaxLength(55); + actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTtl.class); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl((short) 64); + actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + actions.add(actionBuilder.build()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + instructions.add(builder.build()); + // Apply_actions instruction + builder = new InstructionBuilder(); + builder.setType(ApplyActions.class); + actionsBuilder = new ActionsInstructionBuilder(); + actions = new ArrayList<>(); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushVlan.class); + EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); + ethertypeBuilder.setEthertype(new EtherType(14)); + actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopPbb.class); + actions.add(actionBuilder.build()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + instructions.add(builder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(instructions, TypeKeyMakerFactory + .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); + out.skipBytes(4); + byte[] actual = new byte[8]; + out.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", + ByteBufUtils.bytesToHexString(actual)); + actual = new byte[8]; + out.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", + ByteBufUtils.bytesToHexString(actual)); + Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Not all data were read", out.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index 6ed7c7e7..e607d0fc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -1,793 +1,793 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13MatchSerializer02Test { - - private SerializerRegistry registry; - private OFSerializer matchSerializer; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - matchSerializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)); - } - - /** - * Testing serialization of match - */ - @Test - public void testEmptyMatch() { - MatchBuilder builder = new MatchBuilder(); - builder.setType(OxmMatchType.class); - Match match = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - matchSerializer.serialize(match, out); - - Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); - Assert.assertTrue("Wrong padding", out.readableBytes() == 4); - } - - /** - * Testing serialization of match - */ - @Test - public void test() { - MatchBuilder builder = new MatchBuilder(); - builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(InPort.class); - entryBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(42L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(InPhyPort.class); - entryBuilder.setHasMask(false); - portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(43L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Metadata.class); - entryBuilder.setHasMask(true); - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthDst.class); - entryBuilder.setHasMask(true); - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,5}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthSrc.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthType.class); - entryBuilder.setHasMask(false); - EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); - ethBuilder.setEthType(new EtherType(46)); - entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(VlanVid.class); - entryBuilder.setHasMask(true); - VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); - vidBuilder.setCfiBit(true); - vidBuilder.setVlanVid(45); - entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,9}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(VlanPcp.class); - entryBuilder.setHasMask(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp((short) 14); - entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpDscp.class); - entryBuilder.setHasMask(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp((short) 48)); - entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpEcn.class); - entryBuilder.setHasMask(false); - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn((short) 49); - entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpProto.class); - entryBuilder.setHasMask(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); - protoBuilder.setProtocolNumber((short) 50); - entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv4Src.class); - entryBuilder.setHasMask(true); - Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,14}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv4Dst.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,15}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TcpSrc.class); - entryBuilder.setHasMask(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TcpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(UdpSrc.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(UdpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(SctpSrc.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(SctpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv4Type.class); - entryBuilder.setHasMask(false); - Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4typeBuilder.setIcmpv4Type((short) 51); - entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv4Code.class); - entryBuilder.setHasMask(false); - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4CodeBuilder.setIcmpv4Code((short) 52); - entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpOp.class); - entryBuilder.setHasMask(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(53); - entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpSpa.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,16}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpTpa.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,17}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpSha.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,4,0,0,6}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpTha.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,6,0,0,4}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Src.class); - entryBuilder.setHasMask(true); - Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Dst.class); - entryBuilder.setHasMask(true); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Flabel.class); - entryBuilder.setHasMask(true); - Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); - entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv6Type.class); - entryBuilder.setHasMask(false); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6TypeBuilder.setIcmpv6Type((short) 59); - entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv6Code.class); - entryBuilder.setHasMask(false); - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code((short) 60); - entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdTarget.class); - entryBuilder.setHasMask(false); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdSll.class); - entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdTll.class); - entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsLabel.class); - entryBuilder.setHasMask(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(61L); - entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsTc.class); - entryBuilder.setHasMask(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc((short) 62); - entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsBos.class); - entryBuilder.setHasMask(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(true); - entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(PbbIsid.class); - entryBuilder.setHasMask(true); - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(64L); - entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TunnelId.class); - entryBuilder.setHasMask(true); - metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Exthdr.class); - entryBuilder.setHasMask(true); - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - - - builder.setMatchEntries(entries); - Match match = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - matchSerializer.serialize(match, out); - - Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); - Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - byte[] array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,5}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); - array = new byte[2]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,9}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,1}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,14}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,2}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,15}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,4}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,16}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,5}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,17}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,1,2,3,4,5}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,4,0,0,6}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,3}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,6,0,0,4}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1}, array); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,0,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); - array = new byte[3]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); - Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); - array = new byte[2]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,2}, array); - Assert.assertTrue("Wrong padding", out.readableBytes() == 4); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13MatchSerializer02Test { + + private SerializerRegistry registry; + private OFSerializer matchSerializer; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + matchSerializer = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)); + } + + /** + * Testing serialization of match + */ + @Test + public void testEmptyMatch() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(OxmMatchType.class); + Match match = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + matchSerializer.serialize(match, out); + + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); + Assert.assertTrue("Wrong padding", out.readableBytes() == 4); + } + + /** + * Testing serialization of match + */ + @Test + public void test() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(InPort.class); + entryBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); + portNumberBuilder.setPortNumber(new PortNumber(42L)); + entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(InPhyPort.class); + entryBuilder.setHasMask(false); + portNumberBuilder = new PortNumberMatchEntryBuilder(); + portNumberBuilder.setPortNumber(new PortNumber(43L)); + entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Metadata.class); + entryBuilder.setHasMask(true); + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthDst.class); + entryBuilder.setHasMask(true); + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,5}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthSrc.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthType.class); + entryBuilder.setHasMask(false); + EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); + ethBuilder.setEthType(new EtherType(46)); + entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(VlanVid.class); + entryBuilder.setHasMask(true); + VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); + vidBuilder.setCfiBit(true); + vidBuilder.setVlanVid(45); + entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,9}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(VlanPcp.class); + entryBuilder.setHasMask(false); + VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); + pcpBuilder.setVlanPcp((short) 14); + entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpDscp.class); + entryBuilder.setHasMask(false); + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp((short) 48)); + entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpEcn.class); + entryBuilder.setHasMask(false); + EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); + ecnBuilder.setEcn((short) 49); + entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpProto.class); + entryBuilder.setHasMask(false); + ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + protoBuilder.setProtocolNumber((short) 50); + entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv4Src.class); + entryBuilder.setHasMask(true); + Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,14}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv4Dst.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,15}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TcpSrc.class); + entryBuilder.setHasMask(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TcpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(UdpSrc.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(UdpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(SctpSrc.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(SctpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv4Type.class); + entryBuilder.setHasMask(false); + Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4typeBuilder.setIcmpv4Type((short) 51); + entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv4Code.class); + entryBuilder.setHasMask(false); + Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4CodeBuilder.setIcmpv4Code((short) 52); + entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpOp.class); + entryBuilder.setHasMask(false); + OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); + opBuilder.setOpCode(53); + entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpSpa.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,16}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpTpa.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,17}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpSha.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,4,0,0,6}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpTha.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,6,0,0,4}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Src.class); + entryBuilder.setHasMask(true); + Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Dst.class); + entryBuilder.setHasMask(true); + ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Flabel.class); + entryBuilder.setHasMask(true); + Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); + flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); + entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,1,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv6Type.class); + entryBuilder.setHasMask(false); + Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6TypeBuilder.setIcmpv6Type((short) 59); + entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv6Code.class); + entryBuilder.setHasMask(false); + Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6CodeBuilder.setIcmpv6Code((short) 60); + entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdTarget.class); + entryBuilder.setHasMask(false); + ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdSll.class); + entryBuilder.setHasMask(false); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdTll.class); + entryBuilder.setHasMask(false); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsLabel.class); + entryBuilder.setHasMask(false); + MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); + labelBuilder.setMplsLabel(61L); + entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsTc.class); + entryBuilder.setHasMask(false); + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc((short) 62); + entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsBos.class); + entryBuilder.setHasMask(false); + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + bosBuilder.setBos(true); + entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(PbbIsid.class); + entryBuilder.setHasMask(true); + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + isidBuilder.setIsid(64L); + entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,1,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TunnelId.class); + entryBuilder.setHasMask(true); + metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Exthdr.class); + entryBuilder.setHasMask(true); + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); + entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + + + builder.setMatchEntries(entries); + Match match = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + matchSerializer.serialize(match, out); + + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); + Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + byte[] array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,5}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); + array = new byte[2]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,9}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,1}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,14}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,2}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,15}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,4}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,16}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,5}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,17}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,1,2,3,4,5}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,4,0,0,6}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,3}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,6,0,0,4}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1}, array); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,0,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); + array = new byte[3]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); + Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); + array = new byte[2]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,2}, array); + Assert.assertTrue("Wrong padding", out.readableBytes() == 4); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java index 47e92623..4a1ceb78 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; - -/** - * @author michal.polkorab - * - */ -public class OpenflowUtilsTest { - - /** - * Tests {@link OpenflowUtils#createPortState(long)} - */ - @Test - public void testPortState() { - PortStateV10 state = OpenflowUtils.createPortState(512L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, false, false, false, true, false, true, false), state); - - state = OpenflowUtils.createPortState(1793L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, true, false, true, true, true, false, true), state); - - state = OpenflowUtils.createPortState(1L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, true, false, false, false, false, true, false), state); - } - - /** - * Tests {@link OpenflowUtils#createPortConfig(long)} - */ - @Test - public void testPortConfig() { - PortConfigV10 config = OpenflowUtils.createPortConfig(127L); - Assert.assertEquals("Wrong port config", - new PortConfigV10(true, true, true, true, true, true, true), config); - - config = OpenflowUtils.createPortConfig(0L); - Assert.assertEquals("Wrong port config", - new PortConfigV10(false, false, false, false, false, false, false), config); - } - - /** - * Tests {@link OpenflowUtils#createPortFeatures(long)} - */ - @Test - public void testPortFeatures() { - PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L); - Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, - true, true, true, true, true), features); - - features = OpenflowUtils.createPortFeatures(0L); - Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, - false, false, false, false, false, false), features); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; + +/** + * @author michal.polkorab + * + */ +public class OpenflowUtilsTest { + + /** + * Tests {@link OpenflowUtils#createPortState(long)} + */ + @Test + public void testPortState() { + PortStateV10 state = OpenflowUtils.createPortState(512L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, false, false, false, true, false, true, false), state); + + state = OpenflowUtils.createPortState(1793L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, true, true, true, false, true), state); + + state = OpenflowUtils.createPortState(1L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, false, false, false, true, false), state); + } + + /** + * Tests {@link OpenflowUtils#createPortConfig(long)} + */ + @Test + public void testPortConfig() { + PortConfigV10 config = OpenflowUtils.createPortConfig(127L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(true, true, true, true, true, true, true), config); + + config = OpenflowUtils.createPortConfig(0L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(false, false, false, false, false, false, false), config); + } + + /** + * Tests {@link OpenflowUtils#createPortFeatures(long)} + */ + @Test + public void testPortFeatures() { + PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, + true, true, true, true, true), features); + + features = OpenflowUtils.createPortFeatures(0L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, + false, false, false, false, false, false), features); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index c58a119a..ba445321 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -1,181 +1,181 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class TypeKeyMakerFactoryTest { - - /** - * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} - */ - @Test - public void testActionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - ActionBuilder builder = new ActionBuilder(); - builder.setType(Output.class); - Action action = builder.build(); - MessageTypeKey key = keyMaker.make(action); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - Output.class, null), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} - */ - @Test - public void testExperimenterActionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - ActionBuilder builder = new ActionBuilder(); - builder.setType(Experimenter.class); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expIdBuilder.setSubType(ActionSubtypeClass.class); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - Action action = builder.build(); - MessageTypeKey key = keyMaker.make(action); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, - ActionSubtypeClass.class), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} - */ - @Test - public void testInstructionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); - Instruction instruction = builder.build(); - MessageTypeKey key = keyMaker.make(instruction); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - GotoTable.class, null), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} - */ - @Test - public void testExperimenterInstructionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .common.instruction.rev130731.Experimenter.class); - ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); - Instruction instruction = builder.build(); - MessageTypeKey key = keyMaker.make(instruction); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, - 42L), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(InPort.class); - builder.setHasMask(true); - MatchEntries entry = builder.build(); - MessageTypeKey key = keyMaker.make(entry); - - Assert.assertNotNull("Null key", key); - MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, InPort.class); - Assert.assertEquals("Wrong key", comparationKey, key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testExperimenterMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(ExperimenterClass.class); - builder.setOxmMatchField(OxmMatchFieldClass.class); - builder.setHasMask(true); - ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); - MatchEntries entry = builder.build(); - MessageTypeKey key = keyMaker.make(entry); - - Assert.assertNotNull("Null key", key); - MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - ExperimenterClass.class, OxmMatchFieldClass.class); - comparationKey.setExperimenterId(42L); - Assert.assertEquals("Wrong key", comparationKey, key); - } - - private class ActionSubtypeClass extends ExperimenterActionSubType { - // only for testing purposes - } - - private class OxmMatchFieldClass extends MatchField { - // only for testing purposes - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class TypeKeyMakerFactoryTest { + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Output.class); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Output.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Experimenter.class); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expIdBuilder.setSubType(ActionSubtypeClass.class); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, + ActionSubtypeClass.class), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(GotoTable.class); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + GotoTable.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow + .common.instruction.rev130731.Experimenter.class); + ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, + 42L), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(InPort.class); + builder.setHasMask(true); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPort.class); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(ExperimenterClass.class); + builder.setOxmMatchField(OxmMatchFieldClass.class); + builder.setHasMask(true); + ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + ExperimenterClass.class, OxmMatchFieldClass.class); + comparationKey.setExperimenterId(42L); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + private class ActionSubtypeClass extends ExperimenterActionSubType { + // only for testing purposes + } + + private class OxmMatchFieldClass extends MatchField { + // only for testing purposes + } } \ No newline at end of file diff --git a/openflow-protocol-it/src/test/resources/log4j.xml b/openflow-protocol-it/src/test/resources/log4j.xml index 23b1b663..34512d51 100644 --- a/openflow-protocol-it/src/test/resources/log4j.xml +++ b/openflow-protocol-it/src/test/resources/log4j.xml @@ -1,24 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java index c5d7a6aa..1d2c580b 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.spi.statistics; - -/** - * Used for JConsole service - * - * @author michal.polkorab - */ -public interface StatisticsHandler { - - /** - * Resets all counters - */ - public void resetCounters(); - - /** - * Prints statistics - * @return statistics - */ - public String printStatistics(); +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.spi.statistics; + +/** + * Used for JConsole service + * + * @author michal.polkorab + */ +public interface StatisticsHandler { + + /** + * Resets all counters + */ + public void resetCounters(); + + /** + * Prints statistics + * @return statistics + */ + public String printStatistics(); } \ No newline at end of file diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index 60647655..91edd9e8 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -1,53 +1,53 @@ - - - - 4.0.0 - - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.6.0-SNAPSHOT - - openflowjava-config - Configuration files for openflowjava statistics - jar - Openflow Protocol Library - CONFIG - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - 45-openflowjava-stats.xml - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${configfile} - xml - configstats - - - - - - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + 4.0.0 + + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.6.0-SNAPSHOT + + openflowjava-config + Configuration files for openflowjava statistics + jar + Openflow Protocol Library - CONFIG + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + 45-openflowjava-stats.xml + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${configfile} + xml + configstats + + + + + + + + + diff --git a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml index 12761959..882d7e18 100644 --- a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml +++ b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml @@ -1,41 +1,41 @@ - - - - - - - urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28 - urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28 - - - - - - - - stats:statistics-collection-service-impl - statistics-collection-service-impl - - true - 10000 - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-default - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-legacy - - - - - - + + + + + + + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28 + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28 + + + + + + + + stats:statistics-collection-service-impl + statistics-collection-service-impl + + true + 10000 + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-default + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-legacy + + + + + + \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java index 0d4046ef..02a2199a 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.clients; - -import com.google.common.util.concurrent.SettableFuture; - -/** - * Unifying interface for simple clients / switch simulators - * - * @author michal.polkorab - */ -public interface OFClient extends Runnable { - - /** - * @return the isOnlineFuture which is set when client is started - */ - SettableFuture getIsOnlineFuture(); - - /** - * @return the scenarioDone when scenario is successfully finished - */ - SettableFuture getScenarioDone(); - - /** - * @param scenario list of desired actions - */ - void setScenarioHandler(ScenarioHandler scenario); - - /** - * @param securedClient true is client should use encrypted communication, - * false otherwise - */ - void setSecuredClient(boolean securedClient); +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * Unifying interface for simple clients / switch simulators + * + * @author michal.polkorab + */ +public interface OFClient extends Runnable { + + /** + * @return the isOnlineFuture which is set when client is started + */ + SettableFuture getIsOnlineFuture(); + + /** + * @return the scenarioDone when scenario is successfully finished + */ + SettableFuture getScenarioDone(); + + /** + * @param scenario list of desired actions + */ + void setScenarioHandler(ScenarioHandler scenario); + + /** + * @param securedClient true is client should use encrypted communication, + * false otherwise + */ + void setSecuredClient(boolean securedClient); } \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index d24d6d3f..8ef85bc4 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.util; - -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public abstract class ExperimenterDeserializerKeyFactory { - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, ErrorMessage.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMultipartReplyTFDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, TableFeatureProperties.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createQueuePropertyDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, QueueProperty.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public abstract class ExperimenterDeserializerKeyFactory { + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ErrorMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyTFDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, TableFeatureProperties.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createQueuePropertyDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, QueueProperty.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); + } } \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 5d1fc635..4ea333b6 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.util; - -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public abstract class ExperimenterSerializerKeyFactory { - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMeterBandSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public abstract class ExperimenterSerializerKeyFactory { + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMeterBandSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); + } } \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java index 1c63fc0f..d597cfd5 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java @@ -1,94 +1,94 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterDeserializerKeyFactoryTest { - - /** - * Test ExperimenterDeserializerKeyFactory key creation - */ - @Test - public void test() { - ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory - .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdDeserializerKey comparationKey = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 43L, ExperimenterMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 44L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 45L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 45L, MultipartReplyExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MultipartReplyExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterDeserializerKeyFactoryTest { + + /** + * Test ExperimenterDeserializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory + .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdDeserializerKey comparationKey = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 43L, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 44L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 45L, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } } \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java index df975ea5..397f7d69 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterSerializerKeyFactoryTest { - - /** - * Test ExperimenterSerializerKeyFactory key creation - */ - @Test - public void test() { - ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory - .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdSerializerKey comparationKey = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 43L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 44L, MultipartRequestExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MultipartRequestExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( - EncodeConstants.OF10_VERSION_ID, 45L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 45L, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterSerializerKeyFactoryTest { + + /** + * Test ExperimenterSerializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory + .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdSerializerKey comparationKey = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 44L, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 45L, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } } \ No newline at end of file From 07de1ed897da9d7dc70c6d550f38c59339ed751e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 16:03:49 +0100 Subject: [PATCH 116/285] Remove trailing whitespace Trailing whitespace generates a lot of warnings -- mass-remove it. Change-Id: I9b73bc873685576daa80a998a58d1ce55e475c35 Signed-off-by: Robert Varga --- openflow-protocol-api/pom.xml | 2 +- .../api/connection/ConnectionAdapter.java | 8 +- .../connection/ConnectionConfiguration.java | 14 +- .../connection/ListeningStatusProvider.java | 2 +- .../connection/StatisticsConfiguration.java | 2 +- .../connection/SwitchConnectionHandler.java | 4 +- .../api/connection/TlsConfiguration.java | 6 +- .../DeserializerExtensionProvider.java | 2 +- .../extensibility/DeserializerRegistry.java | 4 +- .../extensibility/EnhancedMessageTypeKey.java | 2 +- .../api/extensibility/HeaderDeserializer.java | 4 +- .../api/extensibility/MessageTypeKey.java | 4 +- .../api/extensibility/OFDeserializer.java | 2 +- .../SerializerExtensionProvider.java | 2 +- .../api/extensibility/SerializerRegistry.java | 8 +- .../api/keys/InstructionDeserializerKey.java | 2 +- .../ExperimenterActionDeserializerKey.java | 2 +- .../ExperimenterActionSerializerKey.java | 2 +- .../ExperimenterIdDeserializerKey.java | 4 +- ...xperimenterInstructionDeserializerKey.java | 2 +- .../protocol/api/util/BinContent.java | 2 +- .../protocol/api/util/EncodeConstants.java | 2 +- .../src/main/yang/openflow-action.yang | 6 +- .../src/main/yang/openflow-augments.yang | 12 +- .../src/main/yang/openflow-configuration.yang | 10 +- .../main/yang/openflow-extensible-match.yang | 14 +- .../src/main/yang/openflow-instruction.yang | 2 +- .../src/main/yang/openflow-protocol.yang | 202 +++---- .../src/main/yang/openflow-types.yang | 564 +++++++++--------- .../src/main/yang/system-notifications.yang | 2 +- .../EnhancedMessageCodeKeyTest.java | 4 +- .../EnhancedMessageTypeKeyTest.java | 6 +- .../api/extensibility/MessageTypeKeyTest.java | 2 +- .../api/keys/ActionDeserializerKeyTest.java | 2 +- .../api/keys/ActionSerializerKeyTest.java | 6 +- .../keys/InstructionDeserializerKeyTest.java | 2 +- .../keys/InstructionSerializerKeyTest.java | 2 +- .../protocol/api/keys/KeysTest.java | 4 +- .../keys/MatchEntryDeserializerKeyTest.java | 8 +- .../api/keys/MatchEntrySerializerKeyTest.java | 8 +- .../ExperimenterActionSerializerKeyTest.java | 4 +- .../ExperimenterIdSerializerKeyTest.java | 4 +- openflow-protocol-impl/pom.xml | 4 +- .../impl/core/ChannelInitializerFactory.java | 2 +- .../impl/core/OFDatagramPacketHandler.java | 4 +- .../protocol/impl/core/OFEncoder.java | 2 +- .../protocol/impl/core/OFFrameDecoder.java | 6 +- .../protocol/impl/core/PipelineHandlers.java | 2 +- .../protocol/impl/core/ShutdownProvider.java | 2 +- .../protocol/impl/core/SslContextFactory.java | 2 +- .../impl/core/TcpChannelInitializer.java | 4 +- .../protocol/impl/core/UdpHandler.java | 2 +- .../impl/core/VersionMessageUdpWrapper.java | 2 +- .../impl/core/VersionMessageWrapper.java | 6 +- .../core/connection/ChannelOutboundQueue.java | 2 +- .../connection/MessageListenerWrapper.java | 4 +- .../impl/core/connection/RpcResponseKey.java | 6 +- .../connection/UdpMessageListenerWrapper.java | 2 +- .../ActionDeserializerInitializer.java | 2 +- .../TypeToClassMapInitializer.java | 2 +- .../factories/ErrorMessageFactory.java | 6 +- .../GetAsyncReplyMessageFactory.java | 14 +- .../factories/HelloMessageFactory.java | 4 +- .../MultipartReplyMessageFactory.java | 62 +- .../factories/OF10ErrorMessageFactory.java | 6 +- .../OF10FeaturesReplyMessageFactory.java | 4 +- .../OF10PortStatusMessageFactory.java | 2 +- ...OF10QueueGetConfigReplyMessageFactory.java | 8 +- .../OF10StatsReplyMessageFactory.java | 20 +- .../factories/PortStatusMessageFactory.java | 6 +- .../QueueGetConfigReplyMessageFactory.java | 6 +- .../ClearActionsInstructionDeserializer.java | 2 +- .../AbstractOxmMatchEntryDeserializer.java | 4 +- .../serialization/SerializationFactory.java | 2 +- .../OF13SetMplsTtlActionSerializer.java | 2 +- .../factories/HelloInputMessageFactory.java | 2 +- ...OF10QueueGetConfigInputMessageFactory.java | 2 +- .../SetAsyncInputMessageFactory.java | 4 +- .../impl/util/AbstractCodeKeyMaker.java | 4 +- .../impl/util/AbstractTypeKeyMaker.java | 4 +- .../InstructionSerializerRegistryHelper.java | 2 +- .../protocol/impl/util/ListSerializer.java | 2 +- .../MatchEntrySerializerRegistryHelper.java | 4 +- .../impl/util/OF13MatchSerializer.java | 2 +- .../protocol/impl/util/OpenflowUtils.java | 2 +- .../protocol/impl/util/TypeKeyMaker.java | 4 +- .../impl/util/TypeToClassInitHelper.java | 2 +- .../openflowjava/statistics/Counter.java | 4 +- .../statistics/StatisticsCounters.java | 8 +- .../SwitchConnectionProviderModule.java | 12 +- ...nflow-switch-connection-provider-impl.yang | 4 +- .../core/DelegatingInboundHandlerTest.java | 4 +- .../protocol/impl/core/DummyDecoder.java | 2 +- .../protocol/impl/core/IdleHandlerTest.java | 8 +- .../impl/core/OFDecoderStatisticsTest.java | 4 +- .../protocol/impl/core/OFDecoderTest.java | 8 +- .../impl/core/OFFrameDecoderTest.java | 2 +- .../impl/core/OFVersionDetectorTest.java | 8 +- .../PublishingChannelInitializerTest.java | 4 +- .../impl/core/SslContextFactoryTest.java | 2 +- .../protocol/impl/core/SslKeyStoreTest.java | 4 +- .../core/VersionMessageUdpWrapperTest.java | 4 +- .../ChannelOutboundQueue02Test.java | 2 +- .../ConnectionAdapterFactoryImplTest.java | 4 +- .../ConnectionAdapterImp02lTest.java | 2 +- .../ConnectionConfigurationImpl.java | 4 +- .../core/connection/RpcResponseKeyTest.java | 6 +- .../SwitchConnectionProviderImpl02Test.java | 22 +- .../UdpMessageListenerWrapperTest.java | 4 +- .../DeserializerRegistryImplTest.java | 2 +- .../MessageTypeCodeKeyTest.java | 2 +- .../deserialization/TypeToClassKeyTest.java | 2 +- .../EchoReplyMessageFactoryTest.java | 4 +- .../EchoRequestMessageFactoryTest.java | 2 +- .../factories/ErrorMessageFactoryTest.java | 4 +- .../ExperimenterMessageFactoryTest.java | 2 +- .../FlowRemovedMessageFactoryTest.java | 4 +- .../GetAsyncReplyMessageFactoryTest.java | 2 +- .../GetConfigReplyMessageFactoryTest.java | 4 +- .../factories/HelloMessageFactoryTest.java | 2 +- .../MultipartReplyMessageFactoryTest.java | 512 ++++++++-------- .../OF10EchoReplyMessageFactoryTest.java | 4 +- .../OF10EchoRequestMessageFactoryTest.java | 2 +- .../OF10FeaturesReplyMessageFactoryTest.java | 2 +- .../OF10GetConfigReplyMessageFactoryTest.java | 4 +- .../OF10PacketInMessageFactoryTest.java | 6 +- .../OF10PortStatusMessageFactoryTest.java | 2 +- .../OF10StatsReplyMessageFactoryTest.java | 106 ++-- .../factories/PacketInMessageFactoryTest.java | 6 +- .../PortStatusMessageFactoryTest.java | 6 +- ...QueueGetConfigReplyMessageFactoryTest.java | 6 +- .../RoleReplyMessageFactoryTest.java | 2 +- .../match/OxmIpv6FlabelDeserializerTest.java | 2 +- .../match/OxmMetadataDeserializerTest.java | 2 +- .../match/OxmVlanVidDeserializerTest.java | 2 +- .../SerializerRegistryImplTest.java | 6 +- .../BarrierInputMessageFactoryTest.java | 6 +- .../EchoInputMessageFactoryTest.java | 8 +- .../EchoReplyInputMessageFactoryTest.java | 6 +- .../ExperimenterInputMessageFactoryTest.java | 12 +- .../FlowModInputMessageFactoryTest.java | 6 +- .../GetConfigInputMessageFactoryTest.java | 12 +- .../GetFeaturesInputMessageFactoryTest.java | 8 +- ...GetQueueConfigInputMessageFactoryTest.java | 4 +- .../GetaAsyncRequestMessageFactoryTest.java | 6 +- .../GroupModInputMessageFactoryTest.java | 6 +- .../HelloInputMessageFactoryTest.java | 30 +- .../MeterModInputMessageFactoryTest.java | 20 +- .../OF10BarrierInputMessageFactoryTest.java | 6 +- .../OF10FlowModInputMessageFactoryTest.java | 6 +- .../OF10HelloInputMessageFactoryTest.java | 6 +- .../OF10PacketOutInputMessageFactoryTest.java | 8 +- .../OF10PortModInputMessageFactoryTest.java | 6 +- ...QueueGetConfigInputMessageFactoryTest.java | 6 +- .../OF10StatsRequestInputFactoryTest.java | 32 +- .../PacketOutInputMessageFactoryTest.java | 8 +- .../PortModInputMessageFactoryTest.java | 16 +- .../RoleRequestInputMessageFactoryTest.java | 6 +- .../SetAsyncInputMessageFactoryTest.java | 6 +- .../SetConfigMessageFactoryTest.java | 14 +- .../TableModInputMessageFactoryTest.java | 8 +- .../MultipartRequestGroupDescTest.java | 2 +- .../MultipartRequestGroupFeaturesTest.java | 2 +- .../MultipartRequestMeterFeaturesTest.java | 2 +- .../MultipartRequestPortDescTest.java | 2 +- .../multipart/MultipartRequestTableTest.java | 2 +- .../OF10StatsRequestAggregateTest.java | 2 +- .../match/OxmArpOpSerializerTest.java | 4 +- .../match/OxmArpShaSerializerTest.java | 10 +- .../match/OxmArpSpaSerializerTest.java | 10 +- .../match/OxmArpThaSerializerTest.java | 10 +- .../match/OxmArpTpaSerializerTest.java | 10 +- .../match/OxmEthDstSerializerTest.java | 10 +- .../match/OxmEthSrcSerializerTest.java | 10 +- .../match/OxmEthTypeSerializerTest.java | 6 +- .../match/OxmIcmpv4CodeSerializerTest.java | 6 +- .../match/OxmIcmpv4TypeSerializerTest.java | 6 +- .../match/OxmIcmpv6CodeSerializerTest.java | 4 +- .../match/OxmIcmpv6TypeSerializerTest.java | 6 +- .../match/OxmIpDscpSerializerTest.java | 4 +- .../match/OxmIpProtoSerializerTest.java | 4 +- .../match/OxmIpv4DstSerializerTest.java | 10 +- .../match/OxmIpv4SrcSerializerTest.java | 10 +- .../match/OxmIpv6ExtHdrSerializerTest.java | 10 +- .../match/OxmIpv6NdSllSerializerTest.java | 4 +- .../match/OxmIpv6NdTllSerializerTest.java | 4 +- .../match/OxmMetadataSerializerTest.java | 10 +- .../match/OxmMplsBosSerializerTest.java | 6 +- .../match/OxmMplsLabelSerializerTest.java | 4 +- .../match/OxmMplsTcSerializerTest.java | 4 +- .../match/OxmPbbIsidSerializerTest.java | 10 +- .../match/OxmSctpDstSerializerTest.java | 4 +- .../match/OxmSctpSrcSerializerTest.java | 4 +- .../match/OxmTcpDstSerializerTest.java | 4 +- .../match/OxmTcpSrcSerializerTest.java | 4 +- .../match/OxmTunnelIdSerializerTest.java | 10 +- .../match/OxmUdpDstSerializerTest.java | 4 +- .../match/OxmUdpSrcSerializerTest.java | 4 +- .../match/OxmVlanPcpSerializerTest.java | 4 +- .../match/OxmVlanVidSerializerTest.java | 8 +- .../impl/util/ActionsDeserializerTest.java | 6 +- .../protocol/impl/util/BufferHelper.java | 20 +- .../util/InstructionsDeserializerTest.java | 4 +- .../impl/util/MatchDeserializerTest.java | 56 +- .../util/OF10ActionsDeserializerTest.java | 4 +- .../impl/util/OF10ActionsSerializerTest.java | 8 +- .../impl/util/OF10MatchDeserializerTest.java | 2 +- .../impl/util/OF10MatchSerializerTest.java | 6 +- .../impl/util/OF13ActionsSerializerTest.java | 6 +- .../util/OF13InstructionsSerializerTest.java | 4 +- .../impl/util/OF13MatchSerializer02Test.java | 22 +- .../impl/util/OF13MatchSerializerTest.java | 28 +- .../statistics/StatisticsCountersTest.java | 4 +- openflow-protocol-it/pom.xml | 2 +- .../it/integration/IntegrationTest.java | 22 +- .../protocol/it/integration/MockPlugin.java | 20 +- openflow-protocol-spi/pom.xml | 6 +- .../connection/SwitchConnectionProvider.java | 6 +- .../spi/statistics/StatisticsHandler.java | 2 +- openflowjava-config/pom.xml | 6 +- pom.xml | 4 +- simple-client/pom.xml | 4 +- .../impl/clients/ClientSslContextFactory.java | 6 +- .../protocol/impl/clients/OFClient.java | 2 +- .../impl/clients/ScenarioFactory.java | 2 +- .../impl/clients/ScenarioHandler.java | 6 +- .../protocol/impl/clients/SendEvent.java | 2 +- .../protocol/impl/clients/SimpleClient.java | 4 +- .../impl/clients/SimpleClientHandler.java | 2 +- .../impl/clients/SimpleClientInitializer.java | 4 +- .../protocol/impl/clients/SleepEvent.java | 4 +- .../impl/clients/UdpSimpleClient.java | 6 +- .../clients/UdpSimpleClientInitializer.java | 4 +- .../impl/clients/WaitForMessageEvent.java | 2 +- .../openflowjava/util/ByteBufUtilsTest.java | 38 +- 235 files changed, 1406 insertions(+), 1406 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 6b580791..894173aa 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -60,7 +60,7 @@ - org.eclipse.m2e diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 50a85fbc..82b7a896 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -27,12 +27,12 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * @return future set to true, when disconnect completed */ Future disconnect(); - + /** * @return true, if connection to switch is alive */ boolean isAlive(); - + /** * @return address of the remote end - address of a switch if connected */ @@ -41,7 +41,7 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * @param messageListener here will be pushed all messages from switch */ void setMessageListener(OpenflowProtocolListener messageListener); - + /** * @param systemListener here will be pushed all system messages from library */ @@ -58,7 +58,7 @@ public interface ConnectionAdapter extends OpenflowProtocolService { void fireConnectionReadyNotification(); /** - * set listener for connection became ready-to-use event + * set listener for connection became ready-to-use event * @param connectionReadyListener */ void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index 243f2d93..cfb04293 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -23,32 +23,32 @@ public interface ConnectionConfiguration { * @return address to bind, if null, all available interfaces will be used */ InetAddress getAddress(); - + /** * @return port to bind */ int getPort(); - + /** * @return transport protocol to use */ Object getTransferProtocol(); - + /** * @return TLS configuration object */ TlsConfiguration getTlsConfiguration(); - + /** - * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream + * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream */ long getSwitchIdleTimeout(); - + /** * @return seed for {@link SSLEngine} */ Object getSslContext(); - + /** * @return thread numbers for TcpHandler's eventloopGroups */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ListeningStatusProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ListeningStatusProvider.java index 6de6675b..f54b7c2c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ListeningStatusProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ListeningStatusProvider.java @@ -17,7 +17,7 @@ public interface ListeningStatusProvider { /** - * @return future holding startup result of all library instances under plugin's control + * @return future holding startup result of all library instances under plugin's control */ Future isOnline(); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java index e5b25d40..daf87069 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/StatisticsConfiguration.java @@ -10,7 +10,7 @@ /** * Used for StatisticsCounter configuration - * + * * @author madamjak */ public interface StatisticsConfiguration { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java index c5f26fc1..363e3245 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java @@ -17,12 +17,12 @@ * */ public interface SwitchConnectionHandler { - + /** * @param connection to switch proving message sending/receiving, connection management */ void onSwitchConnected(ConnectionAdapter connection); - + /** * @param switchAddress * @return true, if connection from switch having given address shell be accepted; false otherwise diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index 84eeab3e..6676dd02 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -22,17 +22,17 @@ public interface TlsConfiguration { * @return keystore location */ String getTlsKeystore(); - + /** * @return keystore type */ KeystoreType getTlsKeystoreType(); - + /** * @return truststore location */ String getTlsTruststore(); - + /** * @return truststore type */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index f8f3c1b3..516113b8 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -25,7 +25,7 @@ * instructions, match entries, ... ) which are differentiated by * vendor / experimenter subtype, vendor has to switch / choose between * these subtypes.
- * + * * This has to be done in this way because of experimenter headers, which * provide only vendor / experimenter ID. Subtype position may be different * for different vendors (or not present at all) - that's why vendor has to diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 3b647a49..aa92ea08 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -30,10 +30,10 @@ public interface DeserializerRegistry { * Registers deserializer. * Throws IllegalStateException when there is * a deserializer already registered under given key. - * + * * If the deserializer implements {@link DeserializerRegistryInjector} interface, * the deserializer is injected with DeserializerRegistry instance. - * + * * @param key used for deserializer lookup * @param deserializer deserializer instance */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index c0f17c6a..1f987218 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -35,7 +35,7 @@ public int hashCode() { result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); return result; } - + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index 855b2f69..1d105f39 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -13,13 +13,13 @@ /** * @author michal.polkorab - * @param + * @param */ public interface HeaderDeserializer extends OFGeneralDeserializer { /** * Deserializes byte message headers - * + * * @param rawMessage message as bytes in ByteBuf * @return POJO/DTO */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java index 2e1d0189..bf45cd10 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java @@ -19,7 +19,7 @@ public class MessageTypeKey { private final Class msgType; private final short msgVersion; - + /** * @param msgVersion protocol version * @param msgType type of message - class of serialized object @@ -28,7 +28,7 @@ public MessageTypeKey(short msgVersion, Class msgType) { this.msgType = msgType; this.msgVersion = msgVersion; } - + @Override public String toString() { return "msgVersion: " + msgVersion + " objectType: " + msgType.getName(); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java index 25a04ac3..a49d84c3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java @@ -22,7 +22,7 @@ public interface OFDeserializer extends OFGeneralDeseriali /** * Transforms byte message into POJO/DTO (of type E). - * + * * @param message message as bytes in ByteBuf * @return POJO/DTO */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index b5bb0c2c..f4325cff 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -27,7 +27,7 @@ * instructions, match entries, ... ) which are differentiated by * vendor / experimenter subtype, vendor has to switch / choose between * these subtypes.
- * + * * This has to be done in this way because of unknown augmentations * - that's why vendor has to handle it in his own implementations. * @author michal.polkorab diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 30141911..eaa52c3d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -11,7 +11,7 @@ /** - * Stores and handles serializers + * Stores and handles serializers * @author michal.polkorab * */ @@ -26,17 +26,17 @@ public interface SerializerRegistry { * @param msgTypeKey lookup key * @return serializer or NullPointerException if no serializer was found */ - SERIALIZERTYPE + SERIALIZERTYPE getSerializer(MessageTypeKey msgTypeKey); /** * Registers serializer * Throws IllegalStateException when there is * a serializer already registered under given key. - * + * * If the serializer implements {@link SerializerRegistryInjector} interface, * the serializer is injected with SerializerRegistry instance. - * + * * @param key used for serializer lookup * @param serializer serializer implementation */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index f7ebcb3c..cb08cd92 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -21,7 +21,7 @@ public class InstructionDeserializerKey extends MessageCodeKey { /** * @param version protocol wire version * @param type instruction type - * @param experimenterId + * @param experimenterId */ public InstructionDeserializerKey(short version, int type, Long experimenterId) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java index 3b599b43..cbb23632 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -15,7 +15,7 @@ * @author michal.polkorab * */ -public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey +public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey implements ExperimenterDeserializerKey { /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index e5c9c806..eef5f106 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -15,7 +15,7 @@ /** * @author michal.polkorab */ -public final class ExperimenterActionSerializerKey extends ActionSerializerKey +public final class ExperimenterActionSerializerKey extends ActionSerializerKey implements ExperimenterSerializerKey { private Class actionSubType; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java index cb00362e..cafde379 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -16,7 +16,7 @@ * @author michal.polkorab * */ -public final class ExperimenterIdDeserializerKey extends MessageCodeKey +public final class ExperimenterIdDeserializerKey extends MessageCodeKey implements ExperimenterDeserializerKey { private Long experimenterId; @@ -32,7 +32,7 @@ public ExperimenterIdDeserializerKey(short version, this.experimenterId = experimenterId; } - + @Override public int hashCode() { final int prime = 31; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java index b15a1173..5abe45ee 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -20,7 +20,7 @@ public final class ExperimenterInstructionDeserializerKey extends InstructionDes /** * @param version protocol wire version - * @param experimenterId + * @param experimenterId */ public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java index 171a684d..aa322f91 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java @@ -21,7 +21,7 @@ public abstract class BinContent { public static long intToUnsignedLong(int value) { return value & 0x00000000ffffffffL; } - + /** * @param value * @return long cut into int diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index bbd881e2..cf857285 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -26,7 +26,7 @@ public abstract class EncodeConstants { public static final int OFHEADER_SIZE = 8; /** Zero length - used when the length is updated later */ public static final int EMPTY_LENGTH = 0; - + /** Length of mac address */ public static final byte MAC_ADDRESS_LENGTH = 6; /** Number of groups in ipv4 address */ diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 482c1228..0f579fa0 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-action { namespace "urn:opendaylight:openflow:common:action"; prefix "ofaction"; @@ -92,7 +92,7 @@ container actions-container { uses actions-grouping; } - + grouping actions-grouping { list action { config false; @@ -103,7 +103,7 @@ } } } - + // OF1.0 structures identity set_vlan_vid { description "Set the 802.1q VLAN id (OF v1.0)."; diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 9a545416..229d5f5a 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -5,11 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-augments { namespace "urn:opendaylight:openflow:augments"; prefix "aug"; - + import yang-ext {prefix ext;} import ietf-inet-types {prefix inet;} import ietf-yang-types {prefix yang;} @@ -21,8 +21,8 @@ import openflow-extensible-match {prefix oxm;} revision "2013-10-02" { - description "OpenFlow 1.3 - augments model. - Please visit + description "OpenFlow 1.3 - augments model. + Please visit https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf - Augmentation Tables chapter"; } @@ -354,7 +354,7 @@ type oft:experimenter-id; } } - + // OFP_QUEUE_PROP AUGMENTS augment "/ofproto:queue-prop-container/ofproto:queue-property" { ext:augment-identifier "rate-queue-property"; @@ -368,7 +368,7 @@ type oft:experimenter-id; } } - + // OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) augment "/ofproto:error-message" { ext:augment-identifier "experimenter-id-error"; diff --git a/openflow-protocol-api/src/main/yang/openflow-configuration.yang b/openflow-protocol-api/src/main/yang/openflow-configuration.yang index 38d8d58b..790a151b 100644 --- a/openflow-protocol-api/src/main/yang/openflow-configuration.yang +++ b/openflow-protocol-api/src/main/yang/openflow-configuration.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-configuration { namespace "urn:opendaylight:openflow:config"; prefix "of-config"; @@ -17,11 +17,11 @@ typedef path-type { type enumeration { enum CLASSPATH { - value 0; + value 0; description "Keystore file is located on classpath."; } enum PATH { - value 1; + value 1; description "Keystore file is located on absolute or relative path."; } } @@ -30,11 +30,11 @@ typedef keystore-type { type enumeration { enum JKS { - value 0; + value 0; description "Keystore type - JKS."; } enum PKCS12 { - value 1; + value 1; description "Keystore type - PKCS12."; } } diff --git a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang index e265eb09..e1f5514f 100644 --- a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang +++ b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-extensible-match { namespace "urn:opendaylight:openflow:oxm"; prefix "oxm"; @@ -19,12 +19,12 @@ } identity oxm-match-type { - description + description "The OpenFlow Extensible Match type must be supported by all OpenFlow switches."; base oft:match-type-base; } - + // oxm classes identity oxm-class-base { description "Base identity for OXM classes"; @@ -43,7 +43,7 @@ base oxm-class-base; } identity experimenter-class { - description + description "Marks Experimenter match type class. All experimenter match classes MUST use this class as a base."; base oxm-class-base; @@ -229,7 +229,7 @@ container oxm-container { uses oxm-fields-grouping; } - + grouping oxm-fields-grouping { list match-entries { description "OXM TLV-structures (Type Length Value)"; @@ -246,7 +246,7 @@ } leaf has-mask { type boolean; - } + } } } @@ -330,5 +330,5 @@ } } } - + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-instruction.yang b/openflow-protocol-api/src/main/yang/openflow-instruction.yang index 80f74a83..671556e1 100644 --- a/openflow-protocol-api/src/main/yang/openflow-instruction.yang +++ b/openflow-protocol-api/src/main/yang/openflow-instruction.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-instruction { namespace "urn:opendaylight:openflow:common:instruction"; prefix "ofinstruction"; diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 9330fac6..34f21818 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -5,13 +5,13 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-protocol { namespace "urn:opendaylight:openflow:protocol"; prefix "ofproto"; import ietf-yang-types {prefix yang;} - + import openflow-types {prefix oft;} import openflow-extensible-match { prefix oxm;} import openflow-instruction { prefix ofinstruction;} @@ -55,7 +55,7 @@ } leaf peer-features { description "Features advertised by peer."; - type oft:port-features; + type oft:port-features; } leaf curr-speed { description "Current port bitrate in kbps."; @@ -72,7 +72,7 @@ leaf config-v10 { type oft:port-config-v10; } - leaf state-v10 { + leaf state-v10 { type oft:port-state-v10; } leaf current-features-v10 { @@ -87,9 +87,9 @@ description "Features supported by the port."; type oft:port-features-v10; } - leaf peer-features-v10 { + leaf peer-features-v10 { description "Features advertised by peer."; - type oft:port-features-v10; + type oft:port-features-v10; } } @@ -121,7 +121,7 @@ uses ofaction:actions-grouping; } - + container table-features-properties-container { uses table-features-properties-grouping; } @@ -159,10 +159,10 @@ reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; /* Symmetric message */ uses ofHeader; - + list elements { uses ofHelloElementHeader; - + leaf-list version-bitmap { type boolean; } @@ -172,7 +172,7 @@ reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; /* Symmetric message */ uses ofHeader; - + leaf type { type uint16; } @@ -186,14 +186,14 @@ type string; } leaf data { - type binary; + type binary; } } grouping echo-request { reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; /* Symmetric message */ uses ofHeader; - + leaf data { type binary; } @@ -202,7 +202,7 @@ reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"; /* Symmetric message */ uses ofHeader; - + leaf data { type binary; } @@ -211,7 +211,7 @@ reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; /* Symmetric message */ uses ofHeader; - + leaf experimenter { type oft:experimenter-id; } @@ -229,7 +229,7 @@ reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf datapathId { type uint64; } @@ -268,7 +268,7 @@ reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf flags { type oft:switch-config-flag; } @@ -279,9 +279,9 @@ grouping set-config { reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + leaf flags { type oft:switch-config-flag; } @@ -293,9 +293,9 @@ grouping packet-in { reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"; /* Async message */ - + uses ofHeader; - + leaf buffer-id { // ID assigned by datapath. type uint32; @@ -305,7 +305,7 @@ type uint16; } leaf reason { - // Reason packet is being sent (one of OFPR_*) + // Reason packet is being sent (one of OFPR_*) type oft:packet-in-reason; } leaf table-id { @@ -321,7 +321,7 @@ leaf data { type binary; } - + // OF1.0 structures leaf in-port { type uint16; @@ -331,7 +331,7 @@ reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"; /* Async message */ uses ofHeader; - + leaf cookie { type uint64; } @@ -363,17 +363,17 @@ type uint64; } uses oxm:match-grouping; - + // OF1.0 structures uses oxm:match-v10-grouping; - } + } grouping port-status { reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"; - + uses ofHeader; - + uses port-grouping; - + leaf reason { type oft:port-reason; } @@ -382,11 +382,11 @@ grouping packet-out { reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + uses ofaction:actions-grouping; - + leaf data { type binary; } @@ -396,13 +396,13 @@ leaf in-port { type oft:port-number; } - } + } grouping flow-mod { reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + leaf cookie { type uint64; } @@ -437,22 +437,22 @@ type oft:flow-mod-flags; } uses oxm:match-grouping; - + uses ofinstruction:instructions-grouping; - + // OF1.0 structures leaf flags-v10 { type oft:flow-mod-flags-v10; } uses oxm:match-v10-grouping; uses ofaction:actions-grouping; - } + } grouping group-mod { reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + leaf command { type oft:group-mod-command; } @@ -462,25 +462,25 @@ leaf group-id { type oft:group-id; } - + uses buckets-grouping; } - + grouping port-mod { reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf port-no { type oft:port-number; } leaf hw-address { type yang:mac-address; - } + } leaf config { type oft:port-config; - } + } leaf mask { type oft:port-config; } @@ -497,28 +497,28 @@ leaf advertise-v10 { type oft:port-features-v10; } - } + } grouping table-mod { reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf table-id { type oft:table-id; } leaf config { type oft:table-config; } - } - + } + /* Multipart messages. */ grouping multipart-request { reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf type { type oft:multipart-type; } @@ -551,7 +551,7 @@ type uint64; } uses oxm:match-grouping; - + // OF1.0 structures uses oxm:match-v10-grouping; } @@ -574,7 +574,7 @@ type uint64; } uses oxm:match-grouping; - + // OF1.0 structures uses oxm:match-v10-grouping; } @@ -683,13 +683,13 @@ } } } - } + } grouping multipart-reply { reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf type { type oft:multipart-type; } @@ -750,9 +750,9 @@ type uint64; } uses oxm:match-grouping; - + uses ofinstruction:instructions-grouping; - + // OF1.0 structures uses oxm:match-v10-grouping; uses ofaction:actions-grouping; @@ -787,7 +787,7 @@ leaf matched-count { type uint64; } - + // OF1.0 structures leaf name { type string; @@ -1029,7 +1029,7 @@ } leaf config { type oft:table-config; - } + } leaf max-entries { type uint32; } @@ -1050,35 +1050,35 @@ } } } - } + } /* Barrier messages. */ grouping barrier-request { reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - } + } grouping barrier-reply { reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - } + } /* Queue Configuration messages. */ grouping queue-get-config-request { reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + leaf port { type oft:port-number; } - } + } grouping queue-get-config-reply { reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf port { type oft:port-number; } @@ -1110,51 +1110,51 @@ grouping role-request { reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; - + leaf role { type oft:controller-role; } leaf generation-id { type uint64; } - } + } grouping role-reply { reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - + leaf role { type oft:controller-role; } leaf generation-id { type uint64; } - } + } /* Asynchronous message configuration. */ grouping get-async-request { reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; - } + } grouping get-async-reply { reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ uses ofHeader; uses async-body-grouping; - } + } grouping set-async { reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"; /* Controller/switch message */ - + uses ofHeader; uses async-body-grouping; } - + grouping async-body-grouping { list packet-in-mask { leaf-list mask { @@ -1178,10 +1178,10 @@ /* Controller/switch message */ uses ofHeader; - + leaf command { type oft:meter-mod-command; - } + } leaf flags { type oft:meter-flags; } @@ -1192,7 +1192,7 @@ uses meter-band-header; } } - + container meter-band-container { uses meter-band-header; } @@ -1218,7 +1218,7 @@ } } } - + grouping meter-band-commons { leaf type { type oft:meter-band-type; @@ -1235,19 +1235,19 @@ notification hello-message { uses hello; reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; - + /* Symmetric message */ } notification error-message { uses error; reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; - + /* Symmetric message */ } notification echo-request-message { uses echo-request; reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; - + /* Symmetric message */ } notification experimenter-message { @@ -1267,19 +1267,19 @@ uses echo-reply; } } - + rpc echo-reply { input { uses echo-reply; } } - + rpc hello { input { uses hello; } } - + rpc experimenter { input { uses experimenter; @@ -1296,7 +1296,7 @@ uses features-reply; } } - + rpc get-config { input { uses get-config-request; @@ -1306,27 +1306,27 @@ } /* Controller/switch message */ } - + rpc set-config { input { uses set-config; - } + } /* Controller/switch message */ } /* Asynchronous messages. */ notification packet-in-message { uses packet-in; - + /* Async message */ } notification flow-removed-message { uses flow-removed; - + /* Async message */ - } + } notification port-status-message { uses port-status; - + } /* Async message */ /* Controller command messages. */ @@ -1335,25 +1335,25 @@ uses packet-out; } /* Controller/switch message */ - } + } rpc flow-mod { input { uses flow-mod; } /* Controller/switch message */ - } + } rpc group-mod { input { uses group-mod; } /* Controller/switch message */ - } + } rpc port-mod { input { uses port-mod; } } /* Controller/switch message */ - + rpc table-mod { input { uses table-mod; @@ -1373,7 +1373,7 @@ uses multipart-reply; // notification because of multiple following responses } /* Controller/switch message */ - + /* Barrier messages. */ rpc barrier { @@ -1392,7 +1392,7 @@ output { uses queue-get-config-reply; } - } + } /* Controller role change request messages. */ rpc role-request { @@ -1403,7 +1403,7 @@ uses role-reply; } } /* Controller/switch message */ - + /* Asynchronous message configuration. */ rpc get-async { input { @@ -1412,14 +1412,14 @@ output { uses get-async-reply; } - } + } /* Controller/switch message */ rpc set-async { - input { + input { uses set-async; } - - } + + } /* Meters and rate limiters configuration messages. */ rpc meter-mod { input { diff --git a/openflow-protocol-api/src/main/yang/openflow-types.yang b/openflow-protocol-api/src/main/yang/openflow-types.yang index 1a024089..be0e9f5d 100644 --- a/openflow-protocol-api/src/main/yang/openflow-types.yang +++ b/openflow-protocol-api/src/main/yang/openflow-types.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module openflow-types { namespace "urn:opendaylight:openflow:common:types"; prefix "oft"; @@ -19,7 +19,7 @@ supports special / reserved values (in OF v1.3)"; type uint32; } - + typedef port-number-values { description "Reserved OpenFlow Port (fake output \"ports\") (OF v1.3)."; type enumeration { @@ -38,20 +38,20 @@ description "Submit the packet to the first flow table NB: This destination port can only be used in packet-out messages."; - value -7; // 0xfffffff9 + value -7; // 0xfffffff9 } enum NORMAL { description "Process with normal L2/L3 switching."; - value -6; // 0xfffffffa + value -6; // 0xfffffffa } enum FLOOD { description "All physical ports in VLAN, except input port and those blocked or link down."; - value -5; // 0xfffffffb + value -5; // 0xfffffffb } enum ALL { description "All physical ports except input port."; - value -4; // 0xfffffffc + value -4; // 0xfffffffc } enum CONTROLLER { description "Send to controller."; @@ -63,7 +63,7 @@ } enum ANY { description "Wildcard port used only for flow mod - (delete) and flow stats requests. Selects + (delete) and flow stats requests. Selects all flows regardless of output port (including flows with no output port)."; value -1; // 0xffffffff @@ -74,67 +74,67 @@ typedef port-features { description "Features of ports available in datapath."; type bits { - bit _10mb_hd { + bit _10mb_hd { position 0; description "10 Mb half-duplex rate support."; } - bit _10mb-fd { + bit _10mb-fd { position 1; description "10 Mb full-duplex rate support."; } - bit _100mb-hd { + bit _100mb-hd { position 2; description "100 Mb half-duplex rate support."; } - bit _100mb-fd { + bit _100mb-fd { position 3; description "100 Mb full-duplex rate support."; } - bit _1gb-hd { + bit _1gb-hd { position 4; description "1 Gb half-duplex rate support."; } - bit _1gb-fd { + bit _1gb-fd { position 5; description "1 Gb full-duplex rate support."; } - bit _10gb-fd { + bit _10gb-fd { position 6; description "10 Gb full-duplex rate support."; } - bit _40gb-fd { + bit _40gb-fd { position 7; description "40 Gb full-duplex rate support."; } - bit _100gb-fd { + bit _100gb-fd { position 8; description "100 Gb full-duplex rate support."; } - bit _1tb-fd { + bit _1tb-fd { position 9; description "1 Tb full-duplex rate support."; } - bit other { + bit other { position 10; description "Other rate, not in the list."; } - bit copper { + bit copper { position 11; description "Copper medium."; } - bit fiber { + bit fiber { position 12; description "Fiber medium."; } - bit autoneg { + bit autoneg { position 13; description "Auto-negotiation."; } - bit pause { + bit pause { position 14; description "Pause."; } - bit pause-asym { + bit pause-asym { position 15; description "Asymmetric pause."; } @@ -142,24 +142,24 @@ } typedef port-config { - description + description "Flags to indicate behavior of the physical port. These flags are - describe the current configuration and used port_mod message + describe the current configuration and used port_mod message to configure the port's behavior."; type bits { - bit port-down { + bit port-down { //description " Port is administratively down."; position 0; } - bit no-recv { + bit no-recv { //description " Drop all packets received by port."; position 2; } - bit no-fwd { + bit no-fwd { //description " Drop packets forwarded to port."; position 5; } - bit no-packet-in { + bit no-packet-in { //description "Do not send packet-in msgs for port."; position 6; } @@ -167,7 +167,7 @@ } typedef port-state { - description + description "Current state of the physical port. These are not configurable from the controller."; type bits { @@ -187,10 +187,10 @@ } identity match-type-base { - description + description "The match type indicates the match structure (set of fields that compose the match) in use. The match type is placed in the type field at the beginning - of all match structures.Extensions that define match types may be + of all match structures.Extensions that define match types may be published on the ONF wiki. Support for extensions is optional."; } @@ -236,363 +236,363 @@ typedef error-type { type enumeration { enum HELLO_FAILED { - value 0; + value 0; description "Hello Protocol failed."; } enum BAD_REQUEST { - value 1; + value 1; description "Request was not understood."; } enum BAD_ACTION { - value 2; + value 2; description "Error in action description."; } enum BAD_INSTRUCTION { - value 3; + value 3; description "Error in instruction list."; } enum BAD_MATCH { - value 4; + value 4; description "Error in match."; } enum FLOW_MOD_FAILED { - value 5; + value 5; description "Problem modifying flow entry."; } enum GROUP_MOD_FAILED { - value 6; + value 6; description "Problem modifying group entry."; } enum PORT_MOD_FAILED { - value 7; + value 7; description "Port mod request failed."; } enum TABLE_MOD_FAILED { - value 8; + value 8; description "Table mod request failed."; } enum QUEUE_OP_FAILED { - value 9; + value 9; description "Queue operation failed."; } enum SWITCH_CONFIG_FAILED { - value 10; + value 10; description "Switch config request failed."; } enum ROLE_REQUEST_FAILED { - value 11; + value 11; description "Controller Role request failed."; } enum METER_MOD_FAILED { - value 12; + value 12; description "Error in meter."; } enum TABLE_FEATURES_FAILED { - value 13; + value 13; description "Setting table features failed."; } enum EXPERIMENTER { - value 65535; //0xffff + value 65535; //0xffff description "Experimenter error messages."; } } } - + typedef hello-failed-code { type enumeration { enum INCOMPATIBLE { - value 0; + value 0; description "Hello Protocol failed."; } enum EPERM { - value 1; + value 1; description "Request was not understood."; } } } - + typedef bad-request-code { type enumeration { enum BAD_VERSION { - value 0; + value 0; } enum BAD_TYPE { - value 1; + value 1; } enum BAD_MULTIPART { - value 2; + value 2; } enum BAD_EXPERIMENTER { - value 3; + value 3; } enum BAD_EXP_TYPE { - value 4; + value 4; } enum EPERM { - value 5; + value 5; } enum BAD_LEN { - value 6; + value 6; } enum BUFFER_EMPTY { - value 7; + value 7; } enum BUFFER_UNKNOWN { - value 8; + value 8; } enum BAD_TABLE_ID { - value 9; + value 9; } enum IS_SLAVE { - value 10; + value 10; } enum BAD_PORT { - value 11; + value 11; } enum BAD_PACKET { - value 12; + value 12; } enum MULTIPART_BUFFER_OVERFLOW { - value 13; + value 13; } } } - + typedef bad-action-code { type enumeration { enum BAD_TYPE { - value 0; + value 0; } enum BAD_LEN { - value 1; + value 1; } enum BAD_EXPERIMENTER { - value 2; + value 2; } enum BAD_EXP_TYPE { - value 3; + value 3; } enum BAD_OUT_PORT { - value 4; + value 4; } enum BAD_ARGUMENT { - value 5; + value 5; } enum EPERM { - value 6; + value 6; } enum TOO_MANY { - value 7; + value 7; } enum BAD_QUEUE { - value 8; + value 8; } enum BAD_OUT_GROUP { - value 9; + value 9; } enum MATCH_INCONSISTENT { - value 10; + value 10; } enum UNSUPPORTED_ORDER { - value 11; + value 11; } enum BAD_TAG { - value 12; + value 12; } enum BAD_SET_TYPE { - value 13; + value 13; } enum BAD_SET_LEN { - value 14; + value 14; } enum BAD_SET_ARGUMENT { - value 15; + value 15; } } } - + typedef bad-instruction-code { type enumeration { enum UNKNOWN_INST { - value 0; + value 0; } enum UNSUP_INST { - value 1; + value 1; } enum BAD_TABLE_ID { - value 2; + value 2; } enum UNSUP_METADATA { - value 3; + value 3; } enum UNSUP_METADATA_MASK { - value 4; + value 4; } enum BAD_EXPERIMENTER { - value 5; + value 5; } enum BAD_EXP_TYPE { - value 6; + value 6; } enum BAD_LEN { - value 7; + value 7; } enum EPERM { - value 8; + value 8; } } } - + typedef bad-match-code { type enumeration { enum BAD_TYPE { - value 0; + value 0; } enum BAD_LEN { - value 1; + value 1; } enum BAD_TAG { - value 2; + value 2; } enum BAD_DL_ADDR_MASK { - value 3; + value 3; } enum BAD_NW_ADDR_MASK { - value 4; + value 4; } enum BAD_WILDCARDS { - value 5; + value 5; } enum BAD_FIELD { - value 6; + value 6; } enum BAD_VALUE { - value 7; + value 7; } enum BAD_MASK { - value 8; + value 8; } enum BAD_PREREQ { - value 9; + value 9; } enum DUP_FIELD { - value 10; + value 10; } enum EPERM { - value 11; + value 11; } } } - + typedef flow-mod-failed-code { type enumeration { enum UNKNOWN { - value 0; + value 0; } enum TABLE_FULL { - value 1; + value 1; } enum BAD_TABLE_ID { - value 2; + value 2; } enum OVERLAP { - value 3; + value 3; } enum EPERM { - value 4; + value 4; } enum BAD_TIMEOUT { - value 5; + value 5; } enum BAD_COMMAND { - value 6; + value 6; } enum BAD_FLAGS { - value 7; + value 7; } } } - + typedef group-mod-failed-code { type enumeration { enum GROUP_EXISTS { - value 0; + value 0; } enum INVALID_GROUP { - value 1; + value 1; } enum WEIGHT_UNSUPPORTED { - value 2; + value 2; } enum OUT_OF_GROUPS { - value 3; + value 3; } enum OUT_OF_BUCKETS { - value 4; + value 4; } enum CHAINING_UNSUPPORTED { - value 5; + value 5; } enum WATCH_UNSUPPORTED { - value 6; + value 6; } enum LOOP { - value 7; + value 7; } enum UNKNOWN_GROUP { - value 8; + value 8; } enum CHAINED_GROUP { - value 9; + value 9; } enum BAD_TYPE { - value 10; + value 10; } enum BAD_COMMAND { - value 11; + value 11; } enum BAD_BUCKET { - value 12; + value 12; } enum BAD_WATCH { - value 13; + value 13; } enum EPERM { - value 14; + value 14; } } } - + typedef port-mod-failed-code { type enumeration { enum BAD_PORT { - value 0; + value 0; } enum BAD_HW_ADDR { - value 1; + value 1; } enum BAD_CONFIG { - value 2; + value 2; } enum BAD_ADVERTISE { - value 3; + value 3; } enum EPERM { - value 4; + value 4; } } } - + typedef table-mod-failed-code { type enumeration { enum BAD_TABLE { - value 0; + value 0; } enum BAD_CONFIG { - value 1; + value 1; } enum EPERM { - value 2; + value 2; } } } @@ -600,125 +600,125 @@ typedef queue-op-failed-code { type enumeration { enum BAD_PORT { - value 0; + value 0; } enum BAD_QUEUE { - value 1; + value 1; } enum EPERM { - value 2; + value 2; } } } - + typedef switch-config-failed-code { type enumeration { enum BAD_FLAGS { - value 0; + value 0; } enum BAD_LEN { - value 1; + value 1; } enum EPERM { - value 2; + value 2; } } } - + typedef role-request-failed-code { type enumeration { enum STALE { - value 0; + value 0; } enum UNSUP { - value 1; + value 1; } enum BAD_ROLE { - value 2; + value 2; } } } - + typedef meter-mod-failed-code { type enumeration { enum UNKNOWN { - value 0; + value 0; } enum METER_EXISTS { - value 1; + value 1; } enum INVALID_METER { - value 2; + value 2; } enum UNKNOWN_METER { - value 3; + value 3; } enum BAD_COMMAND { - value 4; + value 4; } enum BAD_FLAGS { - value 5; + value 5; } enum BAD_RATE { - value 6; + value 6; } enum BAD_BURST { - value 7; + value 7; } enum BAD_BAND { - value 8; + value 8; } enum BAD_BAND_VALUE { - value 9; + value 9; } enum OUT_OF_METERS { - value 10; + value 10; } enum OUT_OF_BANDS { - value 11; + value 11; } } } - + typedef table-features-failed-code { type enumeration { enum BAD_TABLE { - value 0; + value 0; } enum BAD_METADATA { - value 1; + value 1; } enum BAD_TYPE { - value 2; + value 2; } enum BAD_LEN { - value 3; + value 3; } enum BAD_ARGUMENT { - value 4; + value 4; } enum EPERM { - value 5; + value 5; } } } - + typedef hello-element-type { type enumeration { enum VERSIONBITMAP { - value 1; + value 1; description "Bitmap of version supported."; } } } - + typedef capabilities { description "Capabilities supported by the datapath."; type bits { bit OFPC_FLOW_STATS { position 0; /* Flow statistics. */ - } + } bit OFPC_TABLE_STATS { position 1; /* Table statistics. */ @@ -750,19 +750,19 @@ description " Handling of IP fragments. "; type enumeration { enum FRAG_NORMAL { - value 0; + value 0; description "No special handling for fragments."; } enum OFPC_FRAG_DROP { - value 1; + value 1; description "Drop fragments."; } enum OFPC_FRAG_REASM { - value 2; + value 2; description "Reassemble (only if OFPC_IP_REASM set)."; } enum OFPC_FRAG_MASK { - value 3; + value 3; } } } @@ -908,7 +908,7 @@ } enum OFPTT_ALL { value 255; // 0xff - description "Wildcard table used for table config, + description "Wildcard table used for table config, flow stats and flow deletes."; } } @@ -928,7 +928,7 @@ } enum OFPG_ANY { value -1; //0xffffffff - description "Wildcard group used only for flow stats requests. + description "Wildcard group used only for flow stats requests. Selects all flows regardless of group (including flows with no group)"; } } @@ -1059,7 +1059,7 @@ description "Maximum datarate."; } enum OFPQT_EXPERIMENTER { - value 65535; // 0xffff + value 65535; // 0xffff description "Experimenter defined property."; } } @@ -1104,7 +1104,7 @@ } } } - + typedef action-type { /* ofp_action_type */ type bits { @@ -1232,7 +1232,7 @@ } } } - + typedef meter-band-type-bitmap { /* ofp_meter_band_type */ type bits { @@ -1283,67 +1283,67 @@ typedef table-features-prop-type { type enumeration { enum OFPTFPT_INSTRUCTIONS { - value 0; + value 0; description "Instructions property."; } enum OFPTFPT_INSTRUCTIONS_MISS { - value 1; + value 1; description "Instructions for table-miss."; } enum OFPTFPT_NEXT_TABLES { - value 2; + value 2; description "Next Table property."; } enum OFPTFPT_NEXT_TABLES_MISS { - value 3; + value 3; description "Next Table for table-miss."; } enum OFPTFPT_WRITE_ACTIONS { - value 4; + value 4; description "Write Actions property."; } enum OFPTFPT_WRITE_ACTIONS_MISS { - value 5; + value 5; description "Write Actions for table-miss."; } enum OFPTFPT_APPLY_ACTIONS { - value 6; + value 6; description "Apply Actions property."; } enum OFPTFPT_APPLY_ACTIONS_MISS { - value 7; + value 7; description "Apply Actions for table-miss."; } enum OFPTFPT_MATCH { - value 8; + value 8; description "Match property."; } enum OFPTFPT_WILDCARDS { - value 10; + value 10; description "Wildcards property."; } enum OFPTFPT_WRITE_SETFIELD { - value 12; + value 12; description "Write Set-Field property."; } enum OFPTFPT_WRITE_SETFIELD_MISS { - value 13; + value 13; description "Write Set-Field for table-miss."; } enum OFPTFPT_APPLY_SETFIELD { - value 14; + value 14; description "Apply Set-Field property."; } enum OFPTFPT_APPLY_SETFIELD_MISS { - value 15; + value 15; description "Apply Set-Field for table-miss."; } enum OFPTFPT_EXPERIMENTER { - value 65534; + value 65534; description "Experimenter property."; } enum OFPTFPT_EXPERIMENTER_MISS { - value 65535; //0xffff + value 65535; //0xffff description "Experimenter for table-miss."; } } @@ -1392,7 +1392,7 @@ } } } - + typedef ipv6-exthdr-flags { description "Bit definitions for IPv6 Extension Header pseudo-field."; type bits { @@ -1434,170 +1434,170 @@ } } } - + // OPENFLOW v1.0 STRUCTURES - // Structures under this line are needed to support OpenFlow version 1.0 + // Structures under this line are needed to support OpenFlow version 1.0 // wire protocol 0x01; - + typedef error-type-v10 { type enumeration { enum HELLO_FAILED { - value 0; + value 0; description "Hello Protocol failed."; } enum BAD_REQUEST { - value 1; + value 1; description "Request was not understood."; } enum BAD_ACTION { - value 2; + value 2; description "Error in action description."; } enum FLOW_MOD_FAILED { - value 3; + value 3; description "Problem modifying flow entry."; } enum PORT_MOD_FAILED { - value 4; + value 4; description "Port mod request failed."; } enum QUEUE_OP_FAILED { - value 5; + value 5; description "Queue operation failed."; } } } - + typedef hello-failed-code-v10 { type enumeration { enum INCOMPATIBLE { - value 0; + value 0; description "Hello Protocol failed."; } enum EPERM { - value 1; + value 1; description "Request was not understood."; } } } - + typedef bad-request-code-v10 { type enumeration { enum BAD_VERSION { - value 0; + value 0; } enum BAD_TYPE { - value 1; + value 1; } enum BAD_STAT { - value 2; + value 2; } enum BAD_VENDOR { - value 3; + value 3; } enum BAD_SUBTYPE { - value 4; + value 4; } enum EPERM { - value 5; + value 5; } enum BAD_LEN { - value 6; + value 6; } enum BUFFER_EMPTY { - value 7; + value 7; } enum BUFFER_UNKNOWN { - value 8; + value 8; } } } - + typedef bad-action-code-v10 { type enumeration { enum BAD_TYPE { - value 0; + value 0; } enum BAD_LEN { - value 1; + value 1; } enum VENDOR { - value 2; + value 2; } enum BAD_VENDOR_TYPE { - value 3; + value 3; } enum BAD_OUT_PORT { - value 4; + value 4; } enum BAD_ARGUMENT { - value 5; + value 5; } enum EPERM { - value 6; + value 6; } enum TOO_MANY { - value 7; + value 7; } enum BAD_QUEUE { - value 8; + value 8; } } } - + typedef flow-mod-failed-code-v10 { type enumeration { enum ALL_TABLES_FULL { - value 0; + value 0; } enum OVERLAP { - value 1; + value 1; } enum EPERM { - value 2; + value 2; } enum BAD_EMERG_TIMEOUT { - value 3; + value 3; } enum BAD_COMMAND { - value 4; + value 4; } enum UNSUPPORTED { - value 5; + value 5; } } } - + typedef port-mod-failed-code-v10 { type enumeration { enum BAD_PORT { - value 0; + value 0; } enum BAD_HW_ADDR { - value 1; + value 1; } } } - + typedef queue-op-failed-code-v10 { type enumeration { enum BAD_PORT { - value 0; + value 0; } enum BAD_QUEUE { - value 1; + value 1; } enum EPERM { - value 2; + value 2; } } } - + typedef port-number-values-v10 { description "Port numbering. Physical ports are numbered starting from 1."; type enumeration { enum MAX { - value 65280; // 0xff00 + value 65280; // 0xff00 } enum IN_PORT { description "Send the packet out the input port. This @@ -1610,20 +1610,20 @@ description "Perform actions in flow table. NB: This can only be the destination port for packet-out messages."; - value 65529; // 0xfff9 + value 65529; // 0xfff9 } enum NORMAL { description "Process with normal L2/L3 switching."; - value 65530; // 0xfffa + value 65530; // 0xfffa } enum FLOOD { description "All physical ports except input port and those disabled by STP."; - value 65531; // 0xfffb + value 65531; // 0xfffb } enum ALL { description "All physical ports except input port."; - value 65532; // 0xfffc + value 65532; // 0xfffc } enum CONTROLLER { description "Send to controller."; @@ -1639,14 +1639,14 @@ } } } - + typedef port-config-v10 { - description + description "Flags to indicate behavior of the physical port. These flags are - describe the current configuration and used port_mod message + describe the current configuration and used port_mod message to configure the port's behavior."; type bits { - bit port-down { + bit port-down { description " Port is administratively down."; position 0; } @@ -1654,29 +1654,29 @@ description "Disable 802.1D spanning tree on port."; position 1; } - bit no-recv { + bit no-recv { description " Drop all packets received by port."; position 2; } - bit no-recv-stp { + bit no-recv-stp { description " Drop received 802.1D STP packets."; position 3; } - bit no-flood { + bit no-flood { description " Do not include this port when flooding."; position 4; } - bit no-fwd { + bit no-fwd { description " Drop packets forwarded to port."; position 5; } - bit no-packet-in { + bit no-packet-in { description "Do not send packet-in msgs for port."; position 6; } } } - + typedef port-state-v10 { description "Current state of the physical port. These are not configurable from the controller."; @@ -1710,68 +1710,68 @@ } } } - + typedef port-features-v10 { description "Features of ports available in datapath."; reference "ofp_port_features"; type bits { - bit _10mb-hd { + bit _10mb-hd { position 0; description "10 Mb half-duplex rate support."; } - bit _10mb-fd { + bit _10mb-fd { position 1; description "10 Mb full-duplex rate support."; } - bit _100mb-hd { + bit _100mb-hd { position 2; description "100 Mb half-duplex rate support."; } - bit _100mb-fd { + bit _100mb-fd { position 3; description "100 Mb full-duplex rate support."; } - bit _1gb-hd { + bit _1gb-hd { position 4; description "1 Gb half-duplex rate support."; } - bit _1gb-fd { + bit _1gb-fd { position 5; description "1 Gb full-duplex rate support."; } - bit _10gb-fd { + bit _10gb-fd { position 6; description "10 Gb full-duplex rate support."; } - bit copper { + bit copper { position 7; description "Copper medium."; } - bit fiber { + bit fiber { position 8; description "Fiber medium."; } - bit autoneg { + bit autoneg { position 9; description "Auto-negotiation."; } - bit pause { + bit pause { position 10; description "Pause."; } - bit pause-asym { + bit pause-asym { position 11; description "Asymmetric pause."; } } } - + typedef capabilities-v10 { type bits { bit OFPC_FLOW_STATS { position 0; description "Flow statistics."; - } + } bit OFPC_TABLE_STATS { position 1; description "Table statistics."; @@ -1802,7 +1802,7 @@ } } } - + typedef flow-mod-flags-v10 { /* ofp_flow_mod_flags */ type bits { @@ -1820,7 +1820,7 @@ } } } - + typedef action-type-v10 { /* ofp_action_type */ type bits { @@ -1878,7 +1878,7 @@ } } } - + typedef flow-wildcards-v10 { /* ofp_flow_wildcards */ description "Flow wildcards - NW_SRC_MASK & NW_DST_MASK are handled separately"; @@ -1925,5 +1925,5 @@ } } } - + } diff --git a/openflow-protocol-api/src/main/yang/system-notifications.yang b/openflow-protocol-api/src/main/yang/system-notifications.yang index 4cbe17e7..b31dd02b 100644 --- a/openflow-protocol-api/src/main/yang/system-notifications.yang +++ b/openflow-protocol-api/src/main/yang/system-notifications.yang @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - + module system-notifications { namespace "urn:opendaylight:openflow:system"; prefix "ofs"; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index 82377828..edfa5721 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -47,7 +47,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test EnhancedMessageTypeKey equals - additional test */ @@ -55,7 +55,7 @@ public void test() { public void testEquals() { EnhancedMessageCodeKey key1 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index 40ff08cc..483597c6 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -49,7 +49,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test EnhancedMessageTypeKey equals - additional test */ @@ -59,10 +59,10 @@ public void testEquals() { EnhancedMessageTypeKey key2; key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 83f426c4..18a4a1e7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -48,7 +48,7 @@ public void test() { @Test public void testEquals() { MessageTypeKey key1; - MessageTypeKey key2; + MessageTypeKey key2; key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 6ba052b7..3b2be12c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -40,7 +40,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test ActionDeserializerKey equals - additional test */ diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index 043a3cfb..1a1021a1 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -47,7 +47,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } - + /** * Test ActionSerializerKey equals - additional test */ @@ -55,10 +55,10 @@ public void test() { public void testEquals(){ ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); - + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java index 208b4ff7..6b501a1c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -40,7 +40,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test InstructionDeserializerKey equals - additional test */ diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index 23aecd79..a51a2d70 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -47,7 +47,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } - + /** * Test InstructionSerializerKey equals - additional test */ diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index f270bd92..927ec5d5 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -42,7 +42,7 @@ public void testEqualsAndHashcodeOfDeserializerKeys() { EncodeConstants.OF13_VERSION_ID, 1L); Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey); Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode()); - + MatchEntryDeserializerKey matchKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP); MatchEntryDeserializerKey matchKey2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, @@ -78,7 +78,7 @@ public void testEqualsAndHashcodeOfActionDeserializerKeys() { Assert.assertEquals(matchKey, matchKey2); Assert.assertEquals(matchKey.hashCode(), matchKey2.hashCode()); } - + private static class ExpSubType extends ExperimenterActionSubType { // empty class - only used in test for comparation } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index 5c69cc65..c3d9cf90 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -46,7 +46,7 @@ public void test() { Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test MatchEntryDeserializerKey equals - additional test */ @@ -54,16 +54,16 @@ public void test() { public void testEquals() { MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + Long expId1=123456L; Long expId2=654321L; key1.setExperimenterId(null); key2.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - + key1.setExperimenterId(expId1); Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 0863db37..8bf98fda 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -56,9 +56,9 @@ public void test() { key2.setExperimenterId(42L); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } - + /** - * Test MatchEntrySerializerKey equals - additional test + * Test MatchEntrySerializerKey equals - additional test */ @Test public void testEquals(){ @@ -68,10 +68,10 @@ public void testEquals(){ key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - + Long expId1 = 987654331L; Long expId2 = 123456789L; - + key1.setExperimenterId(null); key2.setExperimenterId(expId2); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index c8111fbd..f287d3a3 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -60,7 +60,7 @@ public void testEquals() { Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); } - + private static class TestSubType extends ExperimenterActionSubType { // empty class - only used in test for comparation } @@ -68,6 +68,6 @@ private static class TestSubType extends ExperimenterActionSubType { private static class TestSubType2 extends ExperimenterActionSubType { // empty class - only used in test for comparation } - + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index 06f06cbf..e931d6a7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -48,7 +48,7 @@ public void test() { Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } - + /** * Test ExperimenterIdSerializerKey equals - additional test */ @@ -63,5 +63,5 @@ public void testEquals() { new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); } - + } \ No newline at end of file diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 8cc54c09..ba83903a 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -18,7 +18,7 @@ 0.7.0-SNAPSHOT 0.7.0-SNAPSHOT - + @@ -98,7 +98,7 @@ - + ${project.groupId} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java index 7328f8c7..042d4640 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java @@ -24,7 +24,7 @@ public class ChannelInitializerFactory { private SerializationFactory serializationFactory; private TlsConfiguration tlsConfig; private SwitchConnectionHandler switchConnectionHandler; - + /** * @return PublishingChannelInitializer that initializes new channels */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index 74e9c3a3..685985ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -79,7 +79,7 @@ protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); LOGGER.debug("length of actual message: {}", length); - + if (readableBytes < length) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("skipping bytebuf - too few bytes for msg: " + @@ -90,7 +90,7 @@ protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); - + byte version = bb.readByte(); if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { LOGGER.debug("detected version: " + version); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 5a739497..075b99da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -31,7 +31,7 @@ public class OFEncoder extends MessageToByteEncoder { private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class); private SerializationFactory serializationFactory; private StatisticsCounters statisticsCounters; - + /** Constructor of class */ public OFEncoder() { statisticsCounters = StatisticsCounters.getInstance(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 4bc5ce87..5c3b7616 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -72,10 +72,10 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) } return; } - + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); LOGGER.debug("length of actual message: {}", length); - + if (readableBytes < length) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("skipping bytebuf - too few bytes for msg: " + @@ -85,7 +85,7 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); - + ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); messageBuffer.retain(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java index 26dad6d1..51ac5482 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java @@ -10,7 +10,7 @@ /** * Stores names of handlers used in pipeline. - * + * * @author michal.polkorab */ public enum PipelineHandlers { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java index a3372ef8..15978def 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java @@ -18,7 +18,7 @@ public interface ShutdownProvider { /** - * @return shutdown future + * @return shutdown future */ ListenableFuture shutdown(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java index 965cab3d..b2c5a199 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java @@ -24,7 +24,7 @@ /** * Class for setting up TLS connection. - * + * * @author michal.polkorab */ public class SslContextFactory { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 6b974825..07aab354 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -45,13 +45,13 @@ public TcpChannelInitializer() { /** * Testing Constructor - * + * */ protected TcpChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAdapterFactory connAdaptorFactory ) { allChannels = channelGroup ; connectionAdapterFactory = connAdaptorFactory ; } - + @Override protected void initChannel(final SocketChannel ch) { InetAddress switchAddress = ch.remoteAddress().getAddress(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 0d7bb4e5..3e6e384e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -28,7 +28,7 @@ /** * Class implementing server over UDP for handling incoming connections. - * + * * @author michal.polkorab */ public final class UdpHandler implements ServerFacade { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java index e9a8bf98..c1625e5b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java @@ -14,7 +14,7 @@ /** * Wraps received messages (includes version) and sender address - + * @author michal.polkorab */ public class VersionMessageUdpWrapper extends VersionMessageWrapper { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java index f04ae92d..a61298de 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java @@ -18,7 +18,7 @@ public class VersionMessageWrapper { private short version; private ByteBuf messageBuffer; - + /** * Constructor * @param version version decoded in {@link OFVersionDetector} @@ -42,6 +42,6 @@ public short getVersion() { public ByteBuf getMessageBuffer() { return messageBuffer; } - - + + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index 7a43db62..65b9c6a6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -185,7 +185,7 @@ private synchronized void flush() { } final GenericFutureListener> l = h.takeListener(); - + final ChannelFuture p; if (address == null) { p = channel.write(new MessageListenerWrapper(h.takeMessage(), l)); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java index ec415b38..4b98fd8c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java @@ -16,7 +16,7 @@ /** * Wraps outgoing message and includes listener attached to this message. This object * is sent to OFEncoder. When OFEncoder fails to serialize the message, - * listener is filled with exception. The exception is then delegated to upper ODL layers. + * listener is filled with exception. The exception is then delegated to upper ODL layers. * @author michal.polkorab */ public class MessageListenerWrapper { @@ -40,7 +40,7 @@ public OfHeader getMsg() { return msg; } - + /** * @return listener listening on message sending success / failure */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java index 067c5603..2463f3f2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java @@ -15,7 +15,7 @@ * @author mirehak */ public class RpcResponseKey { - + private final long xid; private final String outputClazz; /** @@ -26,7 +26,7 @@ public RpcResponseKey(long xid, String outputClazz) { this.xid = xid; this.outputClazz = outputClazz; } - + /** * @return the xid */ @@ -40,7 +40,7 @@ public long getXid() { public String getOutputClazz() { return outputClazz; } - + @Override public int hashCode() { final int prime = 31; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java index a946cf54..e783dc42 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java @@ -18,7 +18,7 @@ * is sent to OFEncoder. When OFEncoder fails to serialize the message, * listener is filled with exception. The exception is then delegated to upper ODL layers. * This object is used for UDP communication - it also carries recipient address - + * @author michal.polkorab */ public class UdpMessageListenerWrapper extends MessageListenerWrapper { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index e946f30f..1c6c5d20 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -56,7 +56,7 @@ private ActionDeserializerInitializer() { */ public static void registerDeserializers(DeserializerRegistry registry) { // register OF v1.0 action deserializers - ActionDeserializerRegistryHelper helper = + ActionDeserializerRegistryHelper helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); helper.registerDeserializer(0, new OF10OutputActionDeserializer()); helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index b0b4d047..9ed52140 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -44,7 +44,7 @@ private TypeToClassMapInitializer() { */ public static void initializeTypeToClassMap(Map> messageClassMap) { // init OF v1.0 mapping - TypeToClassInitHelper helper = + TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 1, ErrorMessage.class); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index 8e341bd0..daae3634 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -68,7 +68,7 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { } return builder.build(); } - + private static void decodeType(ErrorMessageBuilder builder, ErrorType type, int readValue) { if (type != null) { builder.setType(type.getIntValue()); @@ -232,12 +232,12 @@ private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder, setUnknownCode(builder, code); } } - + private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) { builder.setCode(readValue); builder.setCodeString(UNKNOWN_CODE); } - + private static void setCode(ErrorMessageBuilder builder, int code, String codeString) { builder.setCode(code); builder.setCodeString(codeString); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java index d565fa63..39d757cc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java @@ -46,18 +46,18 @@ public GetAsyncOutput deserialize(ByteBuf rawMessage) { builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage)); return builder.build(); } - + private static List decodePacketInMask(ByteBuf input) { List inMasks = new ArrayList<>(); PacketInMaskBuilder maskBuilder; for (int i = 0; i < SEPARATE_ROLES; i++) { maskBuilder = new PacketInMaskBuilder(); maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt())); - inMasks.add(maskBuilder.build()); + inMasks.add(maskBuilder.build()); } return inMasks; } - + private static List decodePortStatusMask(ByteBuf input) { List inMasks = new ArrayList<>(); PortStatusMaskBuilder maskBuilder; @@ -68,7 +68,7 @@ private static List decodePortStatusMask(ByteBuf input) { } return inMasks; } - + private static List decodeFlowRemovedMask(ByteBuf input) { List inMasks = new ArrayList<>(); FlowRemovedMaskBuilder maskBuilder; @@ -79,7 +79,7 @@ private static List decodeFlowRemovedMask(ByteBuf input) { } return inMasks; } - + private static List decodePacketInReasons(long input) { List reasons = new ArrayList<>(); if ((input & (1 << 0)) != 0) { @@ -93,7 +93,7 @@ private static List decodePacketInReasons(long input) { } return reasons; } - + private static List decodePortReasons(long input) { List reasons = new ArrayList<>(); if ((input & (1 << 0)) != 0) { @@ -107,7 +107,7 @@ private static List decodePortReasons(long input) { } return reasons; } - + private static List decodeFlowRemovedReasons(long input) { List reasons = new ArrayList<>(); if ((input & (1 << 0)) != 0) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java index 5fafb5e3..ca0a79c8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactory.java @@ -39,7 +39,7 @@ public HelloMessage deserialize(ByteBuf rawMessage) { } return builder.build(); } - + private static List readElement(ByteBuf input) { List elementsList = new ArrayList<>(); while (input.readableBytes() > 0) { @@ -64,7 +64,7 @@ private static List readElement(ByteBuf input) { } return elementsList; } - + private static List readVersionBitmap(int[] input){ List versionBitmapList = new ArrayList<>(); for (int i = 0; i < input.length; i++) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index b27712f5..7d7f7524 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -196,11 +196,11 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); - break; + break; case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); - break; + break; case OFPMPGROUP: builder.setMultipartReplyBody(setGroup(rawMessage)); break; case OFPMPGROUPDESC: builder.setMultipartReplyBody(setGroupDesc(rawMessage)); @@ -219,13 +219,13 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { break; case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; - default: + default: break; } - + return builder.build(); } - + private static MultipartReplyDescCase setDesc(ByteBuf input) { MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder(); MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder(); @@ -252,7 +252,7 @@ private static MultipartReplyDescCase setDesc(ByteBuf input) { caseBuilder.setMultipartReplyDesc(descBuilder.build()); return caseBuilder.build(); } - + private MultipartReplyFlowCase setFlow(ByteBuf input) { MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder(); MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder(); @@ -293,16 +293,16 @@ private MultipartReplyFlowCase setFlow(ByteBuf input) { caseBuilder.setMultipartReplyFlow(flowBuilder.build()); return caseBuilder.build(); } - + private static FlowModFlags createFlowModFlagsFromBitmap(int input){ final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0; final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0; - final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0; + final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0; final Boolean fmfNOPKTCOUNTS = (input & (1 << 3)) != 0; final Boolean fmfNOBYTCOUNTS = (input & (1 << 4)) != 0; return new FlowModFlags(fmfCHECKOVERLAP, fmfNOBYTCOUNTS, fmfNOPKTCOUNTS, fmfRESETCOUNTS, fmfSENDFLOWREM); } - + private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder(); MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder(); @@ -317,7 +317,7 @@ private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { caseBuilder.setMultipartReplyAggregate(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyTableCase setTable(ByteBuf input) { MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder(); MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder(); @@ -339,7 +339,7 @@ private static MultipartReplyTableCase setTable(ByteBuf input) { caseBuilder.setMultipartReplyTable(builder.build()); return caseBuilder.build(); } - + private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder(); MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder(); @@ -358,7 +358,7 @@ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { featuresBuilder.setMetadataWrite(metadataWrite); featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt())); featuresBuilder.setMaxEntries(input.readUnsignedInt()); - featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, + featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)); features.add(featuresBuilder.build()); } @@ -366,12 +366,12 @@ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { caseBuilder.setMultipartReplyTableFeatures(builder.build()); return caseBuilder.build(); } - + private static TableConfig createTableConfig(long input) { boolean deprecated = (input & 3) != 0; return new TableConfig(deprecated); } - + private List createTableFeaturesProperties(ByteBuf input, int length) { List properties = new ArrayList<>(); int tableFeaturesLength = length; @@ -446,7 +446,7 @@ private List createTableFeaturesProperties(ByteBuf input } return properties; } - + private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder(); MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder(); @@ -499,7 +499,7 @@ private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { caseBuilder.setMultipartReplyPortStats(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyQueueCase setQueue(ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); @@ -525,7 +525,7 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { caseBuilder.setMultipartReplyQueue(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyGroupCase setGroup(ByteBuf input) { MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder(); MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder(); @@ -557,7 +557,7 @@ private static MultipartReplyGroupCase setGroup(ByteBuf input) { bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket)); bucketStatsList.add(bucketStatsBuilder.build()); actualLength += BUCKET_COUNTER_LENGTH; - } + } groupStatsBuilder.setBucketStats(bucketStatsList); groupStatsList.add(groupStatsBuilder.build()); } @@ -565,7 +565,7 @@ private static MultipartReplyGroupCase setGroup(ByteBuf input) { caseBuilder.setMultipartReplyGroup(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { MultipartReplyMeterFeaturesCaseBuilder caseBuilder = new MultipartReplyMeterFeaturesCaseBuilder(); MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder(); @@ -578,7 +578,7 @@ private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { caseBuilder.setMultipartReplyMeterFeatures(builder.build()); return caseBuilder.build(); } - + private static MeterFlags createMeterFlags(long input){ final Boolean mfKBPS = (input & (1 << 0)) != 0; final Boolean mfPKTPS = (input & (1 << 1)) != 0; @@ -586,13 +586,13 @@ private static MeterFlags createMeterFlags(long input){ final Boolean mfSTATS = (input & (1 << 3)) != 0; return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS); } - + private static MeterBandTypeBitmap createMeterBandsBitmap(long input) { final Boolean mbtDROP = (input & (1 << 1)) != 0; final Boolean mbtDSCPREMARK = (input & (1 << 2)) != 0; return new MeterBandTypeBitmap(mbtDROP, mbtDSCPREMARK); } - + private static MultipartReplyMeterCase setMeter(ByteBuf input) { MultipartReplyMeterCaseBuilder caseBuilder = new MultipartReplyMeterCaseBuilder(); MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder(); @@ -631,7 +631,7 @@ private static MultipartReplyMeterCase setMeter(ByteBuf input) { caseBuilder.setMultipartReplyMeter(builder.build()); return caseBuilder.build(); } - + private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder(); MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder(); @@ -692,12 +692,12 @@ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { caseBuilder.setMultipartReplyMeterConfig(builder.build()); return caseBuilder.build(); } - + private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( EncodeConstants.OF13_VERSION_ID, input.readUnsignedInt())); } - + private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder(); MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder(); @@ -725,7 +725,7 @@ private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { caseBuilder.setMultipartReplyPortDesc(builder.build()); return caseBuilder.build(); } - + private static PortConfig createPortConfig(long input){ final Boolean pcPortDown = ((input) & (1<<0)) != 0; final Boolean pcNRecv = ((input) & (1<<2)) != 0; @@ -733,14 +733,14 @@ private static PortConfig createPortConfig(long input){ final Boolean pcNPacketIn = ((input) & (1<<6)) != 0; return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } - + private static PortState createPortState(long input){ final Boolean psLinkDown = ((input) & (1<<0)) != 0; final Boolean psBlocked = ((input) & (1<<1)) != 0; final Boolean psLive = ((input) & (1<<2)) != 0; return new PortState(psBlocked, psLinkDown, psLive); } - + private static PortFeatures createPortFeatures(long input){ final Boolean pf10mbHd = ((input) & (1<<0)) != 0; final Boolean pf10mbFd = ((input) & (1<<1)) != 0; @@ -761,7 +761,7 @@ private static PortFeatures createPortFeatures(long input){ return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); } - + private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) { MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder(); MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder(); @@ -780,7 +780,7 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa caseBuilder.setMultipartReplyGroupFeatures(featuresBuilder.build()); return caseBuilder.build(); } - + private static ActionType createActionBitmap(long input) { final Boolean atOutput = ((input) & (1<<0)) != 0; final Boolean atCopyTTLout = ((input) & (1<<11)) != 0; @@ -820,7 +820,7 @@ private static GroupTypes createGroupType(long input) { final Boolean gtFF = ((input) & (1<<3)) != 0; return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect); } - + private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) { MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder(); MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java index dda0fd36..fb19113e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java @@ -45,7 +45,7 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { } return builder.build(); } - + private static void decodeType(ErrorMessageBuilder builder, ErrorTypeV10 type, int readValue) { if (type != null) { builder.setType(type.getIntValue()); @@ -129,12 +129,12 @@ private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder, setUnknownCode(builder, code); } } - + private static void setUnknownCode(ErrorMessageBuilder builder, int readValue) { builder.setCode(readValue); builder.setCodeString(UNKNOWN_CODE); } - + private static void setCode(ErrorMessageBuilder builder, int code, String codeString) { builder.setCode(code); builder.setCodeString(codeString); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index f8f967e4..469f920e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -31,7 +31,7 @@ * @author michal.polkorab */ public class OF10FeaturesReplyMessageFactory implements OFDeserializer { - + private static final byte PADDING_IN_FEATURES_REPLY_HEADER = 3; @Override @@ -67,7 +67,7 @@ private static CapabilitiesV10 createCapabilitiesV10(long input) { return new CapabilitiesV10(arpMatchIp, flowStats, ipReasm, portStats, queueStats, reserved, stp, tableStats); } - + private static ActionTypeV10 createActionsV10(long input) { final Boolean output = (input & (1 << 0)) != 0; final Boolean setVLANvid = (input & (1 << 1)) != 0; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java index eed4b104..9c3b72e7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java @@ -29,7 +29,7 @@ public class OF10PortStatusMessageFactory implements OFDeserializer createQueuesList(ByteBuf input){ List queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { @@ -59,10 +59,10 @@ private static List createQueuesList(ByteBuf input){ input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH)); queuesList.add(queueBuilder.build()); - } + } return queuesList; } - + private static List createPropertiesList(ByteBuf input, int length){ int propertiesLength = length; List propertiesList = new ArrayList<>(); @@ -82,4 +82,4 @@ private static List createPropertiesList(ByteBuf input, int lengt } return propertiesList; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index df7f6940..ccea543f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -95,19 +95,19 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); - break; + break; case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); - break; + break; case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; - default: + default: break; } return builder.build(); } - + private static MultipartReplyDescCase setDesc(ByteBuf input) { MultipartReplyDescCaseBuilder caseBuilder = new MultipartReplyDescCaseBuilder(); MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder(); @@ -134,7 +134,7 @@ private static MultipartReplyDescCase setDesc(ByteBuf input) { caseBuilder.setMultipartReplyDesc(descBuilder.build()); return caseBuilder.build(); } - + private MultipartReplyFlowCase setFlow(ByteBuf input) { MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder(); MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder(); @@ -172,7 +172,7 @@ private MultipartReplyFlowCase setFlow(ByteBuf input) { caseBuilder.setMultipartReplyFlow(flowBuilder.build()); return caseBuilder.build(); } - + private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder(); MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder(); @@ -187,7 +187,7 @@ private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { caseBuilder.setMultipartReplyAggregate(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyTableCase setTable(ByteBuf input) { MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder(); MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder(); @@ -217,7 +217,7 @@ private static MultipartReplyTableCase setTable(ByteBuf input) { caseBuilder.setMultipartReplyTable(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder(); MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder(); @@ -268,7 +268,7 @@ private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { caseBuilder.setMultipartReplyPortStats(builder.build()); return caseBuilder.build(); } - + private static MultipartReplyQueueCase setQueue(ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); @@ -293,7 +293,7 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { caseBuilder.setMultipartReplyQueue(builder.build()); return caseBuilder.build(); } - + private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( EncodeConstants.OF10_VERSION_ID, input.readUnsignedInt())); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index 5bd9cb32..fe3d7ac7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -34,7 +34,7 @@ public class PortStatusMessageFactory implements OFDeserializer createQueuesList(ByteBuf input){ List queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { @@ -66,10 +66,10 @@ private List createQueuesList(ByteBuf input){ input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH)); queuesList.add(queueBuilder.build()); - } + } return queuesList; } - + private List createPropertiesList(ByteBuf input, int length){ int propertiesLength = length; List propertiesList = new ArrayList<>(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index 9fd7cec9..75bf6f50 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -32,7 +32,7 @@ public Instruction deserialize(ByteBuf input) { InstructionBuilder builder = super.processHeader(input); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = + ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); List actions = new ArrayList<>(); actionsBuilder.setAction(actions); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index 1d737b09..5b9c6ba5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -40,7 +40,7 @@ public MatchEntries deserializeHeader(ByteBuf input) { /** * Prepares match entry header - sets oxm_class, oxm_field, hasMask - * + sets the buffer.readerIndex() to the end of match entry + * + sets the buffer.readerIndex() to the end of match entry * - where augmentation starts * @param oxmClass oxm class type * @param oxmField oxm field type @@ -60,5 +60,5 @@ protected MatchEntriesBuilder processHeader(Class oxmCla input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); return builder; } - + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java index e318c683..90cb34d7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java @@ -22,7 +22,7 @@ public class SerializationFactory { private SerializerRegistry registry; - + /** * Transforms POJO message into ByteBuf * @param version version used for encoding received message diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index aacebf2f..db740a4a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -21,7 +21,7 @@ public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { - + @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java index 3d95646b..bd87e16f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java @@ -46,7 +46,7 @@ private static void serializeElementsList(HelloInput message, ByteBuf output) { output.writeZero(padding); output.setShort(elementLengthIndex, output.writerIndex() - elementStartIndex); } - } + } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java index 606a98c5..7afa4bc2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactory.java @@ -20,7 +20,7 @@ * @author michal.polkorab */ public class OF10QueueGetConfigInputMessageFactory implements OFSerializer { - + private static final byte MESSAGE_TYPE = 20; private static final byte PADDING_IN_GET_QUEUE_CONFIG_MESSAGE = 2; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java index 44a089d3..65cb07e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactory.java @@ -62,7 +62,7 @@ private static void serializePacketInMask(List packetInMask, ByteB } } } - + private static void serializePortStatusMask(List portStatusMask, ByteBuf outBuffer) { if (portStatusMask != null) { for (PortStatusMask currentPortStatusMask : portStatusMask) { @@ -83,7 +83,7 @@ private static void serializePortStatusMask(List portStatusMask, } } } - + private static void serializerFlowRemovedMask(List flowRemovedMask, ByteBuf outBuffer) { if (flowRemovedMask != null) { for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java index 05812e8b..45f521e1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java @@ -11,7 +11,7 @@ /** * @author michal.polkorab - * @param type the key maker is based on + * @param type the key maker is based on */ public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { @@ -22,7 +22,7 @@ public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { */ public AbstractCodeKeyMaker(short version) { this.version = version; - + } /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java index f2e736fa..70c7a155 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java @@ -11,7 +11,7 @@ /** * @author michal.polkorab - * @param type the key maker is based on + * @param type the key maker is based on */ public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { @@ -22,7 +22,7 @@ public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { */ public AbstractTypeKeyMaker(short version) { this.version = version; - + } /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index f89fd0a1..62e019ad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -31,7 +31,7 @@ public InstructionSerializerRegistryHelper(short version, SerializerRegistry ser /** * Registers given serializer - * @param instructionType + * @param instructionType * @param serializer */ public void registerSerializer(Class instructionType, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index f085377f..f69c25b6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -20,7 +20,7 @@ /** * Serializes list items and their headers * @author michal.polkorab - * @param + * @param */ public abstract class ListSerializer { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index e3f49e30..e722a93e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -37,8 +37,8 @@ public MatchEntrySerializerRegistryHelper(short version, Class genera /** * Registers given serializer - * @param specificClass - * @param serializer + * @param specificClass + * @param serializer */ public void registerSerializer( Class specificClass, OFGeneralSerializer serializer) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index ceb5963f..c5b07583 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -76,7 +76,7 @@ public void serializeMatchEntries(List matchEntries, ByteBuf out) return; } for (MatchEntries entry : matchEntries) { - + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java index 9a608b2d..f865ac3d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -14,7 +14,7 @@ /** * Used for common structures translation / conversion - * + * * @author michal.polkorab */ public abstract class OpenflowUtils { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index 02b0307b..ad1b2f42 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -12,13 +12,13 @@ /** * @author michal.polkorab - * @param + * @param */ public interface TypeKeyMaker { /** * @param entry - * @return key that will be used for serializer lookup in + * @return key that will be used for serializer lookup in * the serializer registry */ abstract MessageTypeKey make(T entry); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index 0484ea83..672cdea6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -23,7 +23,7 @@ public class TypeToClassInitHelper { * @param version protocol wire version * @param messageClassMap map which stores type to class mapping */ - public TypeToClassInitHelper(short version, Map> messageClassMap) { this.version = version; this.messageClassMap = messageClassMap; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index aea5890e..077bfe64 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicLong; /** * Counts statistics - * + * * @author madamjak */ public class Counter { @@ -35,7 +35,7 @@ public void incrementCounter(){ } /** - * return the last read value of counter. This value can be set during the reading of current counter value, + * return the last read value of counter. This value can be set during the reading of current counter value, * for detail see method getCounterValue(boolean modifyLastReadValue). * @return the counterLastReadValue */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 951969ab..1f4d7ca3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -41,14 +41,14 @@ public final class StatisticsCounters implements StatisticsHandler { private boolean runCounting; // array to hold enabled counter types private CounterEventTypes[] enabledCounters = { - CounterEventTypes.DS_ENCODE_FAIL, + CounterEventTypes.DS_ENCODE_FAIL, CounterEventTypes.DS_ENCODE_SUCCESS, CounterEventTypes.DS_ENTERED_OFJAVA, CounterEventTypes.DS_FLOW_MODS_ENTERED, CounterEventTypes.DS_FLOW_MODS_SENT, - CounterEventTypes.US_DECODE_FAIL, - CounterEventTypes.US_DECODE_SUCCESS, - CounterEventTypes.US_MESSAGE_PASS, + CounterEventTypes.US_DECODE_FAIL, + CounterEventTypes.US_DECODE_SUCCESS, + CounterEventTypes.US_MESSAGE_PASS, CounterEventTypes.US_RECEIVED_IN_OFJAVA}; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index fd5cf8aa..68edb2a3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -29,7 +29,7 @@ */ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule { - + private static Logger LOG = LoggerFactory .getLogger(SwitchConnectionProviderModule.class); @@ -72,7 +72,7 @@ public java.lang.AutoCloseable createInstance() { /** * @return instance configuration object - * @throws UnknownHostException + * @throws UnknownHostException */ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException { final InetAddress address = extractIpAddressBin(getAddress()); @@ -154,12 +154,12 @@ public ThreadConfiguration getThreadConfiguration() { return null; } return new ThreadConfiguration() { - + @Override public int getWorkerThreadCount() { return threads.getWorkerThreads(); } - + @Override public int getBossThreadCount() { return threads.getBossThreads(); @@ -172,7 +172,7 @@ public int getBossThreadCount() { /** * @param address * @return - * @throws UnknownHostException + * @throws UnknownHostException */ private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException { byte[] addressBin = null; @@ -183,7 +183,7 @@ private static InetAddress extractIpAddressBin(IpAddress address) throws Unknown addressBin = address2bin(address.getIpv6Address().getValue()); } } - + if (addressBin == null) { return null; } else { diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index cb714d6b..2f80d957 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -146,7 +146,7 @@ module openflow-switch-connection-provider-impl { identity reset-ofjava-statistics-rpc; rpc print-ofjava-statistics { - description + description "Shortcut JMX call to printOfjavaStatistics."; input { uses rpcx:rpc-context-ref { @@ -163,7 +163,7 @@ module openflow-switch-connection-provider-impl { } rpc reset-ofjava-statistics { - description + description "Shortcut JMX call to resetOfjavaStatistics."; input { uses rpcx:rpc-context-ref { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java index 5e365b86..27aac9ce 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandlerTest.java @@ -41,7 +41,7 @@ public void setUp() { } /** - * + * */ @Test public void testChannelReadSuccess() { @@ -51,7 +51,7 @@ public void testChannelReadSuccess() { verify( mockMsgConsumer, times(1)).consume(mockDataObject); } /** - * + * */ @Test public void testChannelInactive() { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java index d22196a9..fcab9887 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java @@ -25,7 +25,7 @@ public class DummyDecoder extends ByteToMessageDecoder { private static final Logger LOGGER = LoggerFactory .getLogger(DummyDecoder.class); - + @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java index aa08feb5..b3462e98 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandlerTest.java @@ -34,7 +34,7 @@ public class IdleHandlerTest { /** * Sets up test environment - * + * */ @Before public void setUp() { @@ -96,15 +96,15 @@ public void testReadTimedOutTwice() { try { idleHandler.readTimedOut(mockChHndlrCtx); verify(mockChHndlrCtx, times(1)).fireChannelRead(any(Object.class)) ; - + idleHandler.channelRead(mockChHndlrCtx, new String() ); verify(mockChHndlrCtx, times(2)).fireChannelRead(any(Object.class)) ; - + idleHandler.readTimedOut(mockChHndlrCtx); verify(mockChHndlrCtx, times(3)).fireChannelRead(any(Object.class)) ; } catch (Exception e) { Assert.fail(); } } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java index 2b30d846..409e475d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderStatisticsTest.java @@ -31,7 +31,7 @@ /** * Test to count decoder events (counters US_DECODE_SUCCESS, US_DECODE_FAIL and * US_RECEIVED_IN_OFJAVA have to be enabled) - * + * * @author madamjak * */ @@ -100,7 +100,7 @@ public void testDecodeSuccesfullCounter() { Assert.assertEquals( "Wrong - different between RECEIVED_IN_OFJAVA and (US_DECODE_SUCCESS + US_DECODE_FAIL)", statCounters.getCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA).getCounterValue(), - statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue() + statCounters.getCounter(CounterEventTypes.US_DECODE_SUCCESS).getCounterValue() + statCounters.getCounter(CounterEventTypes.US_DECODE_FAIL).getCounterValue()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java index af8a0102..917f9b92 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoderTest.java @@ -44,7 +44,7 @@ public class OFDecoderTest { /** * Sets up test environment - * + * */ @Before public void setUp() { @@ -57,7 +57,7 @@ public void setUp() { } /** - * + * */ @Test public void testDecode() { @@ -74,7 +74,7 @@ public void testDecode() { } /** - * + * */ @Test public void testDecodeDeserializeException() { @@ -93,7 +93,7 @@ public void testDecodeDeserializeException() { } /** - * + * */ @Test public void testDecodeDeserializeNull() { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java index 69fc393e..41d692c8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoderTest.java @@ -27,7 +27,7 @@ /** * Testing class of {@link OFFrameDecoder} - * + * * @author michal.polkorab */ @RunWith(MockitoJUnitRunner.class) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java index 1a3a3244..35b44977 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java @@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; /** - * + * * @author michal.polkorab */ @RunWith(MockitoJUnitRunner.class) @@ -49,7 +49,7 @@ public void setUp() { * Test of decode * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) * } - * + * * @throws Exception */ @Test @@ -94,12 +94,12 @@ public void testDecodeEmptyProtocolMessage() throws Exception { assertEquals( 0, byteBuffer.refCnt() ) ; } - + /** * Test of decode * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) * } - * + * * @throws Exception */ @Test diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index aa7a6e4a..3d8717c7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -66,7 +66,7 @@ public class PublishingChannelInitializerTest { /** * Sets up test environment - * @throws Exception + * @throws Exception */ @Before public void setUp() throws Exception { @@ -89,7 +89,7 @@ public void setUp() throws Exception { when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ; when(mockSwConnHandler.accept(eq(InetAddress.getLocalHost()))).thenReturn(true) ; when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ; - + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index 652e086c..a52f44c6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -41,7 +41,7 @@ public void setUp() { } /** - * @throws Exception + * @throws Exception */ @Test public void testGetServerContext() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java index ca6826f0..c2a13df8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStoreTest.java @@ -33,7 +33,7 @@ public void setUp() { /** * Test keystore file access - via classpath - * @throws Exception + * @throws Exception */ @Test public void testAsInputStream() throws Exception { @@ -44,7 +44,7 @@ public void testAsInputStream() throws Exception { /** * Test keystore file access - via relative path - * @throws Exception + * @throws Exception */ @Test public void testAsInputStream2() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java index 8cdca399..be616030 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapperTest.java @@ -17,7 +17,7 @@ import org.mockito.MockitoAnnotations; /** - * + * * @author madamjak * */ @@ -29,7 +29,7 @@ public class VersionMessageUdpWrapperTest { public void startUp(){ MockitoAnnotations.initMocks(this); } - + @Test public void test(){ short version = 35; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java index 80a58df2..ccc24e55 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java @@ -141,7 +141,7 @@ public void write(ChannelHandlerContext ctx, Object msg, } /** - * Class for testing - channel can change state to read only or writable + * Class for testing - channel can change state to read only or writable * @author madamjak * */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java index cf5796e7..a7e9904e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java @@ -21,14 +21,14 @@ import org.junit.Before; import org.junit.Test; /** - * + * * @author madamjak * */ public class ConnectionAdapterFactoryImplTest { @Mock ChannelPipeline channnelPipe; - @Mock Channel channel; + @Mock Channel channel; @Mock InetSocketAddress address; @Before diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java index 0e561fdc..7088bc09 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java @@ -105,7 +105,7 @@ public void tierDown(){ } } /** - * Test Rpc Calls + * Test Rpc Calls */ @Test public void testRcp() { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java index 6f199328..76936754 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java @@ -30,9 +30,9 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration { /** * Creates {@link ConnectionConfigurationImpl} - * @param address + * @param address * @param port - * @param tlsConfig + * @param tlsConfig * @param switchIdleTimeout */ public ConnectionConfigurationImpl(InetAddress address, int port, TlsConfiguration tlsConfig, long switchIdleTimeout) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java index 62b4613d..0b816c25 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; /** - * + * * @author madamjak * */ @@ -24,7 +24,7 @@ public class RpcResponseKeyTest { */ @Test public void testEquals(){ - + long xid1 = 12L; long xid2 = 66L; String outputClazz1 = "Clazz01"; @@ -48,7 +48,7 @@ public void testEquals(){ */ @Test public void testGetters(){ - + long xid1 = 12L; String outputClazz1 = "Clazz01"; RpcResponseKey key1 = new RpcResponseKey(xid1, outputClazz1); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 282087c4..2a82ddf0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -100,10 +100,10 @@ private void createConfig(TransportProtocol protocol) { config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); config.setTransferProtocol(protocol); } - + /** - * Test getServerFacade + * Test getServerFacade */ @Test public void testServerFacade(){ @@ -129,7 +129,7 @@ public void testShutdownUnconfigured(){ public void testUnregisterWrongKeys(){ startUp(TransportProtocol.TCP); provider.setConfiguration(config); - ExperimenterInstructionSerializerKey testSerKey + ExperimenterInstructionSerializerKey testSerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); Assert.assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey)); ExperimenterInstructionDeserializerKey tesDeserKey @@ -140,36 +140,36 @@ public void testUnregisterWrongKeys(){ /** * Test register and unregister method */ - @Test + @Test public void testUnregisterExistingKeys(){ startUp(TransportProtocol.TCP); provider.setConfiguration(config); // -- registerActionSerializer - ExperimenterActionSerializerKey key1 + ExperimenterActionSerializerKey key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); provider.registerActionSerializer(key1, serializer); Assert.assertTrue("Wrong -- unregister ActionSerializer", provider.unregisterSerializer(key1)); Assert.assertFalse("Wrong -- unregister ActionSerializer by not existing key", provider.unregisterSerializer(key1)); // -- registerActionDeserializer - ExperimenterActionDeserializerKey key2 + ExperimenterActionDeserializerKey key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); provider.registerActionDeserializer(key2, deserializer); Assert.assertTrue("Wrong -- unregister ActionDeserializer", provider.unregisterDeserializer(key2)); Assert.assertFalse("Wrong -- unregister ActionDeserializer by not existing key", provider.unregisterDeserializer(key2)); // -- registerInstructionSerializer - ExperimenterInstructionSerializerKey key3 + ExperimenterInstructionSerializerKey key3 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); provider.registerInstructionSerializer(key3, serializer); Assert.assertTrue("Wrong -- unregister InstructionSerializer", provider.unregisterSerializer(key3)); Assert.assertFalse("Wrong -- unregister InstructionSerializer by not existing key", provider.unregisterSerializer(key3)); // -- registerInstructionDeserializer - ExperimenterInstructionDeserializerKey key4 + ExperimenterInstructionDeserializerKey key4 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,42L); provider.registerInstructionDeserializer(key4, deserializer); Assert.assertTrue("Wrong -- unregister InstructionDeserializer", provider.unregisterDeserializer(key4)); Assert.assertFalse("Wrong -- unregister InstructionDeserializer by not existing key", provider.unregisterDeserializer(key4)); // -- registerMatchEntryDeserializer - MatchEntryDeserializerKey key5 + MatchEntryDeserializerKey key5 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); provider.registerMatchEntryDeserializer(key5, deserializer); Assert.assertTrue("Wrong -- unregister MatchEntryDeserializer", provider.unregisterDeserializer(key5)); @@ -205,7 +205,7 @@ public void testUnregisterExistingKeys(){ Assert.assertTrue("Wrong -- unregister QueuePropertyDeserializer", provider.unregisterDeserializer(key10)); Assert.assertFalse("Wrong -- unregister QueuePropertyDeserializer by not existing key", provider.unregisterDeserializer(key10)); // -- registerMeterBandDeserializer - ExperimenterIdDeserializerKey key11 + ExperimenterIdDeserializerKey key11 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MeterBandExperimenterCase.class); provider.registerMeterBandDeserializer(key11, deserializerMeterBandExpCase); Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11)); @@ -235,7 +235,7 @@ public void testUnregisterExistingKeys(){ Assert.assertTrue("Wrong -- unregister MeterBandSerializer", provider.unregisterSerializer(key15)); Assert.assertFalse("Wrong -- unregister MeterBandSerializer by not existing key", provider.unregisterSerializer(key15)); // -- registerMatchEntrySerializer - MatchEntrySerializerKey key16 + MatchEntrySerializerKey key16 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); provider.registerMatchEntrySerializer(key16, serializer); Assert.assertTrue("Wrong -- unregister MatchEntrySerializer", provider.unregisterSerializer(key16)); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java index 0bf79017..df4c7e98 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapperTest.java @@ -22,7 +22,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; /** - * + * * @author madamjak * */ @@ -30,7 +30,7 @@ public class UdpMessageListenerWrapperTest { @Mock GenericFutureListener> listener; @Mock OfHeader msg; - + @Before public void startUp(){ MockitoAnnotations.initMocks(this); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java index aec3df43..49e41fc8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java @@ -15,7 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; /** - * + * * @author madamjak * */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java index 337d3d36..165d613b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKeyTest.java @@ -13,7 +13,7 @@ /** - * + * * @author madamjak * */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java index 08cd1a4f..a9ebcf43 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; /** - * + * * @author madamjak * */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java index abd1d1d5..801d47a6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java @@ -50,7 +50,7 @@ public void testWithEmptyDataField() { BufferHelper.checkHeaderV13(builtByFactory); } - + /** * Testing {@link EchoReplyMessageFactory} for correct translation into POJO */ @@ -59,7 +59,7 @@ public void testWithDataFieldSet() { byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; ByteBuf bb = BufferHelper.buildBuffer(data); EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java index 04fa4ddb..8aff8b75 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java @@ -50,7 +50,7 @@ public void testWithEmptyDataField() { BufferHelper.checkHeaderV13(builtByFactory); } - + /** * Testing {@link EchoRequestMessageFactory} for correct translation into POJO */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java index 367062f5..55a90b81 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java @@ -351,7 +351,7 @@ public void testWithData() { Assert.assertEquals("Wrong code string", "EPERM", builtByFactory.getCodeString()); Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData()); } - + /** * Test of {@link ErrorMessageFactory} for correct translation into POJO */ @@ -367,7 +367,7 @@ public void testWithIncorrectTypeEnum() { Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString()); Assert.assertArrayEquals("Wrong data", new byte[]{0x00, 0x01, 0x02, 0x03}, builtByFactory.getData()); } - + /** * Test of {@link ErrorMessageFactory} for correct translation into POJO */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java index b05730f2..3b71c37e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -48,7 +48,7 @@ public void startUp() { public void test() { when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); - + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); factory.injectDeserializerRegistry(registry); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java index 22b7df56..cc0f35d8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java @@ -51,7 +51,7 @@ public void test(){ FlowRemovedMessage builtByFactory = BufferHelper.deserialize(flowFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); - + Assert.assertTrue(builtByFactory.getCookie().longValue() == 0x0001020304050607L); Assert.assertTrue(builtByFactory.getPriority() == 0x03); Assert.assertEquals("Wrong reason", 0x02, builtByFactory.getReason().getIntValue()); @@ -63,5 +63,5 @@ public void test(){ Assert.assertEquals("Wrong packetCount", 0x0001020304050607L, builtByFactory.getPacketCount().longValue()); Assert.assertEquals("Wrong byteCount", 0x0001020304050607L, builtByFactory.getByteCount().longValue()); } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java index 937f7d8c..c9dabd87 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -57,7 +57,7 @@ public void startUp() { */ @Test public void testGetAsyncReplyMessage() { - ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+ + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 "+ "00 00 00 00 "+ "00 00 00 07 "+ "00 00 00 00 "+ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java index e30fb02c..16826620 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java @@ -49,8 +49,8 @@ public void test() { GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); + Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue()); } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index 89f10225..47bd8ddf 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -80,7 +80,7 @@ public void testWithPadding() { Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); } - + /** * Testing {@link HelloMessageFactory} if incorrect version is set */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 11322641..ded6a326 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -96,7 +96,7 @@ public void startUp() { private static final Logger LOGGER = LoggerFactory .getLogger(MultipartReplyMessageFactoryTest.class); - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -105,39 +105,39 @@ public void testMultipartReplyDescBody(){ final int DESC_STR_LEN = 256; final int SERIAL_NUM_LEN = 32; ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00"); - + String mfrDesc = "Manufacturer description"; byte[] mfrDescBytes = new byte[256]; mfrDescBytes = mfrDesc.getBytes(); bb.writeBytes(mfrDescBytes); bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); - + String hwDesc = "Hardware description"; byte[] hwDescBytes = new byte[256]; hwDescBytes = hwDesc.getBytes(); bb.writeBytes(hwDescBytes); bb.writeZero(DESC_STR_LEN - hwDescBytes.length); - + String swDesc = "Software description"; byte[] swDescBytes = new byte[256]; swDescBytes = swDesc.getBytes(); bb.writeBytes(swDescBytes); bb.writeZero(DESC_STR_LEN - swDescBytes.length); - + String serialNum = "SN0123456789"; byte[] serialNumBytes = new byte[32]; serialNumBytes = serialNum.getBytes(); bb.writeBytes(serialNumBytes); bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); - + String dpDesc = "switch3 in room 3120"; byte[] dpDescBytes = new byte[256]; dpDescBytes = dpDesc.getBytes(); bb.writeBytes(dpDescBytes); bb.writeZero(DESC_STR_LEN - dpDescBytes.length); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); @@ -161,25 +161,25 @@ public void testMultipartReplyAggregateBody(){ "00 00 00 08 "+//flowCount "00 00 00 00"//pad ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount", + new BigInteger(1, new byte[]{(byte) 0x0F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getByteCount()); - Assert.assertEquals("Wrong flowCount", - 8, + Assert.assertEquals("Wrong flowCount", + 8, message.getFlowCount().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -192,25 +192,25 @@ public void testMultipartReplyTableBody(){ "FF 01 01 01 01 01 01 01 "+//lookupCount "AF 01 01 01 01 01 01 01"//matchedCount ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - + MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); MultipartReplyTable message = messageCase.getMultipartReplyTable(); Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong lookupCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong matchedCount", + new BigInteger(1, new byte[]{(byte) 0xAF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getMatchedCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -234,55 +234,55 @@ public void testMultipartReplyPortStatsBody(){ "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong rxPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxFrameErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxOverErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxCrcErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong collisions", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getCollisions()); Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -297,9 +297,9 @@ public void testMultipartReplyQueueBody(){ "00 00 00 02 "+//durationSec "00 00 00 04"//durationNsec ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); @@ -307,19 +307,19 @@ public void testMultipartReplyQueueBody(){ MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxErrors()); Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -353,9 +353,9 @@ public void testMultipartReplyGroupBody(){ "FF 02 02 02 02 02 02 02 "+//packetCountBucket_2.2 "FF 02 02 02 02 02 02 02"//byteCountBucket_2.2 ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); @@ -363,48 +363,48 @@ public void testMultipartReplyGroupBody(){ MultipartReplyGroup message = messageCase.getMultipartReplyGroup(); Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getByteCount()); Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetCountBucket", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount()); - Assert.assertEquals("Wrong packetCountBucket_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount()); - + Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue()); Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue()); - Assert.assertEquals("Wrong packetCount_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCount_2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCount_2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCount_2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getByteCount()); Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue()); Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetCountBucket_1.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetCountBucket_1.2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_1.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteCountBucket_1.2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount()); - Assert.assertEquals("Wrong packetCountBucket_2.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetCountBucket_2.2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount()); - Assert.assertEquals("Wrong byteCountBucket_2.2", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteCountBucket_2.2", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount()); } @@ -429,48 +429,48 @@ public void testMultipartReplyMeterBody(){ "FF 03 03 03 03 03 03 03 "+//packetBandCount_03 "FF 03 03 03 03 03 03 03"//byteBandCount_03 ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -506,81 +506,81 @@ public void testMultipartReplyMeterBodyMulti(){ "FF 03 03 03 03 03 03 03 "+//packetBandCount_13 "FF 03 03 03 03 03 03 03"//byteBandCount_13 ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); - Assert.assertEquals("Wrong meterId", 9, + MultipartReplyMeter message = messageCase.getMultipartReplyMeter(); + Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount()); - - Assert.assertEquals("Wrong meterId", 8, + + Assert.assertEquals("Wrong meterId", 8, message.getMeterStats().get(1).getMeterId().getValue().intValue()); - Assert.assertEquals("Wrong flowCount", 7, + Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(1).getFlowCount().intValue()); - Assert.assertEquals("Wrong packetInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getPacketInCount()); - Assert.assertEquals("Wrong byteInCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteInCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getByteInCount()); - Assert.assertEquals("Wrong durationSec", 5, + Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(1).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 5, + Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(1).getDurationNsec().intValue()); - Assert.assertEquals("Wrong packetBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong packetBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_01", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong byteBandCount_01", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong packetBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_02", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong byteBandCount_02", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount()); - Assert.assertEquals("Wrong packetBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong packetBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount()); - Assert.assertEquals("Wrong byteBandCount_03", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), + Assert.assertEquals("Wrong byteBandCount_03", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03}), message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -601,33 +601,33 @@ public void testMultipartReplyMeterConfigBody(){ "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel "00 00 00");//meterBandDscp.pad - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true), message.getMeterConfig().get(0).getFlags()); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - - MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + + MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); - Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); + Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue()); Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue()); - - MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + + MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark(); - Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); + Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @@ -648,7 +648,7 @@ public void testMultipartReplyMeterConfigBodyMulti(){ "00 00 00 20 "+//meterBandDscp.burstSize "04 "+//meterBandDscp.precLevel "00 00 00 "+//meterBandDscp.pad - + "00 18 "+//len01 "00 03 "+//flags01 "00 00 00 07 "+//meterId01 @@ -659,45 +659,45 @@ public void testMultipartReplyMeterConfigBodyMulti(){ "04 "+//meterBandDscp01.precLevel "00 00 00"//meterBandDscp01.pad ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); - Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), + MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig(); + Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), message.getMeterConfig().get(0).getFlags()); - Assert.assertEquals("Wrong meterId", 9, + Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue()); - - MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); - MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); - Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); + + MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand(); + MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop(); + Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue()); Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue()); - - MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); + + MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand(); MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark(); - Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); + Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - + LOGGER.info(message.getMeterConfig().get(0).getFlags().toString()); Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags()); - Assert.assertEquals("Wrong meterId01", 7, + Assert.assertEquals("Wrong meterId01", 7, message.getMeterConfig().get(1).getMeterId().getValue().intValue()); - - MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); + + MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand(); MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark(); - Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); + Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue()); Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue()); Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue()); - + } /** @@ -729,47 +729,47 @@ public void testMultipartReplyGroupDescBody01(){ "00 00 00 00"//copyTTLInPad ); MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - - Assert.assertEquals("Wrong outputType", Output.class, + + Assert.assertEquals("Wrong outputType", Output.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getType()); - - Assert.assertEquals("Wrong outputPort", 4351, + + Assert.assertEquals("Wrong outputPort", 4351, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getAugmentation(PortAction.class). getPort().getValue().intValue()); - - Assert.assertEquals("Wrong outputMaxLen", 65535, + + Assert.assertEquals("Wrong outputMaxLen", 65535, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getAugmentation(MaxLengthAction.class). getMaxLength().intValue()); - - Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, + + Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getType()); - - Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, + + Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) .getType()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Set MPLS TTL , Dec MPLS TTL, Push VLAN. Push MPLS, Push PBB @@ -806,57 +806,57 @@ public void testMultipartReplyGroupDescBody02(){ "0F FF "+//pushPbbEthertype "00 00"//pushPbbPad ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, + Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getType()); - Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, + Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getAugmentation(MplsTtlAction.class). getMplsTtl().intValue()); - Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, + Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getType()); - Assert.assertEquals("Wrong pushVlanType", PushVlan.class, + Assert.assertEquals("Wrong pushVlanType", PushVlan.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) .getType()); - Assert.assertEquals("Wrong pushVlanEthertype", 32, + Assert.assertEquals("Wrong pushVlanEthertype", 32, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushMplsType", PushMpls.class, + Assert.assertEquals("Wrong pushMplsType", PushMpls.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) .getType()); - Assert.assertEquals("Wrong pushMplsEthertype", 255, + Assert.assertEquals("Wrong pushMplsEthertype", 255, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3). getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushPbbType", PushPbb.class, + Assert.assertEquals("Wrong pushPbbType", PushPbb.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) .getType()); - Assert.assertEquals("Wrong pushPbbEthertype", 4095, + Assert.assertEquals("Wrong pushPbbEthertype", 4095, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions Pop VLAN, Pop PBB, Pop MPLS, Group, Dec NW TTL @@ -893,54 +893,54 @@ public void testMultipartReplyGroupDescBody03(){ "00 08 "+//decNwTtlLen "00 00 00 00"//decNwTtlPad ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); + MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong popVlanType", PopVlan.class, + Assert.assertEquals("Wrong popVlanType", PopVlan.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getType()); - Assert.assertEquals("Wrong popPbbType", PopPbb.class, + Assert.assertEquals("Wrong popPbbType", PopPbb.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getType()); - Assert.assertEquals("Wrong popMplsType", PopMpls.class, + Assert.assertEquals("Wrong popMplsType", PopMpls.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) .getType()); - Assert.assertEquals("Wrong popMplsEthertype", 207, + Assert.assertEquals("Wrong popMplsEthertype", 207, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) .getAugmentation(EthertypeAction.class). getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong setQueueType", SetQueue.class, + Assert.assertEquals("Wrong setQueueType", SetQueue.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) .getType()); - Assert.assertEquals("Wrong setQueueQueueId", 13565952, + Assert.assertEquals("Wrong setQueueQueueId", 13565952, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) .getAugmentation(QueueIdAction.class). getQueueId().intValue()); - Assert.assertEquals("Wrong groupType", Group.class, + Assert.assertEquals("Wrong groupType", Group.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) .getType()); - Assert.assertEquals("Wrong groupGroupId", 13565952, + Assert.assertEquals("Wrong groupGroupId", 13565952, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) .getAugmentation(GroupIdAction.class). getGroupId().intValue()); - Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, + Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5) .getType()); } - + /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO * Test covers bodies of actions NW TTL, Experimenter @@ -969,47 +969,47 @@ public void testMultipartReplyGroupDescBody04(){ "00 00 00 FF "+ //setFieldPort "00 00 00 00" ); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong type", 7, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyGroupDescCase messageCase = (MultipartReplyGroupDescCase) builtByFactory.getMultipartReplyBody(); MultipartReplyGroupDesc message = messageCase.getMultipartReplyGroupDesc(); - Assert.assertEquals("Wrong type", 1, + Assert.assertEquals("Wrong type", 1, message.getGroupDesc().get(0).getType().getIntValue()); - Assert.assertEquals("Wrong groupId", 8, + Assert.assertEquals("Wrong groupId", 8, message.getGroupDesc().get(0).getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong bucketWeight", 6, + Assert.assertEquals("Wrong bucketWeight", 6, message.getGroupDesc().get(0).getBucketsList().get(0).getWeight().intValue()); - Assert.assertEquals("Wrong bucketWatchPort", 5, + Assert.assertEquals("Wrong bucketWatchPort", 5, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort(). getValue().intValue()); - Assert.assertEquals("Wrong bucketWatchGroup", 4, + Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - - Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, + + Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getType()); - - Assert.assertEquals("Wrong nwTTlnwTTL", 14, + + Assert.assertEquals("Wrong nwTTlnwTTL", 14, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) .getAugmentation(NwTtlAction.class).getNwTtl().intValue()); - - Assert.assertEquals("Wrong setFieldType", SetField.class, + + Assert.assertEquals("Wrong setFieldType", SetField.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getType()); - - Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, + + Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass()); - - Assert.assertEquals("Wrong setFieldOXMField", InPort.class, + + Assert.assertEquals("Wrong setFieldOXMField", InPort.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField()); - - Assert.assertEquals("Wrong setFieldOXMValue", 255, + + Assert.assertEquals("Wrong setFieldOXMValue", 255, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0). getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java index 92197425..336710d5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java @@ -50,7 +50,7 @@ public void testWithEmptyDataFieldV10() { BufferHelper.checkHeaderV10(builtByFactory); } - + /** * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO */ @@ -59,7 +59,7 @@ public void testWithDataFieldSetV10() { byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; ByteBuf bb = BufferHelper.buildBuffer(data); EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - + BufferHelper.checkHeaderV10(builtByFactory); Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java index 96fd0335..7684e850 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java @@ -50,7 +50,7 @@ public void testWithEmptyDataFieldV10() { BufferHelper.checkHeaderV10(builtByFactory); } - + /** * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index 9530eaba..f5ec8f23 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -83,7 +83,7 @@ public void test() { Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), port.getPeerFeaturesV10()); } - + /** * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java index c0d795a6..fc63e70c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java @@ -49,8 +49,8 @@ public void test() { GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); + Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue()); } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java index 62387806..57d73cb7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java @@ -46,8 +46,8 @@ public void startUp() { @Test public void test(){ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00 01 02 03 04"); - PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); - + PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); + BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue()); Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue()); @@ -62,7 +62,7 @@ public void test(){ @Test public void testWithNoAdditionalData(){ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 02 00 00"); - PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); + PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); Assert.assertNull("Wrong data", builtByFactory.getData()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java index 6b451872..0d637522 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java @@ -54,7 +54,7 @@ public void test(){ + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 15 00 00 00 01 00 00 00 31 00 00 04 42 00 00 03 0C 00 00 08 88"); PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb); - + BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong reason", PortReason.OFPPRADD, builtByFactory.getReason()); Assert.assertEquals("Wrong port - port-no", 16, builtByFactory.getPortNo().intValue()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 0e8813ea..a4740621 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -68,39 +68,39 @@ public void testDesc() { final int DESC_STR_LEN = 256; final int SERIAL_NUM_LEN = 32; ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); - + String mfrDesc = "Manufacturer description"; byte[] mfrDescBytes = new byte[256]; mfrDescBytes = mfrDesc.getBytes(); bb.writeBytes(mfrDescBytes); bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); - + String hwDesc = "Hardware description"; byte[] hwDescBytes = new byte[256]; hwDescBytes = hwDesc.getBytes(); bb.writeBytes(hwDescBytes); bb.writeZero(DESC_STR_LEN - hwDescBytes.length); - + String swDesc = "Software description"; byte[] swDescBytes = new byte[256]; swDescBytes = swDesc.getBytes(); bb.writeBytes(swDescBytes); bb.writeZero(DESC_STR_LEN - swDescBytes.length); - + String serialNum = "SN0123456789"; byte[] serialNumBytes = new byte[32]; serialNumBytes = serialNum.getBytes(); bb.writeBytes(serialNumBytes); bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); - + String dpDesc = "switch3 in room 3120"; byte[] dpDescBytes = new byte[256]; dpDescBytes = dpDesc.getBytes(); bb.writeBytes(dpDescBytes); bb.writeZero(DESC_STR_LEN - dpDescBytes.length); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - + BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); @@ -113,7 +113,7 @@ public void testDesc() { Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - + /** * Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization */ @@ -125,7 +125,7 @@ public void testFlow() { + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00"); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); @@ -140,13 +140,13 @@ public void testFlow() { Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), message.getFlowStats().get(0).getCookie()); Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), message.getFlowStats().get(0).getPacketCount()); Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), message.getFlowStats().get(0).getByteCount()); Action action1 = message.getFlowStats().get(0).getAction().get(0); Assert.assertEquals("Wrong action type", Output.class, action1.getType()); @@ -160,7 +160,7 @@ public void testFlow() { .getVlanVid().intValue()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - + /** * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization */ @@ -168,7 +168,7 @@ public void testFlow() { public void testAggregate() { ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00"); - + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); BufferHelper.checkHeaderV10(builtByFactory); @@ -177,15 +177,15 @@ public void testAggregate() { MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); Assert.assertEquals("Wrong packet-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), message.getPacketCount()); Assert.assertEquals("Wrong byte-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), message.getByteCount()); Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - + /** * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization */ @@ -212,15 +212,15 @@ public void testTable() { Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong lookupCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), + Assert.assertEquals("Wrong matchedCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), message.getTableStats().get(0).getMatchedCount()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - + /** * Testing OF10StatsReplyMessageFactory (Port) for correct deserialization */ @@ -243,45 +243,45 @@ public void testPort() { MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + Assert.assertEquals("Wrong rxPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxFrameErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxOverErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong rxCrcErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong collisions", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getPortStats().get(0).getCollisions()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } - + /** * Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization */ @@ -302,14 +302,14 @@ public void testQueue() { MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue()); Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), message.getQueueStats().get(0).getTxErrors()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java index a154ad4b..b30df2f8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java @@ -50,10 +50,10 @@ public void startUp() { public void test(){ ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 01 02 01 04 00 01 02 03 04 05 06 07 00 01 00 0C" + " 80 00 02 04 00 00 00 01 00 00 00 00 00 00 01 02 03 04"); - PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); - + PacketInMessage builtByFactory = BufferHelper.deserialize(packetInFactory, bb); + BufferHelper.checkHeaderV13(builtByFactory); - + Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue()); Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue()); Assert.assertEquals("Wrong reason", PacketInReason.OFPRACTION, builtByFactory.getReason()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index cf0499ae..79ee3fd9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -50,7 +50,7 @@ public void startUp() { */ @Test public void test(){ - ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason + ByteBuf bb = BufferHelper.buildBuffer("01 " + //reason "00 00 00 00 00 00 00 " + //padding "00 01 02 03 " + //port no "00 00 00 00 " + //padding in ofp_port1 @@ -66,9 +66,9 @@ public void test(){ "00 00 00 81 " + //curr speed "00 00 00 80" //max speed ); - + PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb); - + BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue()); Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java index ab4ef3a6..cc2f4eab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java @@ -63,7 +63,7 @@ public void test(){ Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue()); Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList()); } - + private static List createQueuesList(){ List queuesList = new ArrayList<>(); QueuesBuilder qb = new QueuesBuilder(); @@ -71,10 +71,10 @@ private static List createQueuesList(){ qb.setPort(new PortNumber(3L)); qb.setQueueProperty(createPropertiesList()); queuesList.add(qb.build()); - + return queuesList; } - + private static List createPropertiesList(){ List propertiesList = new ArrayList<>(); QueuePropertyBuilder pb = new QueuePropertyBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java index e41e53b6..2f7a81d8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java @@ -49,7 +49,7 @@ public void test(){ RoleRequestOutput builtByFactory = BufferHelper.deserialize(roleFactory, bb); BufferHelper.checkHeaderV13(builtByFactory); - + Assert.assertEquals("Wrong role", 0x02, builtByFactory.getRole().getIntValue()); Assert.assertEquals("Wrong generationId", 0x01020304050607L, builtByFactory.getGenerationId().longValue()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java index 2c29dce1..17bc3abd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java @@ -38,7 +38,7 @@ public void test() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, + Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java index d0983876..c2f61840 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java @@ -39,7 +39,7 @@ public void test() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java index e765ba65..5962ac37 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java @@ -40,7 +40,7 @@ public void test() { Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals("Wrong entry value", 10, entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, + Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java index c398e47d..df7e83bf 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java @@ -15,12 +15,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; /** - * + * * @author madamjak * */ public class SerializerRegistryImplTest { - + private static final short OF13 = EncodeConstants.OF13_VERSION_ID; private static final short OF10 = EncodeConstants.OF10_VERSION_ID; @@ -46,7 +46,7 @@ public void testUnRegisterSerializerNoMessageTypeKey(){ } /** - * Test - unregister serializer + * Test - unregister serializer */ @Test public void testUnRegisterSerializer(){ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java index 9584bf62..1e5f475c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java @@ -45,17 +45,17 @@ public void startUp() { /** * Testing of {@link BarrierInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { BarrierInputBuilder bib = new BarrierInputBuilder(); BufferHelper.setupHeader(bib, EncodeConstants.OF13_VERSION_ID); BarrierInput bi = bib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); barrierFactory.serialize(bi, out); - + BufferHelper.checkHeaderV13(out, BARRIER_REQUEST_MESSAGE_CODE_TYPE, 8); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java index f9df80d2..cf00e1c2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java @@ -46,7 +46,7 @@ public void startUp() { /** * Testing of {@link EchoInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV13() throws Exception { @@ -57,10 +57,10 @@ public void testV13() throws Exception { echoFactory.serialize(ei, out); BufferHelper.checkHeaderV13(out, ECHO_REQUEST_MESSAGE_CODE_TYPE, 8); } - + /** * Testing of {@link EchoInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV10() throws Exception { @@ -74,7 +74,7 @@ public void testV10() throws Exception { /** * Testing of {@link EchoInputMessageFactory} for correct data serialization - * @throws Exception + * @throws Exception */ @Test public void testData() throws Exception{ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java index 64a5f078..be4130a0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java @@ -45,7 +45,7 @@ public void startUp() { /** * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV13() throws Exception { @@ -56,10 +56,10 @@ public void testV13() throws Exception { echoFactory.serialize(eri, out); BufferHelper.checkHeaderV13(out, ECHO_REPLY_MESSAGE_CODE_TYPE, 8); } - + /** * Testing of {@link EchoReplyInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV10() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java index 77cc5c32..47235595 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -56,7 +56,7 @@ public void startUp(boolean real) { /** * Testing of {@link ExperimenterInputMessageFactory} for correct serializer * lookup and serialization - * @throws Exception + * @throws Exception */ @Test(expected=IllegalStateException.class) public void testV10Real() throws Exception { @@ -65,7 +65,7 @@ public void testV10Real() throws Exception { BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); ExperimenterInput input = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); } @@ -73,7 +73,7 @@ public void testV10Real() throws Exception { /** * Testing of {@link ExperimenterInputMessageFactory} for correct serializer * lookup and serialization - * @throws Exception + * @throws Exception */ @Test(expected=IllegalStateException.class) public void testV13Real() throws Exception { @@ -82,7 +82,7 @@ public void testV13Real() throws Exception { BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); ExperimenterInput input = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); } @@ -90,7 +90,7 @@ public void testV13Real() throws Exception { /** * Testing of {@link ExperimenterInputMessageFactory} for correct serializer * lookup and serialization - * @throws Exception + * @throws Exception */ @Test public void testV10() throws Exception { @@ -110,7 +110,7 @@ public void testV10() throws Exception { /** * Testing of {@link ExperimenterInputMessageFactory} for correct serializer * lookup and serialization - * @throws Exception + * @throws Exception */ @Test public void testV13() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index 3c5ba034..bfa59857 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -81,7 +81,7 @@ public void startUp() { } /** - * @throws Exception + * @throws Exception * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO */ @Test @@ -211,11 +211,11 @@ public void testFlowModInputMessageFactory() throws Exception { out.skipBytes(6); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - + private static FlowModFlags createFlowModFlagsFromBitmap(int input){ final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0; final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0; - final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; + final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0; final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0; return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java index bf5a3c36..a050b299 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java @@ -45,33 +45,33 @@ public void startUp() { /** * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV13() throws Exception { GetConfigInputBuilder gcib = new GetConfigInputBuilder(); BufferHelper.setupHeader(gcib, EncodeConstants.OF13_VERSION_ID); GetConfigInput gci = gcib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); getConfigFactory.serialize(gci, out); BufferHelper.checkHeaderV13(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8); } - + /** * Testing of {@link GetConfigInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV10() throws Exception { GetConfigInputBuilder gcib = new GetConfigInputBuilder(); BufferHelper.setupHeader(gcib, EncodeConstants.OF10_VERSION_ID); GetConfigInput gci = gcib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); getConfigFactory.serialize(gci, out); - + BufferHelper.checkHeaderV10(out, GET_CONFIG_REQUEST_MESSAGE_CODE_TYPE, 8); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java index 62ab4bf1..1f4a400f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java @@ -45,14 +45,14 @@ public void startUp() { /** * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV13() throws Exception { GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder(); BufferHelper.setupHeader(gfib, EncodeConstants.OF13_VERSION_ID); GetFeaturesInput gfi = gfib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); featuresFactory.serialize(gfi, out); @@ -61,14 +61,14 @@ public void testV13() throws Exception { /** * Testing of {@link GetFeaturesInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testV10() throws Exception { GetFeaturesInputBuilder gfib = new GetFeaturesInputBuilder(); BufferHelper.setupHeader(gfib, EncodeConstants.OF10_VERSION_ID); GetFeaturesInput gfi = gfib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); featuresFactory.serialize(gfi, out); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java index f1da495a..0d94cf6b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -46,7 +46,7 @@ public void startUp() { /** * Testing of {@link GetQueueConfigInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testGetQueueConfigInputMessage() throws Exception { @@ -54,7 +54,7 @@ public void testGetQueueConfigInputMessage() throws Exception { BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setPort(new PortNumber(0x00010203L)); GetQueueConfigInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); getQueueFactory.serialize(message, out); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java index 5cc956ac..a660f37c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java @@ -45,17 +45,17 @@ public void startUp() { /** * Testing of {@link GetAsyncRequestMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testGetAsyncReques() throws Exception { GetAsyncInputBuilder builder = new GetAsyncInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); GetAsyncInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); getAsyncFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java index c5d41114..c158b706 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java @@ -67,7 +67,7 @@ public void testGroupModInputMessage() throws Exception { List exp = createBucketsList(); builder.setBucketsList(exp); GroupModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); groupModFactory.serialize(message, out); @@ -79,7 +79,7 @@ public void testGroupModInputMessage() throws Exception { List rec = createBucketsListFromBufer(out); Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray()); } - + private static List createBucketsList(){ List bucketsList = new ArrayList<>(); BucketsListBuilder bucketsBuilder = new BucketsListBuilder(); @@ -91,7 +91,7 @@ private static List createBucketsList(){ bucketsList.add(bucket); return bucketsList; } - + private static List createBucketsListFromBufer(ByteBuf out){ List bucketsList = new ArrayList<>(); BucketsListBuilder bucketsBuilder = new BucketsListBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index f971c026..e2ea0f86 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -55,23 +55,23 @@ public void startUp() { /** * Testing of {@link HelloInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testWithoutElementsSet() throws Exception { HelloInputBuilder hib = new HelloInputBuilder(); BufferHelper.setupHeader(hib, EncodeConstants.OF13_VERSION_ID); HelloInput hi = hib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(hi, out); - + BufferHelper.checkHeaderV13(out,(byte) 0, EncodeConstants.OFHEADER_SIZE); } - + /** * Testing of {@link HelloInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testWith4BitVersionBitmap() throws Exception { @@ -81,21 +81,21 @@ public void testWith4BitVersionBitmap() throws Exception { List expectedElement = createElement(lengthOfBitmap); builder.setElements(expectedElement); HelloInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out)); - + BufferHelper.checkHeaderV13(out, (byte) 0, 16); Elements element = readElement(out).get(0); Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType()); Elements comparation = createComparationElement(lengthOfBitmap).get(0); Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray()); } - + /** * Testing of {@link HelloInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testWith64BitVersionBitmap() throws Exception { @@ -105,18 +105,18 @@ public void testWith64BitVersionBitmap() throws Exception { List expectedElement = createElement(lengthOfBitmap); builder.setElements(expectedElement); HelloInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out)); - + BufferHelper.checkHeaderV13(out, (byte) 0, 24); Elements element = readElement(out).get(0); Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType()); Elements comparation = createComparationElement(lengthOfBitmap).get(0); Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray()); } - + private static List createElement(int lengthOfBitmap) { ElementsBuilder elementsBuilder = new ElementsBuilder(); List elementsList = new ArrayList<>(); @@ -129,7 +129,7 @@ private static List createElement(int lengthOfBitmap) { elementsList.add(elementsBuilder.build()); return elementsList; } - + private static List createComparationElement(int lengthOfBitmap) { ElementsBuilder elementsBuilder = new ElementsBuilder(); List elementsList = new ArrayList<>(); @@ -148,7 +148,7 @@ private static List createComparationElement(int lengthOfBitmap) { elementsList.add(elementsBuilder.build()); return elementsList; } - + private static List readElement(ByteBuf input) { List elementsList = new ArrayList<>(); while (input.readableBytes() > 0) { @@ -171,7 +171,7 @@ private static List readElement(ByteBuf input) { } return elementsList; } - + private static List readVersionBitmap(int[] input){ List versionBitmapList = new ArrayList<>(); for (int i = 0; i < input.length; i++) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index 7ac417a4..4884643b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -57,7 +57,7 @@ public void startUp() { } /** - * @throws Exception + * @throws Exception * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO */ @Test @@ -69,25 +69,25 @@ public void testMeterModInputMessage() throws Exception { builder.setMeterId(new MeterId(2248L)); builder.setBands(createBandsList()); MeterModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); meterModFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, (byte) 29, 48); Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); Assert.assertEquals("Wrong meterId", message.getMeterId().getValue().intValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong bands", message.getBands(), decodeBandsList(out)); } - + private static MeterFlags decodeMeterModFlags(short input){ final Boolean _oFPMFKBPS = (input & (1 << 0)) > 0; final Boolean _oFPMFPKTPS = (input & (1 << 1)) > 0; - final Boolean _oFPMFBURST = (input & (1 << 2)) > 0; + final Boolean _oFPMFBURST = (input & (1 << 2)) > 0; final Boolean _oFPMFSTATS = (input & (1 << 3)) > 0; return new MeterFlags(_oFPMFBURST, _oFPMFKBPS, _oFPMFPKTPS, _oFPMFSTATS); } - + private static List createBandsList(){ List bandsList = new ArrayList<>(); BandsBuilder bandsBuilder = new BandsBuilder(); @@ -108,7 +108,7 @@ private static List createBandsList(){ bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); return bandsList; } - + private static List decodeBandsList(ByteBuf input){ List bandsList = new ArrayList<>(); BandsBuilder bandsBuilder = new BandsBuilder(); @@ -135,7 +135,7 @@ private static List decodeBandsList(ByteBuf input){ } /** - * @throws Exception + * @throws Exception * Testing of {@link MeterModInputMessageFactory} for correct translation from POJO */ @Test @@ -147,10 +147,10 @@ public void testMeterModInputMessageWithNoBands() throws Exception { builder.setMeterId(new MeterId(2248L)); builder.setBands(null); MeterModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); meterModFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, (byte) 29, 16); Assert.assertEquals("Wrong meterModCommand", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong meterFlags", message.getFlags(), decodeMeterModFlags(out.readShort())); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java index 4ddb02cc..ae752b6a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java @@ -44,17 +44,17 @@ public void startUp() { /** * Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { BarrierInputBuilder bib = new BarrierInputBuilder(); BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID); BarrierInput bi = bib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); barrierFactory.serialize(bi, out); - + BufferHelper.checkHeaderV10(out, (byte) 18, 8); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 24449825..e4b3af1b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -64,7 +64,7 @@ public void startUp() { } /** - * @throws Exception + * @throws Exception * Testing of {@link OF10FlowModInputMessageFactory} for correct translation from POJO */ @Test @@ -112,10 +112,10 @@ public void testFlowModInputMessageFactory() throws Exception { actions.add(actionBuilder.build()); builder.setAction(actions); FlowModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); flowModFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 14, 88); Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt()); Assert.assertEquals("Wrong inPort", 58, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java index c4807192..e8591d4a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java @@ -44,17 +44,17 @@ public void startUp() { /** * Testing of {@link OF10HelloInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testWithoutElementsSet() throws Exception { HelloInputBuilder hib = new HelloInputBuilder(); BufferHelper.setupHeader(hib, EncodeConstants.OF10_VERSION_ID); HelloInput hi = hib.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(hi, out); - + BufferHelper.checkHeaderV10(out, (byte) 0, 8); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index d98a8364..791d5681 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -58,7 +58,7 @@ public void startUp() { /** * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPacketOutInputMessage() throws Exception { @@ -83,10 +83,10 @@ public void testPacketOutInputMessage() throws Exception { builder.setAction(actions); builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14")); PacketOutInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); packetOutFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 13, 48); Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt()); Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort()); @@ -104,7 +104,7 @@ public void testPacketOutInputMessage() throws Exception { /** * Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPacketOutInputWithNoData() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index b64d6c5c..39276ba3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -49,7 +49,7 @@ public void startUp() { /** * Testing of {@link OF10PortModInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPortModInput() throws Exception { @@ -62,10 +62,10 @@ public void testPortModInput() throws Exception { builder.setAdvertiseV10(new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false)); PortModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); portModFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 15, 32); Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedShort()); byte[] address = new byte[6]; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java index c8a41d2c..91a08cbb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java @@ -45,7 +45,7 @@ public void startUp() { /** * Testing of {@link OF10QueueGetConfigInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { @@ -53,10 +53,10 @@ public void test() throws Exception { BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setPort(new PortNumber(6653L)); GetQueueConfigInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); queueFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 20, 12); Assert.assertEquals("Wrong port", 6653L, out.readUnsignedShort()); out.skipBytes(2); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index cfb64acc..f7171223 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -74,16 +74,16 @@ public void testDesc() throws Exception { caseBuilder.setMultipartRequestDesc(descBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 12); Assert.assertEquals("Wrong type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - + /** * Testing OF10StatsRequestInputFactory (Flow) for correct serialization * @throws Exception @@ -119,10 +119,10 @@ public void testFlow() throws Exception { caseBuilder.setMultipartRequestFlow(flowBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 56); Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); @@ -150,7 +150,7 @@ public void testFlow() throws Exception { Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - + /** * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization * @throws Exception @@ -186,10 +186,10 @@ public void testAggregate() throws Exception { caseBuilder.setMultipartRequestFlow(flowBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 56); Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); @@ -217,7 +217,7 @@ public void testAggregate() throws Exception { Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - + /** * Testing OF10StatsRequestInputFactory (Table) for correct serialization * @throws Exception @@ -233,16 +233,16 @@ public void testTable() throws Exception { caseBuilder.setMultipartRequestTable(tableBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 12); Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } - + /** * Testing OF10StatsRequestInputFactory (Port) for correct serialization * @throws Exception @@ -259,10 +259,10 @@ public void testPort() throws Exception { caseBuilder.setMultipartRequestPortStats(portBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 20); Assert.assertEquals("Wrong type", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); @@ -288,10 +288,10 @@ public void testQueue() throws Exception { caseBuilder.setMultipartRequestQueue(queueBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, (byte) 16, 20); Assert.assertEquals("Wrong type", 5, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 8cc92e2a..5da3a53d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -59,7 +59,7 @@ public void startUp() { /** * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPacketOutInputMessage() throws Exception { @@ -80,10 +80,10 @@ public void testPacketOutInputMessage() throws Exception { builder.setAction(actions); builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14")); PacketOutInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); packetOutFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 56); Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), out.readUnsignedInt()); Assert.assertEquals("Wrong PortNumber", message.getInPort().getValue().longValue(), out.readUnsignedInt()); @@ -101,7 +101,7 @@ public void testPacketOutInputMessage() throws Exception { /** * Testing of {@link PacketOutInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPacketOutInputWithNoData() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index ce226535..fd4f4ca8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -53,7 +53,7 @@ public void startUp() { /** * Testing of {@link PortModInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testPortModInput() throws Exception { @@ -64,14 +64,14 @@ public void testPortModInput() throws Exception { builder.setConfig(new PortConfig(true, false, true, false)); builder.setMask(new PortConfig(false, true, false, true)); builder.setAdvertise(new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, + false, false, false, true, + false, false, false, false, false, false, false, false)); PortModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); portModFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt()); out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01); @@ -93,7 +93,7 @@ private static PortConfig createPortConfig(long input){ final Boolean _noPacketIn = ((input) & (1<<6)) > 0; return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown); } - + private static PortFeatures createPortFeatures(long input){ final Boolean _10mbHd = ((input) & (1<<0)) > 0; final Boolean _10mbFd = ((input) & (1<<1)) > 0; @@ -111,8 +111,8 @@ private static PortFeatures createPortFeatures(long input){ final Boolean _autoneg = ((input) & (1<<13)) > 0; final Boolean _pause = ((input) & (1<<14)) > 0; final Boolean _pauseAsym = ((input) & (1<<15)) > 0; - return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, + return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd, _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym); } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java index a67b2a48..5f21f65b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Testing of {@link RoleRequestInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testRoleRequestInputMessage() throws Exception { @@ -60,10 +60,10 @@ public void testRoleRequestInputMessage() throws Exception { byte[] generationId = new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}; builder.setGenerationId(new BigInteger(1, generationId)); RoleRequestInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); roleFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong role", message.getRole().getIntValue(), ControllerRole.forValue((int) out.readUnsignedInt()).getIntValue()); out.skipBytes(PADDING_IN_ROLE_REQUEST_MESSAGE); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index c9ed91e3..d31a117a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -56,7 +56,7 @@ public void startUp() { } /** - * @throws Exception + * @throws Exception * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO */ @Test @@ -78,7 +78,7 @@ public void testSetAsyncInputMessage() throws Exception { Assert.assertEquals("Wrong portStatusMask", 0, out.readUnsignedInt()); Assert.assertEquals("Wrong flowRemovedMask", 15, out.readUnsignedInt()); Assert.assertEquals("Wrong flowRemovedMask", 0, out.readUnsignedInt()); - + } private static List createPacketInMask() { @@ -140,7 +140,7 @@ private static List createFlowRemowedMask() { } /** - * @throws Exception + * @throws Exception * Testing of {@link SetAsyncInputMessageFactory} for correct translation from POJO */ @Test diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java index bd41db6e..c188b593 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java @@ -47,7 +47,7 @@ public void startUp() { /** * Testing of {@link SetConfigMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testSetConfigMessageV13() throws Exception { @@ -57,18 +57,18 @@ public void testSetConfigMessageV13() throws Exception { builder.setFlags(flag); builder.setMissSendLen(10); SetConfigInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); setConfigFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong flags", SwitchConfigFlag.FRAGNORMAL.getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong missSendLen", 10, out.readUnsignedShort()); } - + /** * Testing of {@link SetConfigMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testSetConfigMessageV10() throws Exception { @@ -78,10 +78,10 @@ public void testSetConfigMessageV10() throws Exception { builder.setFlags(flag); builder.setMissSendLen(85); SetConfigInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); setConfigFactory.serialize(message, out); - + BufferHelper.checkHeaderV10(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong flags", SwitchConfigFlag.OFPCFRAGDROP.getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong missSendLen", 85, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java index d547f064..6423a326 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java @@ -47,7 +47,7 @@ public void startUp() { /** * Testing of {@link TableModInputMessageFactory} for correct translation from POJO - * @throws Exception + * @throws Exception */ @Test public void testTableModInput() throws Exception { @@ -56,14 +56,14 @@ public void testTableModInput() throws Exception { builder.setTableId(new TableId(9L)); builder.setConfig(new TableConfig(true)); TableModInput message = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); tableModFactory.serialize(message, out); - + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 16); Assert.assertEquals("Wrong TableID", message.getTableId().getValue().intValue(), out.readUnsignedByte()); out.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE); Assert.assertEquals("Wrong TableConfig", 8, out.readUnsignedInt()); } - + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java index b747e3e7..f5c8cad6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Tests {@link MultipartRequestInputFactory} - GroupDesc case - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java index ff0012e0..630deca7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Tests {@link MultipartRequestInputFactory} - GroupFeatures case - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java index 7f04ba49..9106a580 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Tests {@link MultipartRequestInputFactory} - MeterFeatures case - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java index fd8365d2..be5b244a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Tests {@link MultipartRequestInputFactory} - PortDesc case - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java index 724b55e5..11383b9f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java @@ -50,7 +50,7 @@ public void startUp() { /** * Tests {@link MultipartRequestInputFactory} - Table case - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 2831e6d5..711c0d45 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -54,7 +54,7 @@ public void startUp() { /** * Tests {@link OF10StatsRequestInputFactory} for correct serialization - * @throws Exception + * @throws Exception */ @Test public void test() throws Exception { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java index 1f1c8bf8..ab564ee0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java @@ -36,7 +36,7 @@ public class OxmArpOpSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareArpOpHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java index b0dc9276..3cd8d886 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -40,7 +40,7 @@ public class OxmArpShaSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[6]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java index 83d6afe7..8f60a449 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -40,7 +40,7 @@ public class OxmArpSpaSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[4]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java index cc0f5d4c..1bd15a7b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -40,7 +40,7 @@ public class OxmArpThaSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[6]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java index 90b51395..5122e822 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -40,7 +40,7 @@ public class OxmArpTpaSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[4]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java index 3a34fdde..03116abd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -40,7 +40,7 @@ public class OxmEthDstSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[6]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java index 984899c1..6f143277 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -40,7 +40,7 @@ public class OxmEthSrcSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[6]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java index ae82abc9..7850358f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java @@ -37,7 +37,7 @@ public class OxmEthTypeSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareEthTypeHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,7 +84,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { MatchEntriesBuilder builder = prepareEthTypeHeader(false); EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java index ec559978..8afa0c1c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java @@ -36,7 +36,7 @@ public class OxmIcmpv4CodeSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,7 +83,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java index 1c0c08ba..23df28c8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java @@ -36,7 +36,7 @@ public class OxmIcmpv4TypeSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,7 +83,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java index f4525441..410fa4aa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java @@ -36,7 +36,7 @@ public class OxmIcmpv6CodeSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java index 1c4240ad..c97a7d42 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java @@ -36,7 +36,7 @@ public class OxmIcmpv6TypeSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,7 +83,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java index 0373589c..9fdd7dda 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -37,7 +37,7 @@ public class OxmIpDscpSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareIpDscpHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java index 2672e807..21e2deaf 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java @@ -36,7 +36,7 @@ public class OxmIpProtoSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry((short) 123); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java index 69499578..7cb8db66 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -40,7 +40,7 @@ public class OxmIpv4DstSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[4]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java index 69866caa..6ea93c2a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -40,7 +40,7 @@ public class OxmIpv4SrcSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,12 +57,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[4]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); @@ -78,7 +78,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -92,7 +92,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java index 0924f100..eb8d3644 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java @@ -41,7 +41,7 @@ public class OxmIpv6ExtHdrSerializerTest { public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,7 +57,7 @@ public void testSerializeWithMask() { public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -75,7 +75,7 @@ public void testSerializeWithoutMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -89,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -121,7 +121,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); if (hasMask) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java index 52df5db1..3e9dce5d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -40,7 +40,7 @@ public class OxmIpv6NdSllSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,7 +57,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java index 6c6e8d31..29585d9b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -40,7 +40,7 @@ public class OxmIpv6NdTllSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -57,7 +57,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java index fbe202dc..b790e133 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java @@ -39,7 +39,7 @@ public class OxmMetadataSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,12 +56,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[8]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); @@ -77,7 +77,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +91,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java index 6c22ec4a..0bc77dbc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java @@ -36,7 +36,7 @@ public class OxmMplsBosSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareMplsBosHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,7 +83,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { MatchEntriesBuilder builder = prepareMplsBosHeader(false); BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java index c20890b9..742001f7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java @@ -36,7 +36,7 @@ public class OxmMplsLabelSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java index d851b755..737eba0a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java @@ -36,7 +36,7 @@ public class OxmMplsTcSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareMplsTcHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java index f2cbf897..02742e88 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java @@ -39,7 +39,7 @@ public class OxmPbbIsidSerializerTest { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -54,7 +54,7 @@ public void testSerializeWithMask() { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -72,7 +72,7 @@ public void testSerializeWithoutMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = preparePbbIsidHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -86,7 +86,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = preparePbbIsidHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -118,7 +118,7 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); } - + private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); if (hasMask) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java index e56c5c0d..9bf4e07b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -37,7 +37,7 @@ public class OxmSctpDstSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(4096); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java index 6c3890c4..91d3099f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -37,7 +37,7 @@ public class OxmSctpSrcSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(4096); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java index b912aed3..431725ae 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -37,7 +37,7 @@ public class OxmTcpDstSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(4096); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java index c156b2f5..3cdd17e3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -37,7 +37,7 @@ public class OxmTcpSrcSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(512); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java index 35f2986e..73cc676a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java @@ -39,7 +39,7 @@ public class OxmTunnelIdSerializerTest { @Test public void testSerializeWithoutMask() { MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,12 +56,12 @@ public void testSerializeWithoutMask() { @Test public void testSerializeWithMask() { MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); checkHeader(buffer, true); - + byte[] address = new byte[8]; buffer.readBytes(address); Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); @@ -77,7 +77,7 @@ public void testSerializeWithMask() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +91,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java index 1cafb491..35318d8f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -37,7 +37,7 @@ public class OxmUdpDstSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(2048); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java index d4989830..7cb4d0ab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -37,7 +37,7 @@ public class OxmUdpSrcSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareMatchEntry(1024); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -52,7 +52,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java index ba08ad08..b96e0d76 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java @@ -36,7 +36,7 @@ public class OxmVlanPcpSerializerTest { @Test public void testSerialize() { MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { @Test public void testSerializeHeader() { MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java index f0ae6dea..a22e6c81 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java @@ -39,7 +39,7 @@ public class OxmVlanVidSerializerTest { @Test public void testSerializeWithCfiBitSet() { MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -54,7 +54,7 @@ public void testSerializeWithCfiBitSet() { @Test public void testSerializeWithoutCfiBitSet() { MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -72,7 +72,7 @@ public void testSerializeWithoutCfiBitSet() { @Test public void testSerializeHeaderWithoutMask() { MatchEntriesBuilder builder = prepareVlanVidHeader(false); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -86,7 +86,7 @@ public void testSerializeHeaderWithoutMask() { @Test public void testSerializeHeaderWithMask() { MatchEntriesBuilder builder = prepareVlanVidHeader(true); - + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index d7d29d84..e9f98b7c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -72,10 +72,10 @@ public void test() { + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " + "00 1A 00 08 00 0A 00 00 " + "00 1B 00 08 00 00 00 00"); - + message.skipBytes(4); // skip XID LOGGER.info("bytes: " + message.readableBytes()); - + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); @@ -132,7 +132,7 @@ public void test() { Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); - Assert.assertEquals("Wrong match entry value", 11, + Assert.assertEquals("Wrong match entry value", 11, entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index 6a857639..dcdbec18 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -23,12 +23,12 @@ /** * @author michal.polkorab - * + * */ public abstract class BufferHelper { /** - * + * */ public static final Long DEFAULT_XID = 0x01020304L; private static final byte[] XID = new byte[] { 0x01, 0x02, 0x03, 0x04 }; @@ -44,7 +44,7 @@ public static ByteBuf buildBuffer(byte[] payload) { bb.writeBytes(payload); return bb; } - + /** * @param payload String in hex format * @return ByteBuf filled with OpenFlow protocol message without first 4 @@ -53,7 +53,7 @@ public static ByteBuf buildBuffer(byte[] payload) { public static ByteBuf buildBuffer(String payload) { return buildBuffer(ByteBufUtils.hexStringToBytes(payload)); } - + /** * @return ByteBuf filled with OpenFlow protocol header message without first 4 * bytes @@ -74,7 +74,7 @@ public static ByteBuf buildBuffer() { public static void checkHeaderV13(ByteBuf input, byte msgType, int length) { checkHeader(input, msgType, length, (short) EncodeConstants.OF13_VERSION_ID); } - + /** * Use version 1.0 for encoded message * @param input ByteBuf to be checked for correct OpenFlow Protocol header @@ -84,14 +84,14 @@ public static void checkHeaderV13(ByteBuf input, byte msgType, int length) { public static void checkHeaderV10(ByteBuf input, byte msgType, int length) { checkHeader(input, msgType, length, (short) EncodeConstants.OF10_VERSION_ID); } - + private static void checkHeader(ByteBuf input, byte msgType, int length, Short version) { Assert.assertEquals("Wrong version", version, Short.valueOf(input.readByte())); Assert.assertEquals("Wrong type", msgType, input.readByte()); Assert.assertEquals("Wrong length", length, input.readUnsignedShort()); Assert.assertEquals("Wrong Xid", DEFAULT_XID, Long.valueOf(input.readUnsignedInt())); } - + /** * @param ofHeader OpenFlow protocol header @@ -99,19 +99,19 @@ private static void checkHeader(ByteBuf input, byte msgType, int length, Short v public static void checkHeaderV13(OfHeader ofHeader) { checkHeader(ofHeader, (short) EncodeConstants.OF13_VERSION_ID); } - + /** * @param ofHeader OpenFlow protocol header */ public static void checkHeaderV10(OfHeader ofHeader) { checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID); } - + private static void checkHeader(OfHeader ofHeader, Short version) { Assert.assertEquals("Wrong version", version, ofHeader.getVersion()); Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid()); } - + /** * @param builder * @param version wire protocol number used diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index adb6941e..39452dcc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -57,9 +57,9 @@ public void test() { + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00"); - + message.skipBytes(4); // skip XID - + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index a3ad2abb..e325baff 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -132,14 +132,14 @@ public void testIpv4Address() { Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); } - + /** * Testing Ipv6 address deserialization */ @Test public void testIpv6Address() { ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); - + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26); key.setExperimenterId(null); @@ -148,7 +148,7 @@ public void testIpv6Address() { Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); } - + /** * Testing match deserialization */ @@ -219,25 +219,25 @@ public void testMatch() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), entry2.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry3 = entries.get(3); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), entry3.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry4 = entries.get(4); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), entry4.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry5 = entries.get(5); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); @@ -251,9 +251,9 @@ public void testMatch() { Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); Assert.assertEquals("Wrong entry value", 10, entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, + Assert.assertEquals("Wrong entry value", false, entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), entry6.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry7 = entries.get(7); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); @@ -285,7 +285,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), entry11.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry12 = entries.get(12); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); @@ -293,7 +293,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), entry12.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry13 = entries.get(13); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); @@ -355,7 +355,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), entry22.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry23 = entries.get(23); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); @@ -363,47 +363,47 @@ public void testMatch() { Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), entry23.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry24 = entries.get(24); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), entry24.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry25 = entries.get(25); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), entry25.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry26 = entries.get(26); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), entry26.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry27 = entries.get(27); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), entry27.getAugmentation(MaskMatchEntry.class).getMask()); MatchEntries entry28 = entries.get(28); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, + Assert.assertEquals("Wrong entry value", 2, entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), entry28.getAugmentation(MaskMatchEntry.class).getMask()); @@ -411,25 +411,25 @@ public void testMatch() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); - Assert.assertEquals("Wrong entry value", 21, + Assert.assertEquals("Wrong entry value", 21, entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); MatchEntries entry30 = entries.get(30); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); - Assert.assertEquals("Wrong entry value", 23, + Assert.assertEquals("Wrong entry value", 23, entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); MatchEntries entry31 = entries.get(31); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); MatchEntries entry32 = entries.get(32); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), + Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); MatchEntries entry33 = entries.get(33); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 3e83bf4b..2dd21e82 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -63,7 +63,7 @@ public void test() { + "00 09 00 08 00 02 00 00 " + "00 0A 00 08 00 03 00 00 " + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); - + message.skipBytes(4); // skip XID CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, @@ -97,7 +97,7 @@ public void test() { Action action6 = actions.get(5); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); - Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), + Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); Action action7 = actions.get(6); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index 3b72cb4d..ad9f0c14 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -72,7 +72,7 @@ public void startUp() { } /** - * Testing correct serialization of actions (OF v1.0) + * Testing correct serialization of actions (OF v1.0) */ @Test public void test() { @@ -152,11 +152,11 @@ public void test() { queueBuilder.setQueueId(400L); actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); actions.add(actionBuilder.build()); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(actions, TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); - + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong port", 42, out.readUnsignedShort()); @@ -215,5 +215,5 @@ public void test() { Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); } - + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 262be94b..0201f609 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -69,7 +69,7 @@ public void test() { Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue()); Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue()); } - + /** * Testing correct deserialization of ofp_match */ diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index ca295ea1..e19ede8c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -70,7 +70,7 @@ public void test() { builder.setTpDst(4096); MatchV10 match = builder.build(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt()); Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort()); byte[] dlSrc = new byte[6]; @@ -91,7 +91,7 @@ public void test() { Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort()); Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort()); } - + /** * Testing correct serialization of ofp_match */ @@ -117,7 +117,7 @@ public void test2() { builder.setTpDst(4096); MatchV10 match = builder.build(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt()); Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort()); byte[] dlSrc = new byte[6]; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index 4f01fd20..ed47b014 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -64,7 +64,7 @@ /** * @author michal.polkorab - * + * */ public class OF13ActionsSerializerTest { @@ -175,11 +175,11 @@ public void test() { actionBuilder = new ActionBuilder(); actionBuilder.setType(PopPbb.class); actions.add(actionBuilder.build()); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(actions, TypeKeyMakerFactory .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 68fe7510..6e972f82 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -142,11 +142,11 @@ public void test() { actionsBuilder.setAction(actions); builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); instructions.add(builder.build()); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(instructions, TypeKeyMakerFactory .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index e607d0fc..a29b8437 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -152,15 +152,15 @@ public void testEmptyMatch() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); Match match = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); Assert.assertTrue("Wrong padding", out.readableBytes() == 4); } - + /** * Testing serialization of match */ @@ -510,7 +510,7 @@ public void test() { bosBuilder.setBos(true); entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); entries.add(entryBuilder.build()); - + entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(PbbIsid.class); @@ -522,7 +522,7 @@ public void test() { maskBuilder.setMask(new byte[]{0,1,2}); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); - + entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TunnelId.class); @@ -534,7 +534,7 @@ public void test() { maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); - + entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Exthdr.class); @@ -546,15 +546,15 @@ public void test() { maskBuilder.setMask(new byte[]{0,2}); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); - - - + + + builder.setMatchEntries(entries); Match match = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index ca39e1a7..6b82e9e6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -94,10 +94,10 @@ public void testIpv4Src() { entries.add(entriesBuilder.build()); builder.setMatchEntries(entries); Match match = builder.build(); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); @@ -108,7 +108,7 @@ public void testIpv4Src() { Assert.assertEquals("Wrong ip address (third number)", 3, out.readUnsignedByte()); Assert.assertEquals("Wrong ip address (fourth number)", 4, out.readUnsignedByte()); } - + /** * Test for correct serialization of Ipv6Address match entry */ @@ -166,7 +166,7 @@ public void testIpv6Various() { Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); @@ -255,10 +255,10 @@ public void testIpv6Incorrect() { @Test public void testIpv6Flabel() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); @@ -266,21 +266,21 @@ public void testIpv6Flabel() { out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); byte[] label = new byte[4]; out.readBytes(label); - + LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label); } - + /** * Test for correct serialization of Ipv4Address match entry with mask */ @Test public void testIpv6FlabelWithMask() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 0x0c, 0x7b, 0x6a}); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); - + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); @@ -288,20 +288,20 @@ public void testIpv6FlabelWithMask() { out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); byte[] labelAndMask = new byte[8]; out.readBytes(labelAndMask); - + LOG.debug("label: "+ByteBufUtils.bytesToHexString(labelAndMask)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d, 0, 0x0c, 0x7b, 0x6a}, labelAndMask); } - + /** * Test for correct serialization of Ipv4Address match entry with wrong mask */ @Test public void testIpv6FlabelWithMaskBad() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0x0c, 0x7b, 0x6a}); - + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - + try { matchSerializer.serialize(match, out); Assert.fail("incorrect length of mask ignored"); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java index d922d590..fbe48b17 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory; /** - * General tests for StatisticsCounters class + * General tests for StatisticsCounters class * @author madamjak * */ @@ -54,7 +54,7 @@ public void testCounterAll() { } else { Assert.assertNull("Wrong - not enabled counter give not null value", statCounters.getCounter(cet)); } - + } statCounters.resetCounters(); for(CounterEventTypes cet : CounterEventTypes.values()){ diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 4ef8ec36..2751cc9f 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -12,7 +12,7 @@ https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD - + ${project.groupId} diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index a1440961..411bc5ea 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -47,7 +47,7 @@ public class IntegrationTest { private static final Logger LOGGER = LoggerFactory .getLogger(IntegrationTest.class); - + private static int port; private TlsConfiguration tlsConfiguration; private static final int SWITCH_IDLE_TIMEOUT = 2000; @@ -63,7 +63,7 @@ public class IntegrationTest { */ public void setUp(TransportProtocol protocol) throws Exception { LOGGER.debug("\n starting test -------------------------------"); - + String currentDir = System.getProperty("user.dir"); LOGGER.debug("Current dir using System:" +currentDir); startupAddress = InetAddress.getLocalHost(); @@ -76,7 +76,7 @@ public void setUp(TransportProtocol protocol) throws Exception { connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); connConfig.setTransferProtocol(protocol); mockPlugin = new MockPlugin(); - + switchConnectionProvider = new SwitchConnectionProviderImpl(); switchConnectionProvider.setSwitchConnectionHandler(mockPlugin); switchConnectionProvider.setConfiguration(connConfig); @@ -101,7 +101,7 @@ public void tearDown() throws Exception { /** * Library integration and communication test with handshake - * @throws Exception + * @throws Exception */ @Test public void testHandshake() throws Exception { @@ -113,13 +113,13 @@ public void testHandshake() throws Exception { OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); - + LOGGER.debug("testHandshake() Finished") ; } /** * Library integration and secured communication test with handshake - * @throws Exception + * @throws Exception */ @Test public void testTlsHandshake() throws Exception { @@ -131,13 +131,13 @@ public void testTlsHandshake() throws Exception { OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); - + LOGGER.debug("testTlsHandshake() Finished") ; } /** * Library integration and communication test with handshake + echo exchange - * @throws Exception + * @throws Exception */ @Test public void testHandshakeAndEcho() throws Exception { @@ -158,7 +158,7 @@ public void testHandshakeAndEcho() throws Exception { /** * Library integration and secured communication test with handshake + echo exchange - * @throws Exception + * @throws Exception */ @Test public void testTlsHandshakeAndEcho() throws Exception { @@ -179,7 +179,7 @@ public void testTlsHandshakeAndEcho() throws Exception { /** * Library udp integration and communication test with handshake + echo exchange - * @throws Exception + * @throws Exception */ @Test public void testUdpHandshakeAndEcho() throws Exception { @@ -208,7 +208,7 @@ public void testCommunicationWithVM() throws Exception { } /** - * @param amountOfCLients + * @param amountOfCLients * @param protocol true if encrypted connection should be used * @return new clients up and running * @throws ExecutionException if some client could not start diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index b4f69bb0..f8298bbf 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -48,7 +48,7 @@ * @author michal.polkorab * */ -public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler, +public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHandler, SystemNotificationsListener, ConnectionReadyListener { protected static final Logger LOGGER = LoggerFactory.getLogger(MockPlugin.class); @@ -62,7 +62,7 @@ public MockPlugin() { finishedFuture = SettableFuture.create(); LOGGER.debug("mockPlugin: "+System.identityHashCode(this)); } - + @Override public void onSwitchConnected(ConnectionAdapter connection) { LOGGER.debug("onSwitchConnected: " + connection); @@ -100,19 +100,19 @@ public void run() { @Override public void onErrorMessage(ErrorMessage notification) { LOGGER.debug("Error message received"); - + } @Override public void onExperimenterMessage(ExperimenterMessage notification) { LOGGER.debug("Experimenter message received"); - + } @Override public void onFlowRemovedMessage(FlowRemovedMessage notification) { LOGGER.debug("FlowRemoved message received"); - + } @Override @@ -137,7 +137,7 @@ public void run() { }).start(); } - + protected void getSwitchFeatures() { GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder(); featuresBuilder.setVersion((short) 4); @@ -169,7 +169,7 @@ protected void shutdown() { Future disconnect = adapter.disconnect(); disconnect.get(); LOGGER.debug("MockPlugin.shutdown() Disconnected"); - } + } } catch (Exception e) { LOGGER.error("MockPlugin.shutdown() exception caught: ", e.getMessage(), e); } @@ -179,7 +179,7 @@ protected void shutdown() { @Override public void onMultipartReplyMessage(MultipartReplyMessage notification) { LOGGER.debug("MultipartReply message received"); - + } @Override @@ -198,7 +198,7 @@ public void onPacketInMessage(PacketInMessage notification) { @Override public void onPortStatusMessage(PortStatusMessage notification) { LOGGER.debug("MockPlugin.onPortStatusMessage() message received"); - + } @Override @@ -225,7 +225,7 @@ public void onSwitchIdleEvent(SwitchIdleEvent notification) { public int getIdleCounter() { return idleCounter; } - + @Override public void onConnectionReady() { LOGGER.trace("MockPlugin().onConnectionReady()"); diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 6cef4f39..18369f5e 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -7,13 +7,13 @@ openflow-protocol-spi bundle - + Openflow Protocol Library - SPI https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD - + @@ -81,7 +81,7 @@ - + ${project.groupId} diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index 69d08fbb..b57500b4 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -28,20 +28,20 @@ public interface SwitchConnectionProvider extends AutoCloseable, * @param configuration [protocol, port, address and supported features] */ void setConfiguration(ConnectionConfiguration configuration); - + /** * start listening to switches, but please don't forget to do * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first * @return future, triggered to true, when listening channel is up and running */ ListenableFuture startup(); - + /** * stop listening to switches * @return future, triggered to true, when all listening channels are down */ ListenableFuture shutdown(); - + /** * @param switchConHandler instance being informed when new switch connects */ diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java index 1d2c580b..3779a5eb 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java @@ -10,7 +10,7 @@ /** * Used for JConsole service - * + * * @author michal.polkorab */ public interface StatisticsHandler { diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index 91edd9e8..deeade0d 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -1,7 +1,7 @@ - diff --git a/pom.xml b/pom.xml index 71becad6..67148ce6 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ 2010.09.24.7-SNAPSHOT 2013.09.07.7-SNAPSHOT 2.4.0 - 14.0.1 + 14.0.1 4.0.23.Final 2.3.2 0.7.0-SNAPSHOT @@ -266,7 +266,7 @@ deploy jar-no-fork - + diff --git a/simple-client/pom.xml b/simple-client/pom.xml index e73c7624..a68633e1 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -12,7 +12,7 @@ https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD - + @@ -26,7 +26,7 @@ - + ${project.groupId} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java index a6d93aba..9b46d6c0 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java @@ -45,14 +45,14 @@ private ClientSslContextFactory() { KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(ks, ClientSslKeyStore.getCertificatePassword()); - + KeyStore ts = KeyStore.getInstance("JKS"); ts.load(ClientSslTrustStore.asInputStream(), ClientSslTrustStore.getKeyStorePassword()); - + TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); tmf.init(ts); - + clientContext = SSLContext.getInstance(PROTOCOL); clientContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); } catch (Exception e) { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java index 02a2199a..169395c6 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java @@ -12,7 +12,7 @@ /** * Unifying interface for simple clients / switch simulators - * + * * @author michal.polkorab */ public interface OFClient extends Runnable { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 264bedfd..a6afb6a5 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -14,7 +14,7 @@ /** * Class for providing prepared handshake scenario - * + * * @author michal.polkorab */ public final class ScenarioFactory { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 61333f87..075c6568 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; /** - * + * * @author michal.polkorab * */ @@ -33,7 +33,7 @@ public class ScenarioHandler extends Thread { private boolean scenarioFinished = false; /** - * + * * @param scenario */ public ScenarioHandler(Stack scenario) { @@ -84,7 +84,7 @@ public void run() { this.notify(); } } - + /** * @return true if scenario is done / empty */ diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index db339eb2..c5765272 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -17,7 +17,7 @@ /** * Class representing sending message event - * + * * @author michal.polkorab */ public class SendEvent implements ClientEvent { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index 89854c7e..b097b1d1 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -37,7 +37,7 @@ public class SimpleClient implements OFClient { private SettableFuture isOnlineFuture; private SettableFuture scenarioDone; private ScenarioHandler scenarioHandler; - + /** * Constructor of class * @@ -54,7 +54,7 @@ private void init() { isOnlineFuture = SettableFuture.create(); scenarioDone = SettableFuture.create(); } - + /** * Starting class of {@link SimpleClient} */ diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java index 1c888067..01e114bf 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java @@ -62,7 +62,7 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { } scenarioHandler.setCtx(ctx); scenarioHandler.start(); - + } /** diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index c44a660c..a2fe3a11 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -19,11 +19,11 @@ import com.google.common.util.concurrent.SettableFuture; /** Initializes secured {@link SimpleClient} pipeline - * + * * @author michal.polkorab */ public class SimpleClientInitializer extends ChannelInitializer { - + private SettableFuture isOnlineFuture; private boolean secured; private ScenarioHandler scenarioHandler; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java index 25ed0d46..b1e1a50c 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java @@ -13,7 +13,7 @@ /** * Class representing sleep (wait) event - * + * * @author michal.polkorab */ public class SleepEvent implements ClientEvent { @@ -22,7 +22,7 @@ public class SleepEvent implements ClientEvent { private long sleepTime; /** - * + * * @param sleepTime time of {@link Thread#sleep(long)} in milliseconds */ public SleepEvent(long sleepTime) { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java index 92e88672..e9d69da1 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -37,7 +37,7 @@ public class UdpSimpleClient implements OFClient { private SettableFuture isOnlineFuture; private SettableFuture scenarioDone; private ScenarioHandler scenarioHandler; - + /** * Constructor of class * @@ -54,7 +54,7 @@ private void init() { isOnlineFuture = SettableFuture.create(); scenarioDone = SettableFuture.create(); } - + /** * Starting class of {@link UdpSimpleClient} */ @@ -125,7 +125,7 @@ public static void main(String[] args) throws Exception { sc = new UdpSimpleClient(host, port); } sc.run(); - + } @Override diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java index cd7a8a8a..11444427 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java @@ -16,11 +16,11 @@ import com.google.common.util.concurrent.SettableFuture; /** Initializes udp pipeline - * + * * @author michal.polkorab */ public class UdpSimpleClientInitializer extends ChannelInitializer { - + private SettableFuture isOnlineFuture; private ScenarioHandler scenarioHandler; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index c4c786c6..bcf696e9 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -19,7 +19,7 @@ * @author michal.polkorab */ public class WaitForMessageEvent implements ClientEvent { - + private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class); private byte[] headerExpected; private byte[] headerReceived; diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 9bbb0d74..7113eb06 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -31,7 +31,7 @@ public class ByteBufUtilsTest { private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff}; - + /** * Test of {@link org.opendaylight.openflowjava.util.ByteBufUtils#hexStringToBytes(String)} */ @@ -58,10 +58,10 @@ public void testHexStringToBytes2() { @Test public void testHexStringToByteBuf() { ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff"); - + Assert.assertArrayEquals(expected, byteBufToByteArray(bb)); } - + /** * Test of {@link ByteBufUtils#hexStringToByteBuf(String, ByteBuf)} */ @@ -72,13 +72,13 @@ public void testHexStringToGivenByteBuf() { Assert.assertArrayEquals(expected, byteBufToByteArray(buffer)); } - + private static byte[] byteBufToByteArray(ByteBuf bb) { byte[] result = new byte[bb.readableBytes()]; bb.readBytes(result); return result; } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)} */ @@ -87,15 +87,15 @@ public void testFillBitmaskByEmptyMap() { Map emptyMap = new HashMap<>(); String expectedBinaryString = "00000000000000000000000000000000"; String bitmaskInBinaryString = toBinaryString(emptyMap, 32); - + Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString); } private static String toBinaryString(Map emptyMap, int length) { - String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap)); + String binaryString = Integer.toBinaryString(ByteBufUtils.fillBitMaskFromMap(emptyMap)); return String.format("%"+length+"s", binaryString).replaceAll(" ", "0"); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)} */ @@ -110,7 +110,7 @@ public void testFillBitmaskByFullMap() { bitmaskValueInBinarySytring = toBinaryString(fullMap, 32); Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)} */ @@ -125,7 +125,7 @@ public void testFillBitmaskByZeroMap() { bitmaskValueInBinarySytring = toBinaryString(zeroMap, 32); Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromMap(java.util.Map)} */ @@ -145,7 +145,7 @@ public void testFillBitmaskByRandomSet() { bitmaskValueInBinarySytring = toBinaryString(randomMap, 32); Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromList(List)} */ @@ -155,17 +155,17 @@ public void testFillBitmaskByEmptyList() { emptyList.add(null); String expectedBinaryString = "00000000000000000000000000000000"; String bitmaskInBinaryString = listToBinaryString(emptyList, 32); - + Assert.assertEquals("Not null string", expectedBinaryString, bitmaskInBinaryString); } private static String listToBinaryString(List emptyList, int length) { int[] bitMaskArray; bitMaskArray = ByteBufUtils.fillBitMaskFromList(emptyList); - String binaryString = Integer.toBinaryString(bitMaskArray[0]); + String binaryString = Integer.toBinaryString(bitMaskArray[0]); return String.format("%"+length+"s", binaryString).replaceAll(" ", "0"); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromList(List)} */ @@ -180,7 +180,7 @@ public void testFillBitmaskByFullList() { bitmaskValueInBinarySytring = listToBinaryString(fullList, 32); Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromList(List)} */ @@ -195,7 +195,7 @@ public void testFillBitmaskByZeroList() { bitmaskValueInBinarySytring = listToBinaryString(zeroList, 32); Assert.assertEquals("Strings does not match", expectedBinaryString, bitmaskValueInBinarySytring); } - + /** * Test of {@link ByteBufUtils#fillBitMaskFromList(List)} */ @@ -323,7 +323,7 @@ public void testMacToString() { public void testDecodeString() { ByteBuf buf = ByteBufUtils.hexStringToByteBuf("4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00"); Assert.assertEquals("Wrong string decoded", "JAMES BOND", ByteBufUtils.decodeNullTerminatedString(buf, 16)); - + ByteBuf buf2 = ByteBufUtils.hexStringToByteBuf("53 50 49 44 45 52 4D 41 4E 00 00 00 00 00 00"); Assert.assertEquals("Wrong string decoded", "SPIDERMAN", ByteBufUtils.decodeNullTerminatedString(buf2, 15)); } @@ -409,7 +409,7 @@ public void testReadIpv4Address() { String ipv4Address = ByteBufUtils.readIpv4Address(buffer); Assert.assertEquals("Wrong conversion", "10.20.30.40", ipv4Address); Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - + ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer(); buffer.writeByte(10); ipv4Address = ByteBufUtils.readIpv4Address(buffer2); @@ -432,7 +432,7 @@ public void testReadIpv6Address() { String ipv4Address = ByteBufUtils.readIpv6Address(buffer); Assert.assertEquals("Wrong conversion", "000A:FFFF:1000:0000:0400:002A:0A08:B279", ipv4Address); Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0); - + ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer(); buffer.writeShort(10); ipv4Address = ByteBufUtils.readIpv6Address(buffer2); From 3a71d1a912829b14bb474c5e4ab8afdf6f206e4b Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 9 Jan 2015 09:43:25 +0100 Subject: [PATCH 117/285] Features updated (odl-mdsal-common) - features.xml updated with mdsal repository as odl-mdsal-common feature had been moved to new location - added dependency into features-openflowjava pom.xml (new odl-mdsal-common feature location) - introduced new property (mdsal.version)in parent pom.xml Change-Id: I9854b88b6db970f0446fe5bb57057568ee118ce1 Signed-off-by: Michal Polkorab --- features/pom.xml | 7 +++++++ features/src/main/resources/features.xml | 3 ++- pom.xml | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/features/pom.xml b/features/pom.xml index 095f12b9..4308571f 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -31,6 +31,13 @@ features xml + + org.opendaylight.controller + features-mdsal + ${mdsal.version} + features + xml + diff --git a/features/src/main/resources/features.xml b/features/src/main/resources/features.xml index 87d05699..315fd338 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/resources/features.xml @@ -5,6 +5,7 @@ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features mvn:org.opendaylight.controller/features-config/${config.version}/xml/features + mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features odl-openflowjava-protocol @@ -13,7 +14,7 @@ odl-yangtools-binding odl-yangtools-models odl-config-api - odl-mdsal-common + odl-mdsal-common mvn:io.netty/netty-buffer/${netty.version} mvn:io.netty/netty-common/${netty.version} mvn:io.netty/netty-transport/${netty.version} diff --git a/pom.xml b/pom.xml index 67148ce6..f8d695db 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,7 @@ 2.3.2 0.7.0-SNAPSHOT 0.7.0-SNAPSHOT + 1.2.0-SNAPSHOT 0.3.0-SNAPSHOT From b6772b7645e64588ec230cb73832750271fb02ea Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Fri, 9 Jan 2015 15:53:27 -0500 Subject: [PATCH 118/285] Set root pom.xml for Sonar As mentioned on the mailing list Sonar uses the field of the pom.xml that is passed to the mvn command as the name of the project in Sonar. In most cases this is the root pom.xml file in a project. This patch sets the name to the project shortname. https://lists.opendaylight.org/pipermail/discuss/2014-November/004024.html Change-Id: I51859978242e4d93ba434890a12a1014b286dd30 Signed-off-by: Thanh Ha --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index f8d695db..9b33ad39 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,9 @@ org.opendaylight.openflowjava openflow-protocol-parent 0.6.0-SNAPSHOT + openflowjava pom + openflowjava-config openflow-protocol-api From 382e88f90e056381d5f02ba3ea1041b1d144e6c9 Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Mon, 26 Jan 2015 13:36:06 +0100 Subject: [PATCH 119/285] Bug 2245 - Added private constructors to utility classes, in order to hide the implicit one. Change-Id: I9c0c0d0e2e91f87ca24c5ac5b7edb8931dbc7a2f Signed-off-by: Martin Uhlir --- .../openflowjava/protocol/api/util/BinContent.java | 4 ++++ .../openflowjava/protocol/api/util/EncodeConstants.java | 3 +++ .../openflowjava/protocol/api/util/OxmMatchConstants.java | 4 ++++ .../openflowjava/protocol/impl/util/CodeKeyMakerFactory.java | 3 +++ .../openflowjava/protocol/impl/util/ListSerializer.java | 4 ++++ .../openflowjava/protocol/impl/util/OpenflowUtils.java | 4 ++++ .../openflowjava/protocol/impl/util/TypeKeyMakerFactory.java | 4 ++++ .../java/org/opendaylight/openflowjava/util/ByteBufUtils.java | 4 ++++ .../openflowjava/util/ExperimenterDeserializerKeyFactory.java | 4 ++++ 9 files changed, 34 insertions(+) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java index aa322f91..428b5004 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java @@ -14,6 +14,10 @@ */ public abstract class BinContent { + private BinContent() { + //not called + } + /** * @param value * @return int part wrapped in long diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index cf857285..82a09282 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -58,4 +58,7 @@ public abstract class EncodeConstants { /** OF v1.3 lenght of experimenter_ids - see Multipart TableFeatures (properties) message */ public static final byte EXPERIMENTER_IDS_LENGTH = 8; + private EncodeConstants() { + //not called + } } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 3bc7558e..78a5871c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -114,4 +114,8 @@ public abstract class OxmMatchConstants { public static final int NXM_NX_TUN_IPV4_DST = 32; /** NXM TCP_Flag value */ public static final int NXM_NX_TCP_FLAG = 34; + + private OxmMatchConstants() { + //not called + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 7713e355..8a03f534 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -24,6 +24,9 @@ */ public abstract class CodeKeyMakerFactory { + private CodeKeyMakerFactory() { + //not called + } /** * @param version * @return diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index f69c25b6..8b1c7f70 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -24,6 +24,10 @@ */ public abstract class ListSerializer { + private ListSerializer() { + //not called + } + /** * Serializes item list * @param list list of items to be serialized diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java index f865ac3d..cb6e657e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -19,6 +19,10 @@ */ public abstract class OpenflowUtils { + private OpenflowUtils() { + //not called + } + /** * Creates PortState (OF v1.0) from input * @param input value read from buffer diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 2c5b7def..d9fd1340 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -29,6 +29,10 @@ */ public abstract class TypeKeyMakerFactory { + private TypeKeyMakerFactory() { + //not called + } + /** * @param version openflow wire version that shall be used * in lookup key diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 444cffc5..4ac43f65 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -35,6 +35,10 @@ public abstract class ByteBufUtils { public static final Splitter COLON_SPLITTER = Splitter.on(':'); private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray(); + private ByteBufUtils() { + //not called + } + /** * Converts ByteBuf into String * @param bb input ByteBuf diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 8ef85bc4..1a7a5d26 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -22,6 +22,10 @@ */ public abstract class ExperimenterDeserializerKeyFactory { + private ExperimenterDeserializerKeyFactory() { + //not called + } + /** * @param version openflow wire version * @param experimenterId experimenter / vendor ID From dab5b6e45ed8f2a8630cdfc47fdbff622d081bb0 Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Fri, 23 Jan 2015 13:54:24 +0100 Subject: [PATCH 120/285] Bug 2245 - Changed type parameters to comply with naming conventions Change-Id: I0593538542f6e4ee295b12b19b60058a666a8b04 Signed-off-by: Martin Uhlir --- .../api/extensibility/DeserializerRegistry.java | 4 ++-- .../api/extensibility/HeaderSerializer.java | 6 +++--- .../protocol/api/extensibility/OFSerializer.java | 6 +++--- .../SerializerExtensionProvider.java | 4 ++-- .../api/extensibility/SerializerRegistry.java | 11 ++++++----- .../protocol/api/keys/ActionSerializerKey.java | 8 ++++---- .../api/keys/InstructionSerializerKey.java | 8 ++++---- .../api/keys/MatchEntrySerializerKey.java | 14 +++++++------- .../ExperimenterIdSerializerKey.java | 6 +++--- .../impl/core/ProtocolChannelInitializer.java | 6 +++--- .../impl/core/SwitchConnectionProviderImpl.java | 6 ++++-- .../DeserializerRegistryImpl.java | 4 ++-- .../serialization/SerializerRegistryImpl.java | 16 +++++++++------- .../util/ActionSerializerRegistryHelper.java | 2 +- .../InstructionSerializerRegistryHelper.java | 2 +- .../util/MatchEntrySerializerRegistryHelper.java | 12 ++++++------ 16 files changed, 60 insertions(+), 55 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index aa92ea08..8b1b0aec 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -23,8 +23,8 @@ public interface DeserializerRegistry { * @param key used for deserializer lookup * @return deserializer found */ - - SERIALIZERTYPE getDeserializer(MessageCodeKey key); + + T getDeserializer(MessageCodeKey key); /** * Registers deserializer. diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index d1966fb1..1e047c09 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -14,14 +14,14 @@ /** * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) * @author michal.polkorab - * @param + * @param */ -public interface HeaderSerializer extends OFGeneralSerializer { +public interface HeaderSerializer extends OFGeneralSerializer { /** * Serializes object headers (e.g. for Multipart message - Table Features) * @param input object whose headers should be serialized * @param outBuffer output buffer */ - void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); + void serializeHeader(T input, ByteBuf outBuffer); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java index ad463f45..6b2ef473 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java @@ -16,15 +16,15 @@ * Uniform interface for serializers * @author michal.polkorab * @author timotej.kubas - * @param message type + * @param message type */ -public interface OFSerializer extends OFGeneralSerializer { +public interface OFSerializer extends OFGeneralSerializer { /** * Transforms POJO/DTO into byte message (ByteBuf). * @param input object to be serialized * @param outBuffer output buffer */ - void serialize(SERIALIZER_TYPE input, ByteBuf outBuffer); + void serialize(T input, ByteBuf outBuffer); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index f4325cff..face97bc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -63,8 +63,8 @@ void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerMatchEntrySerializer( - MatchEntrySerializerKey key,OFGeneralSerializer serializer); + void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); /** * Registers experimenter (vendor) message serializer diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index eaa52c3d..75ba9f29 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -11,7 +11,9 @@ /** - * Stores and handles serializers + * Stores and handles serializers
+ * K - {@link MessageTypeKey} parameter type,
+ * S - returned serializer type * @author michal.polkorab * */ @@ -26,8 +28,7 @@ public interface SerializerRegistry { * @param msgTypeKey lookup key * @return serializer or NullPointerException if no serializer was found */ - SERIALIZERTYPE - getSerializer(MessageTypeKey msgTypeKey); + S getSerializer(MessageTypeKey msgTypeKey); /** * Registers serializer @@ -40,7 +41,7 @@ public interface SerializerRegistry { * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerSerializer(MessageTypeKey key, + void registerSerializer(MessageTypeKey key, OFGeneralSerializer serializer); /** @@ -50,5 +51,5 @@ void registerSerializer(MessageTypeKey key, * @return true if serializer was removed, * false if no serializer was found under specified key */ - boolean unregisterSerializer(MessageTypeKey key); + boolean unregisterSerializer(MessageTypeKey key); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index d1120467..52f0155b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -14,11 +14,11 @@ /** * @author michal.polkorab - * @param action type + * @param action type */ -public class ActionSerializerKey extends MessageTypeKey { +public class ActionSerializerKey extends MessageTypeKey { - private Class actionType; + private Class actionType; private Long experimenterId; /** @@ -26,7 +26,7 @@ public class ActionSerializerKey extends MessageTypeKey * @param actionType type of action * @param experimenterId experimenter / vendor ID */ - public ActionSerializerKey(short msgVersion, Class actionType, + public ActionSerializerKey(short msgVersion, Class actionType, Long experimenterId) { super(msgVersion, Action.class); this.actionType = actionType; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 73d0f153..4da4489e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -14,12 +14,12 @@ /** * @author michal.polkorab - * @param action type + * @param instruction type */ -public class InstructionSerializerKey +public class InstructionSerializerKey extends MessageTypeKey{ - private Class instructionType; + private Class instructionType; private Long experimenterId; /** @@ -28,7 +28,7 @@ public class InstructionSerializerKey * @param instructionType type of instruction * @param experimenterId experimenter / vendor ID */ - public InstructionSerializerKey(short msgVersion, Class instructionType, + public InstructionSerializerKey(short msgVersion, Class instructionType, Long experimenterId) { super(msgVersion, Instruction.class); this.instructionType = instructionType; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index fddc35c6..ec06f47a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -16,14 +16,14 @@ /** * @author michal.polkorab - * @param oxm_class (see specification) - * @param oxm_field (see specification) + * @param oxm_class (see specification) + * @param oxm_field (see specification) */ -public final class MatchEntrySerializerKey +public final class MatchEntrySerializerKey extends MessageTypeKey implements ExperimenterSerializerKey { - private Class oxmClass; - private Class oxmField; + private Class oxmClass; + private Class oxmField; private Long experimenterId; /** @@ -32,8 +32,8 @@ public final class MatchEntrySerializerKey oxmClass, - Class oxmField) { + public MatchEntrySerializerKey(short msgVersion, Class oxmClass, + Class oxmField) { super(msgVersion, MatchEntries.class); this.oxmClass = oxmClass; this.oxmField = oxmField; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java index 1718246c..d667a423 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -13,9 +13,9 @@ /** * @author michal.polkorab - * @param class of object to be serialized + * @param class of object to be serialized */ -public class ExperimenterIdSerializerKey extends MessageTypeKey +public class ExperimenterIdSerializerKey extends MessageTypeKey implements ExperimenterSerializerKey { private Long experimenterId; @@ -26,7 +26,7 @@ public class ExperimenterIdSerializerKey extends Messag * @param objectClass class of object to be serialized */ public ExperimenterIdSerializerKey(short msgVersion, - Long experimenterId, Class objectClass) { + Long experimenterId, Class objectClass) { super(msgVersion, objectClass); this.experimenterId = experimenterId; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java index 2c1d7899..f450c064 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; /** - * @param Channel type + * @param Channel type * @author michal.polkorab */ -public abstract class ProtocolChannelInitializer - extends ChannelInitializer { +public abstract class ProtocolChannelInitializer + extends ChannelInitializer { private SwitchConnectionHandler switchConnectionHandler; private long switchIdleTimeout; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index c016aee3..f750d4d1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -52,7 +52,9 @@ import com.google.common.util.concurrent.SettableFuture; /** - * Exposed class for server handling + * Exposed class for server handling
+ * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)
+ * F - {@link MatchEntrySerializerKey} parameter representing oxm_field (see specification) * @author mirehak * @author michal.polkorab */ @@ -193,7 +195,7 @@ public void registerInstructionDeserializer(ExperimenterInstructionDeserializerK } @Override - public void registerMatchEntrySerializer(MatchEntrySerializerKey key, + public void registerMatchEntrySerializer(MatchEntrySerializerKey key, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 5c7ad39c..9000e988 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -57,14 +57,14 @@ public void init() { @Override @SuppressWarnings("unchecked") - public DESERIALIZER_TYPE getDeserializer( + public T getDeserializer( MessageCodeKey key) { OFGeneralDeserializer deserializer = registry.get(key); if (deserializer == null) { throw new IllegalStateException("Deserializer for key: " + key + " was not found - please verify that all needed deserializers ale loaded correctly"); } - return (DESERIALIZER_TYPE) deserializer; + return (T) deserializer; } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 06019394..4d91deca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -24,7 +24,9 @@ import org.slf4j.LoggerFactory; /** - * Stores and handles serializers + * Stores and handles serializers
+ * K - {@link MessageTypeKey} type
+ * S - returned serializer type * @author michal.polkorab * @author timotej.kubas */ @@ -60,20 +62,20 @@ public void init() { */ @Override @SuppressWarnings("unchecked") - public SERIALIZER_TYPE getSerializer( - MessageTypeKey msgTypeKey) { + public S getSerializer( + MessageTypeKey msgTypeKey) { OFGeneralSerializer serializer = registry.get(msgTypeKey); if (serializer == null) { throw new IllegalStateException("Serializer for key: " + msgTypeKey + " was not found - please verify that you are using correct message" + " combination (e.g. OF v1.0 message to OF v1.0 device)"); } - return (SERIALIZER_TYPE) serializer; + return (S) serializer; } @Override - public void registerSerializer( - MessageTypeKey msgTypeKey, OFGeneralSerializer serializer) { + public void registerSerializer( + MessageTypeKey msgTypeKey, OFGeneralSerializer serializer) { if ((msgTypeKey == null) || (serializer == null)) { throw new IllegalArgumentException("MessageTypeKey or Serializer is null"); } @@ -89,7 +91,7 @@ public void registerSerializer( } @Override - public boolean unregisterSerializer(MessageTypeKey msgTypeKey) { + public boolean unregisterSerializer(MessageTypeKey msgTypeKey) { if (msgTypeKey == null) { throw new IllegalArgumentException("MessageTypeKey is null"); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index 912ec8b7..ffe274b3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -35,7 +35,7 @@ public ActionSerializerRegistryHelper(short version, SerializerRegistry serializ * @param actionType * @param serializer */ - public void registerSerializer(Class actionType, + public void registerSerializer(Class actionType, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, actionType, null), serializer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index 62e019ad..d85fbbdd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -34,7 +34,7 @@ public InstructionSerializerRegistryHelper(short version, SerializerRegistry ser * @param instructionType * @param serializer */ - public void registerSerializer(Class instructionType, + public void registerSerializer(Class instructionType, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, instructionType, null), serializer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index e722a93e..76f1f2ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -15,12 +15,12 @@ /** * @author michal.polkorab - * @param OXM class + * @param OXM class */ -public class MatchEntrySerializerRegistryHelper { +public class MatchEntrySerializerRegistryHelper { private short version; - private Class generalClass; + private Class generalClass; private SerializerRegistry serializerRegistry; /** @@ -28,7 +28,7 @@ public class MatchEntrySerializerRegistryHelper * @param generalClass * @param serializerRegistry */ - public MatchEntrySerializerRegistryHelper(short version, Class generalClass, + public MatchEntrySerializerRegistryHelper(short version, Class generalClass, SerializerRegistry serializerRegistry) { this.version = version; this.generalClass = generalClass; @@ -40,8 +40,8 @@ public MatchEntrySerializerRegistryHelper(short version, Class genera * @param specificClass * @param serializer */ - public void registerSerializer( - Class specificClass, OFGeneralSerializer serializer) { + public void registerSerializer( + Class specificClass, OFGeneralSerializer serializer) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); key.setExperimenterId(null); serializerRegistry.registerSerializer(key, serializer); From d04d1cdccb94bec23968c7c3a893843ebd928b7b Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Mon, 26 Jan 2015 15:18:17 +0100 Subject: [PATCH 121/285] Bug 2245 - Synchronized classes and data structures replaced by unsynchronized. Change-Id: Ie5aeeb28c74757d1a8bac21ce611a403a0fb6f57 Signed-off-by: Martin Uhlir --- .../it/integration/IntegrationTest.java | 37 ++++++++++--------- .../impl/clients/ScenarioFactory.java | 29 ++++++++------- .../impl/clients/ScenarioHandler.java | 14 +++---- .../openflowjava/util/ByteBufUtils.java | 4 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 411bc5ea..6464a62f 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -10,8 +10,9 @@ import java.net.InetAddress; import java.util.ArrayList; +import java.util.Deque; import java.util.List; -import java.util.Stack; + import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -107,7 +108,7 @@ public void tearDown() throws Exception { public void testHandshake() throws Exception { setUp(TransportProtocol.TCP); int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); + Deque scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); OFClient firstClient = clients.get(0); @@ -125,7 +126,7 @@ public void testHandshake() throws Exception { public void testTlsHandshake() throws Exception { setUp(TransportProtocol.TLS); int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); + Deque scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); OFClient firstClient = clients.get(0); @@ -143,11 +144,11 @@ public void testTlsHandshake() throws Exception { public void testHandshakeAndEcho() throws Exception { setUp(TransportProtocol.TCP); int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + Deque scenario = ScenarioFactory.createHandshakeScenario(); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); OFClient firstClient = clients.get(0); @@ -164,11 +165,11 @@ public void testHandshakeAndEcho() throws Exception { public void testTlsHandshakeAndEcho() throws Exception { setUp(TransportProtocol.TLS); int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + Deque scenario = ScenarioFactory.createHandshakeScenario(); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); OFClient firstClient = clients.get(0); @@ -185,11 +186,11 @@ public void testTlsHandshakeAndEcho() throws Exception { public void testUdpHandshakeAndEcho() throws Exception { setUp(TransportProtocol.UDP); int amountOfCLients = 1; - Stack scenario = ScenarioFactory.createHandshakeScenario(); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); - scenario.add(0, new SleepEvent(1000)); - scenario.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); + Deque scenario = ScenarioFactory.createHandshakeScenario(); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); + scenario.addFirst(new SleepEvent(1000)); + scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP); OFClient firstClient = clients.get(0); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index a6afb6a5..f0e5b9cf 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -8,7 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.clients; -import java.util.Stack; +import java.util.ArrayDeque; +import java.util.Deque; import org.opendaylight.openflowjava.util.ByteBufUtils; @@ -33,12 +34,12 @@ private ScenarioFactory() { * * @return stack filled with Handshake messages */ - public static Stack createHandshakeScenario() { - Stack stack = new Stack<>(); - stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01"))); - stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02"))); - stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03"))); - stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 " + public static Deque createHandshakeScenario() { + Deque stack = new ArrayDeque<>(); + stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01"))); + stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02"))); + stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03"))); + stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 " + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03"))); return stack; } @@ -54,14 +55,14 @@ public static Stack createHandshakeScenario() { * @param auxiliaryId auxiliaryId wanted in featuresReply message * @return stack filled with Handshake messages (featuresReply with auxiliaryId set) */ - public static Stack createHandshakeScenarioWithAuxiliaryId(byte auxiliaryId) { - Stack stack = new Stack<>(); - stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01"))); - stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02"))); - stack.add(0, new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03"))); - stack.add(0, new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 " + public static Deque createHandshakeScenarioWithAuxiliaryId(byte auxiliaryId) { + Deque queue = new ArrayDeque<>(); + queue.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01"))); + queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02"))); + queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03"))); + queue.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 " + "00 01 02 03 04 05 06 07 00 01 02 03 01 " + String.format("%02x ", auxiliaryId) + " 00 00 00 01 02 03 00 01 02 03"))); - return stack; + return queue; } } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 075c6568..b7cf3de0 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -10,7 +10,7 @@ import io.netty.channel.ChannelHandlerContext; -import java.util.Stack; +import java.util.Deque; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; @@ -26,7 +26,7 @@ public class ScenarioHandler extends Thread { private static final Logger LOGGER = LoggerFactory.getLogger(ScenarioHandler.class); - private Stack scenario; + private Deque scenario; private BlockingQueue ofMsg; private ChannelHandlerContext ctx; private int eventNumber; @@ -36,7 +36,7 @@ public class ScenarioHandler extends Thread { * * @param scenario */ - public ScenarioHandler(Stack scenario) { + public ScenarioHandler(Deque scenario) { this.scenario = scenario; ofMsg = new LinkedBlockingQueue<>(); } @@ -46,7 +46,7 @@ public void run() { int freezeCounter = 0; while (!scenario.isEmpty()) { LOGGER.debug("Running event #" + eventNumber); - ClientEvent peek = scenario.peek(); + ClientEvent peek = scenario.peekLast(); if (peek instanceof WaitForMessageEvent) { LOGGER.debug("WaitForMessageEvent"); try { @@ -62,7 +62,7 @@ public void run() { event.setCtx(ctx); } if (peek.eventExecuted()) { - scenario.pop(); + scenario.removeLast(); eventNumber++; freezeCounter = 0; } else { @@ -95,14 +95,14 @@ public boolean isEmpty() { /** * @return scenario */ - public Stack getScenario() { + public Deque getScenario() { return scenario; } /** * @param scenario scenario filled with desired events */ - public void setScenario(Stack scenario) { + public void setScenario(Deque scenario) { this.scenario = scenario; } diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 4ac43f65..c4446f28 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -45,7 +45,7 @@ private ByteBufUtils() { * @return String */ public static String byteBufToHexString(final ByteBuf bb) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = bb.readerIndex(); i < (bb.readerIndex() + bb.readableBytes()); i++) { sb.append(String.format(" %02x", bb.getUnsignedByte(i))); } @@ -204,7 +204,7 @@ public static int[] fillBitMaskFromList(final List booleanList) { * @return String */ public static String bytesToHexString(final byte[] array) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (byte element : array) { sb.append(String.format(" %02x", element)); } From e149a02d7ccbdc4ea67863bbfc92fc141e89d2dd Mon Sep 17 00:00:00 2001 From: Marian Adamjak Date: Wed, 29 Oct 2014 16:18:05 +0100 Subject: [PATCH 122/285] Bug 2245 Fixed Avoid cycle between java packages - move all classes from protocol.api.experimenter into api.keys - move Message*key.java from protocol.api.extensibility into api.keys Change-Id: I509c57ecdd41ddfa48b224c87d762571639b0b8a Signed-off-by: Marian Adamjak Signed-off-by: Michal Polkorab --- .../DeserializerExtensionProvider.java | 8 +- .../extensibility/DeserializerRegistry.java | 2 + .../extensibility/EnhancedMessageCodeKey.java | 2 + .../extensibility/EnhancedMessageTypeKey.java | 2 + .../SerializerExtensionProvider.java | 8 +- .../api/extensibility/SerializerRegistry.java | 2 + .../api/keys/ActionDeserializerKey.java | 1 - .../api/keys/ActionSerializerKey.java | 1 - .../ExperimenterActionDeserializerKey.java | 3 +- .../ExperimenterActionSerializerKey.java | 3 +- .../ExperimenterDeserializerKey.java | 2 +- .../ExperimenterIdDeserializerKey.java | 3 +- .../ExperimenterIdSerializerKey.java | 3 +- ...xperimenterInstructionDeserializerKey.java | 3 +- .../ExperimenterInstructionSerializerKey.java | 3 +- .../ExperimenterSerializerKey.java | 2 +- .../api/keys/InstructionDeserializerKey.java | 1 - .../api/keys/InstructionSerializerKey.java | 1 - .../api/keys/MatchEntryDeserializerKey.java | 2 - .../api/keys/MatchEntrySerializerKey.java | 2 - .../MessageCodeKey.java | 2 +- .../MessageTypeKey.java | 4 +- .../api/extensibility/MessageCodeKeyTest.java | 1 + .../api/extensibility/MessageTypeKeyTest.java | 1 + .../protocol/api/keys/KeysTest.java | 4 - ...ExperimenterActionDeserializerKeyTest.java | 1 + .../ExperimenterActionSerializerKeyTest.java | 1 + .../ExperimenterIdDeserializerKeyTest.java | 3 +- .../ExperimenterIdSerializerKeyTest.java | 3 +- ...imenterInstructionDeserializerKeyTest.java | 1 + ...erimenterInstructionSerializerKeyTest.java | 1 + .../core/SwitchConnectionProviderImpl.java | 20 +- .../DeserializationFactory.java | 2 +- .../DeserializerRegistryImpl.java | 2 +- .../factories/FlowRemovedMessageFactory.java | 2 +- .../MultipartReplyMessageFactory.java | 2 +- .../OF10FlowRemovedMessageFactory.java | 2 +- .../OF10StatsReplyMessageFactory.java | 2 +- .../factories/PacketInMessageFactory.java | 2 +- .../serialization/SerializationFactory.java | 2 +- .../serialization/SerializerRegistryImpl.java | 2 +- .../factories/FlowModInputMessageFactory.java | 2 +- .../MultipartRequestInputFactory.java | 2 +- .../OF10FlowModInputMessageFactory.java | 2 +- .../OF10StatsRequestInputFactory.java | 2 +- .../protocol/impl/util/CodeKeyMaker.java | 2 +- .../impl/util/CodeKeyMakerFactory.java | 6 +- .../util/CommonMessageRegistryHelper.java | 2 +- .../SimpleDeserializerRegistryHelper.java | 2 +- .../protocol/impl/util/TypeKeyMaker.java | 2 +- .../impl/util/TypeKeyMakerFactory.java | 6 +- .../openflowjava/statistics/Counter.java | 2 +- .../ConnectionAdapterImpl02Test.java | 214 ++++++++++++++++++ .../SwitchConnectionProviderImpl02Test.java | 12 +- .../DeserializerRegistryImplTest.java | 2 +- .../BarrierReplyMessageFactoryTest.java | 2 +- .../EchoReplyMessageFactoryTest.java | 2 +- .../EchoRequestMessageFactoryTest.java | 2 +- .../factories/ErrorMessageFactoryTest.java | 2 +- .../ExperimenterMessageFactoryTest.java | 2 +- .../FeaturesReplyMessageFactoryTest.java | 2 +- .../FlowRemovedMessageFactoryTest.java | 2 +- .../GetAsyncReplyMessageFactoryTest.java | 2 +- .../GetConfigReplyMessageFactoryTest.java | 2 +- .../factories/HelloMessageFactoryTest.java | 2 +- .../MultipartReplyMessageFactoryTest.java | 2 +- .../OF10BarrierReplyMessageFactoryTest.java | 2 +- .../OF10EchoReplyMessageFactoryTest.java | 2 +- .../OF10EchoRequestMessageFactoryTest.java | 2 +- .../OF10ErrorMessageFactoryTest.java | 2 +- .../OF10FeaturesReplyMessageFactoryTest.java | 2 +- .../OF10FlowRemovedMessageFactoryTest.java | 2 +- .../OF10GetConfigReplyMessageFactoryTest.java | 2 +- .../OF10HelloMessageFactoryTest.java | 2 +- .../OF10PacketInMessageFactoryTest.java | 2 +- .../OF10PortStatusMessageFactoryTest.java | 2 +- ...QueueGetConfigReplyMessageFactoryTest.java | 2 +- .../OF10StatsReplyMessageFactoryTest.java | 2 +- .../factories/PacketInMessageFactoryTest.java | 2 +- .../PortStatusMessageFactoryTest.java | 2 +- ...GetConfigReplyMessageFactoryMultiTest.java | 2 +- ...QueueGetConfigReplyMessageFactoryTest.java | 2 +- .../RoleReplyMessageFactoryTest.java | 2 +- .../factories/VendorMessageFactoryTest.java | 2 +- .../MultipartReplyExperimenterTest.java | 2 +- .../multipart/MultipartReplyFlowTest.java | 2 +- .../OF10StatsReplyExperimenterTest.java | 2 +- .../SerializerRegistryImplTest.java | 2 +- .../BarrierInputMessageFactoryTest.java | 2 +- .../EchoInputMessageFactoryTest.java | 2 +- .../EchoReplyInputMessageFactoryTest.java | 4 +- .../ExperimenterInputMessageFactoryTest.java | 2 +- .../FlowModInputMessageFactoryTest.java | 2 +- .../GetConfigInputMessageFactoryTest.java | 2 +- .../GetFeaturesInputMessageFactoryTest.java | 2 +- ...GetQueueConfigInputMessageFactoryTest.java | 2 +- .../GetaAsyncRequestMessageFactoryTest.java | 2 +- .../GroupModInputMessageFactoryTest.java | 2 +- .../HelloInputMessageFactoryTest.java | 2 +- .../MeterModInputMessageFactoryTest.java | 2 +- .../MultipartRequestInputFactoryTest.java | 2 +- .../OF10BarrierInputMessageFactoryTest.java | 2 +- .../OF10FlowModInputMessageFactoryTest.java | 2 +- .../OF10HelloInputMessageFactoryTest.java | 2 +- .../OF10PacketOutInputMessageFactoryTest.java | 2 +- .../OF10PortModInputMessageFactoryTest.java | 2 +- ...QueueGetConfigInputMessageFactoryTest.java | 2 +- .../OF10StatsRequestInputFactoryTest.java | 2 +- .../PacketOutInputMessageFactoryTest.java | 2 +- .../PortModInputMessageFactoryTest.java | 2 +- .../RoleRequestInputMessageFactoryTest.java | 2 +- .../SetAsyncInputMessageFactoryTest.java | 2 +- .../SetConfigMessageFactoryTest.java | 2 +- .../TableModInputMessageFactoryTest.java | 2 +- .../VendorInputMessageFactoryTest.java | 2 +- .../MultipartRequestExperimenterTest.java | 2 +- .../MultipartRequestGroupDescTest.java | 2 +- .../MultipartRequestGroupFeaturesTest.java | 2 +- .../MultipartRequestMeterFeaturesTest.java | 2 +- .../MultipartRequestPortDescTest.java | 2 +- .../MultipartRequestTableFeaturesTest.java | 2 +- .../multipart/MultipartRequestTableTest.java | 2 +- .../OF10StatsRequestAggregateTest.java | 2 +- .../OF10StatsRequestExperimenterTest.java | 2 +- .../impl/util/CodeKeyMakerFactoryTest.java | 2 +- .../impl/util/MatchDeserializerTest.java | 2 +- .../impl/util/OF10MatchDeserializerTest.java | 2 +- .../impl/util/OF10MatchSerializerTest.java | 2 +- .../impl/util/OF13MatchSerializer02Test.java | 2 +- .../impl/util/OF13MatchSerializerTest.java | 2 +- .../impl/util/TypeKeyMakerFactoryTest.java | 6 +- .../ExperimenterDeserializerKeyFactory.java | 2 +- .../ExperimenterSerializerKeyFactory.java | 2 +- ...xperimenterDeserializerKeyFactoryTest.java | 2 +- .../ExperimenterSerializerKeyFactoryTest.java | 2 +- 135 files changed, 377 insertions(+), 161 deletions(-) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterActionDeserializerKey.java (85%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterActionSerializerKey.java (93%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterDeserializerKey.java (88%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterIdDeserializerKey.java (93%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterIdSerializerKey.java (93%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterInstructionDeserializerKey.java (84%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterInstructionSerializerKey.java (85%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/{experimenter => }/ExperimenterSerializerKey.java (88%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => keys}/MessageCodeKey.java (96%) rename openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/{extensibility => keys}/MessageTypeKey.java (92%) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 516113b8..abd85ba5 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -8,11 +8,11 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 8b1b0aec..04291b8f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; + /** * @author michal.polkorab diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java index 4ecec614..b8a7ec0d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; + /** * @author michal.polkorab * diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index 1f987218..ec578c6b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; + /** * More specific key for {@link SerializerRegistry} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index face97bc..fc4b089f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -8,11 +8,11 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 75ba9f29..716281c4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.api.extensibility; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; + diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index a80bd7ae..17e2358b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 52f0155b..affd4207 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionDeserializerKey.java similarity index 85% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionDeserializerKey.java index cbb23632..40f21d76 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionDeserializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java similarity index 93% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java index eef5f106..32a1afd3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterDeserializerKey.java similarity index 88% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterDeserializerKey.java index 770a9162..3169de76 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterDeserializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; /** * Marker interface - marks keys appropriate for experimenter deserializer registration diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java similarity index 93% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java index cafde379..bc16e523 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java similarity index 93% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java index d667a423..89525282 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java similarity index 84% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java index 5abe45ee..45232a66 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java similarity index 85% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java index 7d46b590..fb2365bf 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java @@ -6,9 +6,8 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterSerializerKey.java similarity index 88% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterSerializerKey.java index 8ce152bc..d027155a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterSerializerKey.java @@ -6,7 +6,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.keys.experimenter; +package org.opendaylight.openflowjava.protocol.api.keys; /** * Marker interface - marks keys appropriate for experimenter serializer registration diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index cb08cd92..3a0bf982 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 4da4489e..2b7df97c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index ebd16ad7..d6938402 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -8,8 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index ec06f47a..d3cf7c1e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -8,8 +8,6 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java similarity index 96% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java index ea487ea6..6597c19a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility; +package org.opendaylight.openflowjava.protocol.api.keys; /** * @author michal.polkorab diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java similarity index 92% rename from openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java index bf45cd10..507a466f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java @@ -6,7 +6,9 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.api.extensibility; +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; /** diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java index 2c0425f4..2c5b69c6 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 18a4a1e7..4788ddf3 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index 927ec5d5..769bfc92 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -8,10 +8,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java index 2357c71a..97543fea 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index f287d3a3..6c469573 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index 6938223a..fba55191 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -10,7 +10,8 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index e931d6a7..aa5d1275 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -10,7 +10,8 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java index fa924f91..74f1bf96 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java index db78e28c..e7f8e35a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java @@ -10,6 +10,7 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index f750d4d1..9e8a7a18 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -12,23 +12,23 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index 9cc40227..09f4fd1d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -14,8 +14,8 @@ import java.util.Map; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 9000e988..0cd70fd8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -13,8 +13,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java index 97a4390f..3e736fab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java @@ -14,8 +14,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 7d7f7524..cbebe33e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java index 18573f1b..72365a7e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java @@ -14,8 +14,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index ccea543f..5bb680bc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -16,8 +16,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java index 808a1da9..7b1944a4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java @@ -14,8 +14,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java index 90cb34d7..e7456afe 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactory.java @@ -10,9 +10,9 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.yangtools.yang.binding.DataObject; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 4d91deca..e1f2d447 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -11,10 +11,10 @@ import java.util.HashMap; import java.util.Map; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 0e1b3533..7c5cd03a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 29dd683c..29e5fd2c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -12,10 +12,10 @@ import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index 7ba6e7eb..6ed067fe 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index aa8fcbd2..2684f042 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java index f5be1f6c..865db780 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import io.netty.buffer.ByteBuf; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 8a03f534..ba692c8f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -10,12 +10,12 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java index 35cfef79..b19b47e4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 7c9ec2b5..38d05d2c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index ad1b2f42..3ace85ab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index d9fd1340..37ba6dd9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -8,12 +8,12 @@ package org.opendaylight.openflowjava.protocol.impl.util; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index 077bfe64..33bd50aa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -81,4 +81,4 @@ public String getStat() { long cntCurValue = getCounterValue(); return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java new file mode 100644 index 00000000..a4a11393 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author madamjak + * @author michal.polkorab + */ +public class ConnectionAdapterImpl02Test { + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock EchoInput echoInput; + @Mock BarrierInput barrierInput; + @Mock EchoReplyInput echoReplyInput; + @Mock ExperimenterInput experimenterInput; + @Mock FlowModInput flowModInput; + @Mock GetConfigInput getConfigInput; + @Mock GetFeaturesInput getFeaturesInput; + @Mock GetQueueConfigInput getQueueConfigInput; + @Mock GroupModInput groupModInput; + @Mock HelloInput helloInput; + @Mock MeterModInput meterModInput; + @Mock PacketOutInput packetOutInput; + @Mock MultipartRequestInput multipartRequestInput; + @Mock PortModInput portModInput; + @Mock RoleRequestInput roleRequestInput; + @Mock SetConfigInput setConfigInput; + @Mock TableModInput tableModInput; + @Mock GetAsyncInput getAsyncInput; + @Mock SetAsyncInput setAsyncInput; + private ConnectionAdapterImpl adapter; + private Cache> cache; + private OfHeader responseOfCall; + /** + * Initialize mocks + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + /** + * Disconnect adapter + */ + @After + public void tierDown(){ + if (adapter != null && adapter.isAlive()) { + adapter.disconnect(); + } + } + /** + * Test Rpc Calls + */ + @Test + public void testRcp() { + EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + adapter.setResponseCache(cache); + // -- barrier + adapter.barrier(barrierInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - barrier", barrierInput, responseOfCall); + // -- echo + adapter.echo(echoInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - echo", echoInput, responseOfCall); + // -- echoReply + adapter.echoReply(echoReplyInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - echoReply",echoReplyInput, responseOfCall); + // -- experimenter + adapter.experimenter(experimenterInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - experimenter",experimenterInput, responseOfCall); + // -- flowMod + adapter.flowMod(flowModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - flowMod", flowModInput, responseOfCall); + // -- getConfig + adapter.getConfig(getConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getConfig", getConfigInput, responseOfCall); + // -- getFeatures + adapter.getFeatures(getFeaturesInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getFeatures",getFeaturesInput, responseOfCall); + // -- getQueueConfig + adapter.getQueueConfig(getQueueConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getQueueConfig",getQueueConfigInput, responseOfCall); + // -- groupMod + adapter.groupMod(groupModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - groupMod", groupModInput, responseOfCall); + // -- hello + adapter.hello(helloInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - helloInput",helloInput, responseOfCall); + // -- meterMod + adapter.meterMod(meterModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - meterMod",meterModInput, responseOfCall); + // -- packetOut + adapter.packetOut(packetOutInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - packetOut",packetOutInput, responseOfCall); + // -- multipartRequest + adapter.multipartRequest(multipartRequestInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - multipartRequest", multipartRequestInput, responseOfCall); + // -- portMod + adapter.portMod(portModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - portMod", portModInput, responseOfCall); + // -- roleRequest + adapter.roleRequest(roleRequestInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - roleRequest", roleRequestInput, responseOfCall); + // -- setConfig + adapter.setConfig(setConfigInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - setConfig",setConfigInput, responseOfCall); + // -- tableMod + adapter.tableMod(tableModInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - tableMod", tableModInput, responseOfCall); + // -- getAsync + adapter.getAsync(getAsyncInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - getAsync", getAsyncInput, responseOfCall); + // -- setAsync + adapter.setAsync(setAsyncInput); + embChannel.runPendingTasks(); + Assert.assertEquals("Wrong - setAsync", setAsyncInput, responseOfCall); + adapter.disconnect(); + } + + /** + * Channel Handler for testing + * @author madamjak + * + */ + private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { + @Override + public void write(ChannelHandlerContext ctx, Object msg, + ChannelPromise promise) throws Exception { + responseOfCall = null; + if(msg instanceof MessageListenerWrapper){ + MessageListenerWrapper listener = (MessageListenerWrapper) msg; + OfHeader ofHeader = listener.getMsg(); + responseOfCall = ofHeader; + } + } + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 2a82ddf0..bc1a2718 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -21,14 +21,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.core.ServerFacade; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java index 49e41fc8..de4dad5d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java @@ -9,7 +9,7 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java index 863ac336..a938d5cb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java @@ -13,8 +13,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java index 801d47a6..438ac186 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java index 8aff8b75..376d4dfd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java index 55a90b81..0d7dc5c4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java index 3b71c37e..d25137ca 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java index ad4ccc59..1c6fc703 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FeaturesReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java index cc0f35d8..5f9d65a3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java index c9dabd87..4cb07da2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java index 16826620..0d48e66d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index 47bd8ddf..7dab76e2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index ded6a326..351a8726 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -16,8 +16,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java index 368f8f03..ca1db522 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java @@ -13,8 +13,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java index 336710d5..3da76971 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java index 7684e850..12113a37 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java index bf058b7b..ea7d61fd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index f5ec8f23..e759185e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java index 891c9e05..c98b14f5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactoryTest.java @@ -13,8 +13,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java index fc63e70c..fe75abc4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java index 2438f17c..1c430390 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10HelloMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java index 57d73cb7..53ed80fc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactoryTest.java @@ -13,8 +13,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java index 0d637522..76b94b2c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java index e204b3ca..322e5d98 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index a4740621..4a75d0ab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -15,8 +15,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java index b30df2f8..105329db 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index 79ee3fd9..67f9b266 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -15,8 +15,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java index 1125ca2d..9670461f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java index cc2f4eab..7cf4df2c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java index 2f7a81d8..318f85ac 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleReplyMessageFactoryTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java index 0c9707ca..050eee0e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java @@ -18,7 +18,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.util.ByteBufUtils; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java index 28fecce1..1e989ed3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -18,7 +18,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index d1c5e35f..a8652756 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -16,8 +16,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java index 0df462fe..8986f5c8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java @@ -18,7 +18,7 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java index df7e83bf..046762fe 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java @@ -9,7 +9,7 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java index 1e5f475c..c0263c30 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java index cf00e1c2..0d6db4e0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoInputMessageFactoryTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java index be4130a0..98bd9a63 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoReplyInputMessageFactoryTest.java @@ -9,13 +9,15 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import org.junit.Assert; + import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; + import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java index 47235595..89e0f958 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index bfa59857..a0c39227 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -18,9 +18,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java index a050b299..35f5eef9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java index 1f4a400f..fdf097c2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java index 0d94cf6b..780e148e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java index a660f37c..0bdc8675 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetaAsyncRequestMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java index c158b706..37396655 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index e2ea0f86..c3835324 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java index 4884643b..115c0755 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java index 1c34f365..f87a18a0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactoryTest.java @@ -16,9 +16,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java index ae752b6a..cc31a00e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index e4b3af1b..0ec4d2f4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -18,9 +18,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java index e8591d4a..b7ed855b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10HelloInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 791d5681..3ce00862 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index 39276ba3..1b98d77d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java index 91a08cbb..81234dde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index f7171223..464f1c36 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 5da3a53d..f202caad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index fd4f4ca8..12e756a5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java index 5f21f65b..ac09080b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleRequestInputMessageFactoryTest.java @@ -16,9 +16,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java index d31a117a..1f2ff731 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetAsyncInputMessageFactoryTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java index c188b593..700d1641 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java index 6423a326..27ae6457 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/TableModInputMessageFactoryTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java index c14e4dc3..15496598 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java @@ -17,8 +17,8 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java index 4b476037..2f78055b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -20,7 +20,7 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java index f5c8cad6..08b46cd1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java index 630deca7..d619b0f3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java index 9106a580..6c7030e4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java index be5b244a..5adda0a8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index 6ece7679..e8f7f97d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -22,9 +22,9 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java index 11383b9f..8fe08967 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 711c0d45..412adb56 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -14,9 +14,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java index 00a76683..955c1221 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -20,7 +20,7 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java index fcae5712..024dae0d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java @@ -12,10 +12,10 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index e325baff..b139257f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -16,9 +16,9 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 0201f609..35f70325 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -14,8 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index e19ede8c..b1b6d103 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -13,9 +13,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index a29b8437..de60195a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -16,9 +16,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 6b82e9e6..deb3df01 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -17,9 +17,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index ba445321..f4a37a52 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -10,12 +10,12 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 1a7a5d26..c089783b 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.util; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 4ea333b6..36033d07 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.util; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java index d597cfd5..1b422d31 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java @@ -10,7 +10,7 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java index 397f7d69..91435929 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -10,7 +10,7 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; From fc722c75c276ae69b0bf1a8fb9329864e0ba5325 Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Wed, 28 Jan 2015 09:58:55 +0100 Subject: [PATCH 123/285] Bug 2245 - fixed multiple types of issues Issues solved: 1. Objects should be compared with "equals()" 2. Declarations should use Java collection interfaces such as "List" rather than specific implementation classes such as "LinkedList" 3. Modifiers should be declared in correct order 4. Avoid commented-out lines of code 5. Unused private fields should be removed Change-Id: I4ca2224a9fd272dd2deb25f6f36db2ed7bd8bb99 Signed-off-by: Martin Uhlir --- .../openflowjava/protocol/impl/core/UdpChannelInitializer.java | 1 - .../protocol/impl/core/connection/ChannelOutboundQueue.java | 2 +- .../protocol/impl/core/connection/ConnectionAdapterImpl.java | 2 -- .../protocol/impl/core/connection/RpcResponseKey.java | 2 -- .../openflowjava/statistics/StatisticsCounters.java | 2 +- .../java/org/opendaylight/openflowjava/util/ByteBufUtils.java | 2 +- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java index 9ff7d65b..ba1650e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java @@ -27,6 +27,5 @@ protected void initChannel(NioDatagramChannel ch) throws Exception { OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); -// connectionFacade.fireConnectionReadyNotification(); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index 65b9c6a6..73812930 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -236,7 +236,7 @@ private synchronized void flush() { } private void conditionalFlush(final ChannelHandlerContext ctx) { - Preconditions.checkState(ctx.channel() == channel, "Inconsistent channel %s with context %s", channel, ctx); + Preconditions.checkState(ctx.channel().equals(channel), "Inconsistent channel %s with context %s", channel, ctx); conditionalFlush(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 7f1c0971..c2854bec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -95,8 +95,6 @@ public class ConnectionAdapterImpl implements ConnectionFacade { private static final Exception QUEUE_FULL_EXCEPTION = new RejectedExecutionException("Output queue is full"); - private static final String APPLICATION_TAG = "OPENFLOW_LIBRARY"; - private static final String TAG = "OPENFLOW"; private static final RemovalListener> REMOVAL_LISTENER = new RemovalListener>() { @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java index 2463f3f2..9cd482b1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java @@ -68,8 +68,6 @@ public boolean equals(Object obj) { } } else if (!outputClazz.equals(other.outputClazz)) { return false; -// if (xid != other.xid) -// return false; } return true; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 1f4d7ca3..89eeff92 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -55,7 +55,7 @@ public final class StatisticsCounters implements StatisticsHandler { * Get instance of statistics counters, first created object does not start counting and log reporting * @return an instance */ - public synchronized static StatisticsCounters getInstance() { + public static synchronized StatisticsCounters getInstance() { if (instanceHolder == null) { instanceHolder = new StatisticsCounters(); } diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index c4446f28..269d1735 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -74,7 +74,7 @@ public static byte[] hexStringToBytes(final String hexSrc, final boolean withSpa } Iterable tmp = Splitter.onPattern(splitPattern) .omitEmptyStrings().split(hexSrc); - ArrayList byteChips = Lists.newArrayList(tmp); + List byteChips = Lists.newArrayList(tmp); byte[] result = new byte[byteChips.size()]; int i = 0; for (String chip : byteChips) { From d80c9e0b0b010a93ab42c1a70eee46a5c0796dcb Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Fri, 30 Jan 2015 13:33:29 +0100 Subject: [PATCH 124/285] NXM (de)serializers deleted Change-Id: I51e279fea8cc8cc619fd2b46a2dfe135be1d24b8 Signed-off-by: Martin Uhlir --- .../MatchEntryDeserializerInitializer.java | 12 ----- .../match/NxmTcpFlagDeserializer.java | 53 ------------------- .../match/NxmTunnelIpv4DstDeserializer.java | 30 ----------- .../match/NxmTunnelIpv4SrcDeserializer.java | 30 ----------- .../MatchEntriesInitializer.java | 12 ----- .../match/NxmTcpFlagSerializer.java | 46 ---------------- .../match/NxmTunnelIpv4DstSerializer.java | 34 ------------ .../match/NxmTunnelIpv4SrcSerializer.java | 34 ------------ 8 files changed, 251 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index 46273e89..21d9dcb1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -8,9 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; @@ -114,14 +111,5 @@ public static void registerMatchEntryDeserializers(DeserializerRegistry registry helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); - - // Register NXM1Class match entry deserializers - MatchEntryDeserializerRegistryHelper nxm1helper = - new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, - OxmMatchConstants.NXM_1_CLASS, registry); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer()); - } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java deleted file mode 100644 index 7a287238..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagDeserializer.class); - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addTcpFlagAugmentation(input, builder); - return builder.build(); - } - - private static void addTcpFlagAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - TcpFlagMatchEntryBuilder tcpFlagMatchEntryBuilder = new TcpFlagMatchEntryBuilder(); - tcpFlagMatchEntryBuilder.setTcpFlag(input.readUnsignedShort()); - } - - @Override - protected Class getOxmField() { - return TcpFlag.class; - } - - @Override - protected Class getOxmClass() { - return Nxm1Class.class; - } -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java deleted file mode 100644 index bca1b885..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst; - -/** - * @author brent.salisbury - * - */ -public class NxmTunnelIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return TunnelIpv4Dst.class; - } - - @Override - protected Class getOxmClass() { - return Nxm1Class.class; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java deleted file mode 100644 index b081df9f..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; - -/** - * @author brent.salisbury - * - */ -public class NxmTunnelIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return TunnelIpv4Src.class; - } - - @Override - protected Class getOxmClass() { - return Nxm1Class.class; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 884617fa..027b8006 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -9,9 +9,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; @@ -159,14 +156,5 @@ public static void registerMatchEntrySerializers(SerializerRegistry serializerRe helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); - - // Register OpenFlow NXM1Class match entry serializer - Class nxm1Class = Nxm1Class.class; - MatchEntrySerializerRegistryHelper nxm1RegistryHelper = - new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - nxm1Class, serializerRegistry); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); - nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java deleted file mode 100644 index 7d963b8b..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagSerializer extends AbstractOxmMatchEntrySerializer { - - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagSerializer.class); - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(TcpFlagMatchEntry.class).getTcpFlag()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.NXM_NX_TCP_FLAG; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java deleted file mode 100644 index 05b98809..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author brent.salisbury - * - */ -public class NxmTunnelIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.NXM_NX_TUN_IPV4_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java deleted file mode 100644 index 19bd4a60..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author brent.salisbury - * - */ -public class NxmTunnelIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.NXM_NX_TUN_IPV4_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } - -} From ab82f91dc09fdcf15d7ee56416d45ca45db48f11 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 9 Feb 2015 09:55:44 +0100 Subject: [PATCH 125/285] Do not override versions from odlparent All of these properties/plugins are define din odlparent, no need to hard-code them here. Change-Id: I33e5d01ba9fe0ca31e7a9c2c7e041efaac82b0c0 Signed-off-by: Robert Varga --- pom.xml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/pom.xml b/pom.xml index 9b33ad39..2717d316 100644 --- a/pom.xml +++ b/pom.xml @@ -35,28 +35,15 @@ https://sonar.opendaylight.org/ http://nexus.opendaylight.org/content dav:http://nexus.opendaylight.org/content/sites/site - 3.2 - 2.6 UTF-8 - 2.3.2 - 2.13 - 3.0.0 - 1.5.0 - 1.26.2 ${project.build.directory}/yang-gen-config 1.5.0-SNAPSHOT ${project.build.directory}/yang-gen-sal ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 - 1.0.9 - 1.7.2 1.2.0-SNAPSHOT 2010.09.24.7-SNAPSHOT 2013.09.07.7-SNAPSHOT - 2.4.0 - 14.0.1 - 4.0.23.Final - 2.3.2 0.7.0-SNAPSHOT 0.7.0-SNAPSHOT 1.2.0-SNAPSHOT @@ -347,36 +334,11 @@ - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - org.apache.maven.plugins - maven-release-plugin - ${releaseplugin.version} - org.opendaylight.yangtools yang-maven-plugin ${yangtools.version} - - org.apache.felix - maven-bundle-plugin - ${maven.bundle.version} - org.codehaus.mojo build-helper-maven-plugin From 238cb48b9a2318936289a2a0ca2800ea9259976b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 9 Feb 2015 10:06:53 +0100 Subject: [PATCH 126/285] Remove unneeded dependencyManagement declarations All of these declarations already exist in odlparent, no need to redefine them here. Change-Id: Iacebf45d5b8054f6656ea102f5755eaf713c7440 Signed-off-by: Robert Varga --- pom.xml | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/pom.xml b/pom.xml index 2717d316..21f4d827 100644 --- a/pom.xml +++ b/pom.xml @@ -146,41 +146,6 @@ features xml
- - org.slf4j - slf4j-api - ${slf4j.version} - - - io.netty - netty-buffer - ${netty.version} - - - io.netty - netty-handler - ${netty.version} - - - io.netty - netty-codec - ${netty.version} - - - io.netty - netty-common - ${netty.version} - - - io.netty - netty-transport - ${netty.version} - - - com.google.guava - guava - ${guava.version} - org.opendaylight.yangtools.model ietf-inet-types @@ -196,29 +161,11 @@ yang-ext ${yang.ext.version} - - org.osgi - org.osgi.core - 5.0.0 - org.opendaylight.controller config-api 0.3.0-SNAPSHOT - - junit - junit - ${junit.version} - test - true - - - org.mockito - mockito-all - 1.9.5 - test - org.opendaylight.yangtools features-test From e10d2778475f4e9d722923ca944c252940cced5a Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Mon, 9 Feb 2015 17:23:18 +0100 Subject: [PATCH 127/285] Removed tags - according to future plans mentioned here: https://lists.opendaylight.org/pipermail/tsc/2015-February/002497.html Change-Id: Ieb48b5a1348a3de2c3cabf62a009934ba552d2c8 Signed-off-by: Martin Uhlir --- pom.xml | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/pom.xml b/pom.xml index 21f4d827..a63eb495 100644 --- a/pom.xml +++ b/pom.xml @@ -57,59 +57,6 @@ Sonar way with Findbugs - - - - odlPublic - odlPublic - ${nexusproxy}/groups/public/ - - false - - - true - - - - - opendaylight-snapshot - ${nexusproxy}/repositories/opendaylight.snapshot/ - - true - - - false - - - - - - - - - odlPublic - odlPublic - ${nexusproxy}/groups/public/ - - false - - - true - - - - - opendaylight-snapshot - opendaylight-snapshot - ${nexusproxy}/repositories/opendaylight.snapshot/ - - true - - - false - - - From 99dcd84c9e4bf42af16371a77cc5d34745afef6b Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Fri, 6 Feb 2015 15:41:38 +0100 Subject: [PATCH 128/285] Added option to initiate connection to device - as this feature was missing (according to OF specification) - added integration test Change-Id: I0f7346195999170a74975ee3438bc948fd685e61 Signed-off-by: Martin Uhlir --- .../impl/core/ConnectionInitializer.java | 16 +++ .../core/SwitchConnectionProviderImpl.java | 22 +++- .../impl/core/TcpChannelInitializer.java | 21 +-- .../impl/core/TcpConnectionInitializer.java | 80 +++++++++++ .../protocol/impl/core/TcpHandler.java | 30 +++-- .../protocol/impl/core/TcpHandlerTest.java | 3 +- .../it/integration/IntegrationTest.java | 60 +++++++-- .../protocol/it/integration/MockPlugin.java | 13 +- .../connection/SwitchConnectionProvider.java | 1 - .../impl/clients/ListeningSimpleClient.java | 124 ++++++++++++++++++ 10 files changed, 333 insertions(+), 37 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java new file mode 100644 index 00000000..4959edaa --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java @@ -0,0 +1,16 @@ +package org.opendaylight.openflowjava.protocol.impl.core; + +/** + * @author martin.uhlir + * + */ +public interface ConnectionInitializer { + + /** + * Initiates connection towards device + * @param host - host IP + * @param port - port number + */ + void initiateConnection(String host, int port); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 9e8a7a18..92f05827 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -9,6 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import io.netty.channel.nio.NioEventLoopGroup; + import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -58,7 +60,7 @@ * @author mirehak * @author michal.polkorab */ -public class SwitchConnectionProviderImpl implements SwitchConnectionProvider { +public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, ConnectionInitializer { private static final Logger LOGGER = LoggerFactory .getLogger(SwitchConnectionProviderImpl.class); @@ -69,6 +71,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider { private SerializerRegistry serializerRegistry; private DeserializerRegistry deserializerRegistry; private DeserializationFactory deserializationFactory; + private TcpConnectionInitializer connectionInitializer; /** Constructor */ public SwitchConnectionProviderImpl() { @@ -137,7 +140,14 @@ private ServerFacade createAndConfigureServer() { TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol(); if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); - ((TcpHandler) server).setChannelInitializer(factory.createPublishingChannelInitializer()); + TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer(); + ((TcpHandler) server).setChannelInitializer(channelInitializer); + ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration()); + + NioEventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup(); + connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler); + connectionInitializer.setChannelInitializer(channelInitializer); + connectionInitializer.run(); } else if (transportProtocol.equals(TransportProtocol.UDP)){ server = new UdpHandler(connConfig.getAddress(), connConfig.getPort()); ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer()); @@ -265,4 +275,10 @@ public void registerMeterBandSerializer(ExperimenterIdSerializerKey serializer) { serializerRegistry.registerSerializer(key, serializer); } -} \ No newline at end of file + + @Override + public void initiateConnection(String host, int port) { + connectionInitializer.initiateConnection(host, port); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 07aab354..8282f078 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -54,15 +54,18 @@ protected TcpChannelInitializer( DefaultChannelGroup channelGroup, ConnectionAda @Override protected void initChannel(final SocketChannel ch) { - InetAddress switchAddress = ch.remoteAddress().getAddress(); - int port = ch.localAddress().getPort(); - int remotePort = ch.remoteAddress().getPort(); - LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString() - + ":" + remotePort + " --> :" + port); - if (!getSwitchConnectionHandler().accept(switchAddress)) { - ch.disconnect(); - LOGGER.debug("Incoming connection rejected"); - return; + if (ch.remoteAddress() != null) { + InetAddress switchAddress = ch.remoteAddress().getAddress(); + int port = ch.localAddress().getPort(); + int remotePort = ch.remoteAddress().getPort(); + LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString() + + ":" + remotePort + " --> :" + port); + + if (!getSwitchConnectionHandler().accept(switchAddress)) { + ch.disconnect(); + LOGGER.debug("Incoming connection rejected"); + return; + } } LOGGER.debug("Incoming connection accepted - building pipeline"); allChannels.add(ch); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java new file mode 100644 index 00000000..c4b0937e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java @@ -0,0 +1,80 @@ +package org.opendaylight.openflowjava.protocol.impl.core; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; + +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +/** + * Initializes (TCP) connection to device + * @author martin.uhlir + * + */ +public class TcpConnectionInitializer implements ServerFacade, + ConnectionInitializer { + + private static final Logger LOGGER = LoggerFactory + .getLogger(TcpConnectionInitializer.class); + private EventLoopGroup workerGroup; + private ThreadConfiguration threadConfig; + + private TcpChannelInitializer channelInitializer; + private Bootstrap b; + + /** + * Constructor + * @param workerGroup - shared worker group + */ + public TcpConnectionInitializer(NioEventLoopGroup workerGroup) { + Preconditions.checkNotNull(workerGroup, "WorkerGroup can't be null"); + this.workerGroup = workerGroup; + } + + @Override + public void run() { + b = new Bootstrap(); + b.group(workerGroup).channel(NioSocketChannel.class) + .handler(channelInitializer); + } + + @Override + public ListenableFuture shutdown() { + final SettableFuture result = SettableFuture.create(); + workerGroup.shutdownGracefully(); + return result; + } + + @Override + public ListenableFuture getIsOnlineFuture() { + return null; + } + + @Override + public void setThreadConfig(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } + + @Override + public void initiateConnection(String host, int port) { + try { + b.connect(host, port).sync(); + } catch (InterruptedException e) { + LOGGER.error("Unable to initiate connection", e); + } + } + + /** + * @param channelInitializer + */ + public void setChannelInitializer(TcpChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 0c26354e..48d5aa14 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -82,14 +82,6 @@ public TcpHandler(final InetAddress address, final int port) { */ @Override public void run() { - if (threadConfig != null) { - bossGroup = new NioEventLoopGroup(threadConfig.getBossThreadCount()); - workerGroup = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); - } else { - bossGroup = new NioEventLoopGroup(); - workerGroup = new NioEventLoopGroup(); - } - /* * We generally do not perform IO-unrelated tasks, so we want to have * all outstanding tasks completed before the executing thread goes @@ -204,4 +196,26 @@ public void setChannelInitializer(TcpChannelInitializer channelInitializer) { public void setThreadConfig(ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } + + /** + * Initiate event loop groups + * @param threadConfiguration number of threads to be created, if not specified in threadConfig + */ + public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration) { + if (threadConfiguration != null) { + bossGroup = new NioEventLoopGroup(threadConfiguration.getBossThreadCount()); + workerGroup = new NioEventLoopGroup(threadConfiguration.getWorkerThreadCount()); + } else { + bossGroup = new NioEventLoopGroup(); + workerGroup = new NioEventLoopGroup(); + } + } + + /** + * @return workerGroup + */ + public NioEventLoopGroup getWorkerGroup() { + return workerGroup; + } + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java index 129a8668..6d103355 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java @@ -123,6 +123,7 @@ public void testSocketAlreadyInUse() throws IOException { try { tcpHandler = new TcpHandler(serverAddress, serverPort); tcpHandler.setChannelInitializer(mockChannelInitializer); + tcpHandler.initiateEventLoopGroups(null); tcpHandler.run(); } catch (Exception e) { if (e instanceof BindException) { @@ -150,7 +151,7 @@ private void shutdownServer() throws InterruptedException, ExecutionException { */ private Boolean startupServer() throws InterruptedException, IOException, ExecutionException { ListenableFuture online = tcpHandler.getIsOnlineFuture(); - + tcpHandler.initiateEventLoopGroups(null); (new Thread(tcpHandler)).start(); int retry = 0; while (online.isDone() != true && retry++ < 20) { diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 6464a62f..3eedff52 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.Deque; import java.util.List; - import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -21,6 +20,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent; +import org.opendaylight.openflowjava.protocol.impl.clients.ListeningSimpleClient; import org.opendaylight.openflowjava.protocol.impl.clients.OFClient; import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioFactory; import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler; @@ -58,6 +58,9 @@ public class IntegrationTest { private SwitchConnectionProviderImpl switchConnectionProvider; private ConnectionConfigurationImpl connConfig; + private Thread t; + + private enum ClientType {SIMPLE, LISTENING} /** * @param protocol communication protocol to be used during test * @throws Exception @@ -110,7 +113,7 @@ public void testHandshake() throws Exception { int amountOfCLients = 1; Deque scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -128,7 +131,7 @@ public void testTlsHandshake() throws Exception { int amountOfCLients = 1; Deque scenario = ScenarioFactory.createHandshakeScenario(); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -150,7 +153,7 @@ public void testHandshakeAndEcho() throws Exception { scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); @@ -171,7 +174,7 @@ public void testTlsHandshakeAndEcho() throws Exception { scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); @@ -192,7 +195,7 @@ public void testUdpHandshakeAndEcho() throws Exception { scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP); + List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE); OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); @@ -215,23 +218,35 @@ public void testCommunicationWithVM() throws Exception { * @throws ExecutionException if some client could not start */ private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler, - TransportProtocol protocol) throws ExecutionException { + TransportProtocol protocol, ClientType clientType) throws ExecutionException { List clientsHorde = new ArrayList<>(); for (int i = 0; i < amountOfCLients; i++) { LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress()); OFClient sc = null; - if (protocol.equals(TransportProtocol.TCP)) { - sc = new SimpleClient(startupAddress.getHostAddress(), port); + if (clientType == ClientType.SIMPLE) { + if (protocol.equals(TransportProtocol.TCP)) { + sc = new SimpleClient(startupAddress.getHostAddress(), port); + sc.setSecuredClient(false); + } else if (protocol.equals(TransportProtocol.TLS)) { + sc = new SimpleClient(startupAddress.getHostAddress(), port); + sc.setSecuredClient(true); + } else { + sc = new UdpSimpleClient(startupAddress.getHostAddress(), port); + } + } else if (clientType == ClientType.LISTENING) { + sc = new ListeningSimpleClient(0); + sc.setScenarioHandler(scenarioHandler); sc.setSecuredClient(false); - } else if (protocol.equals(TransportProtocol.TLS)) { - sc = new SimpleClient(startupAddress.getHostAddress(), port); - sc.setSecuredClient(true); } else { - sc = new UdpSimpleClient(startupAddress.getHostAddress(), port); + LOGGER.error("Unknown type of client."); + throw new IllegalStateException("Unknown type of client."); } + sc.setScenarioHandler(scenarioHandler); clientsHorde.add(sc); - sc.run(); + //sc.run(); + t = new Thread(sc); + t.start(); } for (OFClient sc : clientsHorde) { try { @@ -244,4 +259,21 @@ private List createAndStartClient(int amountOfCLients, ScenarioHandler return clientsHorde; } + /** + * @throws Exception + */ + @Test + public void testInitiateConnection() throws Exception { + setUp(TransportProtocol.TCP); + + Deque scenario = ScenarioFactory.createHandshakeScenario(); + ScenarioHandler handler = new ScenarioHandler(scenario); + List clients = createAndStartClient(1, handler, TransportProtocol.TCP, ClientType.LISTENING); + OFClient ofClient = clients.get(0); + ofClient.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); + int listeningClientPort = ((ListeningSimpleClient) ofClient).getPort(); + mockPlugin.initiateConnection(switchConnectionProvider, "localhost", listeningClientPort); + ofClient.getScenarioDone().get(); + LOGGER.debug("testInitiateConnection() Finished") ; + } } diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index f8298bbf..e83bac83 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -18,6 +18,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; @@ -231,5 +233,14 @@ public void onConnectionReady() { LOGGER.trace("MockPlugin().onConnectionReady()"); } - + /** + * Initiates connection to device + * @param switchConnectionProvider + * @param host - host IP + * @param port - port number + */ + public void initiateConnection(SwitchConnectionProviderImpl switchConnectionProvider, String host, int port) { + LOGGER.trace("MockPlugin().initiateConnection()"); + switchConnectionProvider.initiateConnection(host, port); + } } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index b57500b4..c6910b14 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -46,5 +46,4 @@ public interface SwitchConnectionProvider extends AutoCloseable, * @param switchConHandler instance being informed when new switch connects */ void setSwitchConnectionHandler(SwitchConnectionHandler switchConHandler); - } \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java new file mode 100644 index 00000000..0288745f --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java @@ -0,0 +1,124 @@ +package org.opendaylight.openflowjava.protocol.impl.clients; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.util.concurrent.Future; + +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutionException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * Listening client for testing purposes + * @author martin.uhlir + * + */ +public class ListeningSimpleClient implements OFClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(ListeningSimpleClient.class); + private int port; + private boolean securedClient = false; + private EventLoopGroup workerGroup; + private SettableFuture isOnlineFuture; + private SettableFuture scenarioDone; + private ScenarioHandler scenarioHandler; + + /** + * Constructor of the class + * + * @param host address of host + * @param port host listening port + */ + public ListeningSimpleClient(int port) { + this.port = port; + init(); + } + + private void init() { + isOnlineFuture = SettableFuture.create(); + scenarioDone = SettableFuture.create(); + } + + /** + * Starting class of {@link ListeningSimpleClient} + */ + @Override + public void run() { + EventLoopGroup bossGroup = new NioEventLoopGroup(1); + workerGroup = new NioEventLoopGroup(); + SimpleClientInitializer clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient); + clientInitializer.setScenario(scenarioHandler); + try { + ServerBootstrap b = new ServerBootstrap(); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(clientInitializer); + + ChannelFuture f = b.bind(port).sync(); + // Update port, as it may have been specified as 0 + this.port = ((InetSocketAddress) f.channel().localAddress()).getPort(); + isOnlineFuture.set(true); + + synchronized (scenarioHandler) { + LOGGER.debug("WAITING FOR SCENARIO"); + while (! scenarioHandler.isScenarioFinished()) { + scenarioHandler.wait(); + } + } + } catch (Exception ex) { + LOGGER.error(ex.getMessage(), ex); + } finally { + LOGGER.debug("listening client shutting down"); + try { + workerGroup.shutdownGracefully().get(); + bossGroup.shutdownGracefully().get(); + LOGGER.debug("listening client shutdown succesful"); + } catch (InterruptedException | ExecutionException e) { + LOGGER.error(e.getMessage(), e); + } + } + scenarioDone.set(true); + } + + /** + * @return close future + */ + public Future disconnect() { + LOGGER.debug("disconnecting client"); + return workerGroup.shutdownGracefully(); + } + + @Override + public void setSecuredClient(boolean securedClient) { + this.securedClient = securedClient; + } + + @Override + public SettableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + @Override + public SettableFuture getScenarioDone() { + return scenarioDone; + } + + @Override + public void setScenarioHandler(ScenarioHandler scenario) { + this.scenarioHandler = scenario; + } + + /** + * @return actual port number + */ + public int getPort() { + return this.port; + } +} \ No newline at end of file From 55b6b6b415e0212847baa40ece5a98330ca611c5 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 12 Feb 2015 16:44:28 -0500 Subject: [PATCH 129/285] Remove unncessary Sonar variables These variables are managed server side or in Jenkins with the latest Sonar release so should not be configured in project pom.xml files. Change-Id: I34dc5a64569a1aaf2ca65f0cff2aa87a9f9b1b6f Signed-off-by: Thanh Ha --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index a63eb495..c1bf6218 100644 --- a/pom.xml +++ b/pom.xml @@ -32,14 +32,12 @@ - https://sonar.opendaylight.org/ http://nexus.opendaylight.org/content dav:http://nexus.opendaylight.org/content/sites/site UTF-8 ${project.build.directory}/yang-gen-config 1.5.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - ${user.name}-private-view org.openflow.openflowj,net.sf.jung2 1.2.0-SNAPSHOT 2010.09.24.7-SNAPSHOT @@ -54,7 +52,6 @@ jacoco target/code-coverage/jacoco.exec target/code-coverage/jacoco-it.exec - Sonar way with Findbugs From 3221974c0b95f8c1477692cee44e25567bc3b3b0 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 19:54:57 +0100 Subject: [PATCH 130/285] Remove distributionManagement It is handled by settings.xml now, so no need to carry it around. Change-Id: I6a5de99277d735487a6f2f62727bb1e4200ba898 Signed-off-by: Robert Varga --- pom.xml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/pom.xml b/pom.xml index c1bf6218..7e1ca6a5 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,6 @@ - http://nexus.opendaylight.org/content dav:http://nexus.opendaylight.org/content/sites/site UTF-8 ${project.build.directory}/yang-gen-config @@ -54,25 +53,6 @@ target/code-coverage/jacoco-it.exec - - - - opendaylight-release - ${nexusproxy}/repositories/opendaylight.release/ - - - - opendaylight-snapshot - ${nexusproxy}/repositories/opendaylight.snapshot/ - - - - - - From 257917655152d0db9fad7c9aea00dd41991fb4fc Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 19:57:20 +0100 Subject: [PATCH 131/285] Migrate to artifact imports This is the proper inter-project version declartion mechanism: just import the produced artifacts along with versions. Change-Id: I1ad948e400e3c994522912ed2be1f08fe6349893 Signed-off-by: Robert Varga --- pom.xml | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index 7e1ca6a5..2a2ce464 100644 --- a/pom.xml +++ b/pom.xml @@ -55,45 +55,19 @@ - org.opendaylight.yangtools - features-yangtools + yangtools-artifacts ${yangtools.version} - features - xml + pom + import org.opendaylight.controller - features-config + config-artifacts ${config.version} - features - xml - - - org.opendaylight.yangtools.model - ietf-inet-types - ${ietf.model.version} - - - org.opendaylight.yangtools.model - ietf-yang-types - ${ietf.model.version} - - - org.opendaylight.yangtools.model - yang-ext - ${yang.ext.version} - - - org.opendaylight.controller - config-api - 0.3.0-SNAPSHOT - - - org.opendaylight.yangtools - features-test - ${yangtools.version} + pom + import From 1b72f3e039ef5e9a18ab4fd3f24f55dca57cca6a Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 19:54:24 +0100 Subject: [PATCH 132/285] Remove unneeded yangtools version The version is already inherited from parent, no need to repeat it here. Change-Id: I862dd6912463b063078d7bb927da7e3e3952f465 Signed-off-by: Robert Varga --- openflow-protocol-api/pom.xml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 894173aa..72dda9a2 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -9,13 +9,9 @@ bundle Openflow Protocol Library - API - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD - - - - 0.7.0-SNAPSHOT - + @@ -101,12 +97,10 @@ org.opendaylight.yangtools yang-binding - ${yangtools.binding.version} org.opendaylight.yangtools yang-common - ${yangtools.version} org.opendaylight.yangtools.model From 4174838cfa866480ac62f109d1091a684e44d9c8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 20:15:33 +0100 Subject: [PATCH 133/285] Introduce an artifacts artifact This will ease up the imports in downstream projects. Change-Id: Ie91dfc04cf969639d83ebb85e4d0a348c5108971 Signed-off-by: Robert Varga --- artifacts/pom.xml | 75 +++++++++++++++++++++++++++++++++++++++++++++++ features/pom.xml | 6 ++++ pom.xml | 21 +++++++++++-- 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 artifacts/pom.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml new file mode 100644 index 00000000..d1840736 --- /dev/null +++ b/artifacts/pom.xml @@ -0,0 +1,75 @@ + + + + + + 4.0.0 + org.opendaylight.openflowjava + openflowjava-artifacts + 0.6.0-SNAPSHOT + pom + + + + + ${project.groupId} + openflow-protocol-api + ${project.version} + + + ${project.groupId} + openflow-protocol-impl + ${project.version} + + + ${project.groupId} + openflow-protocol-impl + ${project.version} + test-jar + test + + + ${project.groupId} + openflow-protocol-spi + ${project.version} + + + ${project.groupId} + simple-client + ${project.version} + + + ${project.groupId} + util + ${project.version} + + + ${project.groupId} + openflowjava-config + ${project.version} + + + ${project.groupId} + openflowjava-config + ${project.version} + xml + configstats + + + ${project.groupId} + features-openflowjava + ${project.version} + features + xml + + + + + + diff --git a/features/pom.xml b/features/pom.xml index 4308571f..6da77ddc 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -80,6 +80,12 @@ io.netty netty-transport + + ${project.groupId} + openflowjava-config + xml + configstats + org.opendaylight.yangtools diff --git a/pom.xml b/pom.xml index 2a2ce464..0fb24b4e 100644 --- a/pom.xml +++ b/pom.xml @@ -15,14 +15,15 @@ pom + artifacts + features openflowjava-config openflow-protocol-api - openflow-protocol-spi - util openflow-protocol-impl openflow-protocol-it - features + openflow-protocol-spi simple-client + util scm:git:ssh://git.opendaylight.org:29418/openflowjava.git @@ -55,6 +56,13 @@ + + org.opendaylight.openflowjava + openflowjava-artifacts + ${project.version} + pom + import + org.opendaylight.yangtools yangtools-artifacts @@ -69,6 +77,13 @@ pom import + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + import + pom + From 9cce16223e45c9622d2a66cba6964c04b8597d78 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 20:19:46 +0100 Subject: [PATCH 134/285] Remove unneeded version declarations They are taken care of by parent import, so no need to declare them again. Change-Id: I66997b43887043e33de039bb2e5f829720a4fc68 Signed-off-by: Robert Varga --- features/pom.xml | 4 ---- openflow-protocol-impl/pom.xml | 3 --- openflow-protocol-it/pom.xml | 3 --- simple-client/pom.xml | 1 - util/pom.xml | 1 - 5 files changed, 12 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 6da77ddc..8eb29eb2 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -43,22 +43,18 @@ org.opendaylight.openflowjava openflow-protocol-api - ${project.version} org.opendaylight.openflowjava openflow-protocol-spi - ${project.version} org.opendaylight.openflowjava openflow-protocol-impl - ${project.version} org.opendaylight.openflowjava util - ${project.version} io.netty diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index ba83903a..3948f919 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -103,17 +103,14 @@ ${project.groupId} openflow-protocol-api - ${project.version} ${project.groupId} openflow-protocol-spi - ${project.version} org.opendaylight.openflowjava util - ${project.version} org.opendaylight.controller diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 2751cc9f..2aafc74e 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -17,20 +17,17 @@ ${project.groupId} openflow-protocol-impl - ${project.version} test ${project.groupId} openflow-protocol-impl test-jar - ${project.version} test ${project.groupId} simple-client - ${project.version} test diff --git a/simple-client/pom.xml b/simple-client/pom.xml index a68633e1..1df035ea 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -31,7 +31,6 @@ ${project.groupId} openflow-protocol-impl - ${project.version} io.netty diff --git a/util/pom.xml b/util/pom.xml index e029f3c5..2dc05398 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -19,7 +19,6 @@ org.opendaylight.openflowjava openflow-protocol-api - ${project.version}
From 32f31ecd4a1850ceffb7fcae77bb73e626d6626b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 20:26:28 +0100 Subject: [PATCH 135/285] Remove unneeded properties These are not referenced anywhere, so we can remove them. Change-Id: Ib528f96fe3832103c79ae0fdcaea3d3f035e06b1 Signed-off-by: Robert Varga --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0fb24b4e..5d9fc1bb 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,7 @@ ${project.build.directory}/yang-gen-config 1.5.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - org.openflow.openflowj,net.sf.jung2 1.2.0-SNAPSHOT - 2010.09.24.7-SNAPSHOT - 2013.09.07.7-SNAPSHOT 0.7.0-SNAPSHOT 0.7.0-SNAPSHOT 1.2.0-SNAPSHOT From 1781422877b0a2a208c3b0818b58c701f2db1098 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 20:28:55 +0100 Subject: [PATCH 136/285] Remove yang.prototypes.version This corresponds to mdsal.version and is already covered by the import. Change-Id: I77f2c225f2ae938380ed994d3726306ec9144390 Signed-off-by: Robert Varga --- openflow-protocol-api/pom.xml | 2 +- openflow-protocol-impl/pom.xml | 9 +-------- openflow-protocol-spi/pom.xml | 7 +++---- pom.xml | 7 +++---- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 72dda9a2..1ec8261f 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -48,7 +48,7 @@ org.opendaylight.yangtools maven-sal-api-gen-plugin - ${yangtools.generator.version} + ${yangtools.version} jar
diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 3948f919..23d0e9fb 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -13,12 +13,6 @@ HEAD - - 0.7.0-SNAPSHOT - 0.7.0-SNAPSHOT - 0.7.0-SNAPSHOT - - @@ -79,7 +73,7 @@ org.opendaylight.yangtools maven-sal-api-gen-plugin - ${yangtools.generator.version} + ${yangtools.version} jar
@@ -115,7 +109,6 @@ org.opendaylight.controller sal-common-util - ${yang.prototype.version} org.opendaylight.controller diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 18369f5e..b2e13905 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -74,7 +74,7 @@ org.opendaylight.yangtools maven-sal-api-gen-plugin - ${yangtools.generator.version} + ${yangtools.version} jar @@ -83,10 +83,9 @@ - - ${project.groupId} + + ${project.groupId} openflow-protocol-api - ${project.version} org.opendaylight.controller diff --git a/pom.xml b/pom.xml index 5d9fc1bb..1b20bbdf 100644 --- a/pom.xml +++ b/pom.xml @@ -38,11 +38,10 @@ ${project.build.directory}/yang-gen-config 1.5.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - 1.2.0-SNAPSHOT - 0.7.0-SNAPSHOT - 0.7.0-SNAPSHOT + + 0.3.0-SNAPSHOT 1.2.0-SNAPSHOT - 0.3.0-SNAPSHOT + 0.7.0-SNAPSHOT 2.4 From feee989223b2914561ea8798c0e5564f9ad9450c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 13 Feb 2015 20:35:14 +0100 Subject: [PATCH 137/285] Migrate features to features-parent odlparent provides a convenient parent, so we can easily use it. Change-Id: I1912af326716305298867504d6fb6dc5df1d4040 Signed-off-by: Robert Varga --- features/pom.xml | 145 +++++++----------- .../main/{resources => features}/features.xml | 18 +-- 2 files changed, 63 insertions(+), 100 deletions(-) rename features/src/main/{resources => features}/features.xml (78%) diff --git a/features/pom.xml b/features/pom.xml index 8eb29eb2..4edae6b3 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -2,21 +2,62 @@ 4.0.0 - org.opendaylight.openflowjava - openflow-protocol-parent - 0.6.0-SNAPSHOT - ../ + org.opendaylight.odlparent + features-parent + 1.5.0-SNAPSHOT + - features-openflowjava + org.opendaylight.openflowjava + features-openflowjava + 0.6.0-SNAPSHOT jar - features.xml - 1.5.0-SNAPSHOT + 0.3.0-SNAPSHOT + 1.2.0-SNAPSHOT 0.7.0-SNAPSHOT + + + + + org.opendaylight.openflowjava + openflowjava-artifacts + ${project.version} + import + pom + + + + + org.opendaylight.yangtools + yangtools-artifacts + ${yangtools.version} + import + pom + + + + + org.opendaylight.controller + config-artifacts + ${config.version} + import + pom + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + import + pom + + + + + @@ -56,6 +97,12 @@ org.opendaylight.openflowjava util + + ${project.groupId} + openflowjava-config + xml + configstats + io.netty netty-codec @@ -76,90 +123,6 @@ io.netty netty-transport - - ${project.groupId} - openflowjava-config - xml - configstats - - - - org.opendaylight.yangtools - features-test - - - - org.opendaylight.controller - opendaylight-karaf-empty - ${karaf.distro.empty.version} - zip - - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.16 - - - org.opendaylight.controller - opendaylight-karaf-empty - ${karaf.empty.distro.version} - - - org.opendaylight.yangtools:features-test - - - - - - - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - HEAD - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - diff --git a/features/src/main/resources/features.xml b/features/src/main/features/features.xml similarity index 78% rename from features/src/main/resources/features.xml rename to features/src/main/features/features.xml index 315fd338..e43bada6 100644 --- a/features/src/main/resources/features.xml +++ b/features/src/main/features/features.xml @@ -15,15 +15,15 @@ odl-yangtools-models odl-config-api odl-mdsal-common - mvn:io.netty/netty-buffer/${netty.version} - mvn:io.netty/netty-common/${netty.version} - mvn:io.netty/netty-transport/${netty.version} - mvn:io.netty/netty-codec/${netty.version} - mvn:io.netty/netty-handler/${netty.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-api/${project.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-spi/${project.version} - mvn:org.opendaylight.openflowjava/openflow-protocol-impl/${project.version} - mvn:org.opendaylight.openflowjava/util/${project.version} + mvn:io.netty/netty-buffer/{{VERSION}} + mvn:io.netty/netty-common/{{VERSION}} + mvn:io.netty/netty-transport/{{VERSION}} + mvn:io.netty/netty-codec/{{VERSION}} + mvn:io.netty/netty-handler/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflow-protocol-api/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} + mvn:org.opendaylight.openflowjava/util/{{VERSION}} odl-openflowjava-protocol From f04d245dfbee2cc3e69db0ca17a5a819c5ef5b51 Mon Sep 17 00:00:00 2001 From: Martin Uhlir Date: Fri, 23 Jan 2015 14:17:48 +0100 Subject: [PATCH 138/285] Exposed channel autoread option Change-Id: I8174d4d7d54eaa4bb6959501561384afd2267afa Signed-off-by: Martin Uhlir --- .../protocol/api/connection/ConnectionAdapter.java | 11 +++++++++++ .../impl/core/connection/ConnectionAdapterImpl.java | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 82b7a896..6d61a217 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -63,4 +63,15 @@ public interface ConnectionAdapter extends OpenflowProtocolService { */ void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener); + /** + * sets option for automatic channel reading; + * if set to false, incoming messages won't be read + */ + void setAutoRead(boolean autoRead); + + /** + * @return true, if channel is configured to autoread + */ + boolean isAutoRead(); + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index c2854bec..d81363c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -469,4 +469,14 @@ public InetSocketAddress getRemoteAddress() { public void setResponseCache(Cache> cache) { this.responseCache = cache; } + + @Override + public boolean isAutoRead() { + return channel.config().isAutoRead(); + } + + @Override + public void setAutoRead(boolean autoRead) { + channel.config().setAutoRead(autoRead); + } } From 435f3e8a95843a6e9a326ab56663c31ff6d7cdb7 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 12 Mar 2015 22:28:49 -0400 Subject: [PATCH 139/285] Add odlparent relativepath relative to autorelease Change-Id: Iaef70a0a21db712b50adbc2afae1b9deb350631e Signed-off-by: Thanh Ha --- features/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 4edae6b3..03d34620 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent features-parent 1.5.0-SNAPSHOT - + ../../odlparent/features-parent org.opendaylight.openflowjava diff --git a/pom.xml b/pom.xml index 1b20bbdf..226050e9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent 1.5.0-SNAPSHOT - + ../odlparent/odlparent org.opendaylight.openflowjava From 29a2a074c78708f6d18583779ece96bb6573f0c6 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 25 Feb 2015 12:59:40 +0100 Subject: [PATCH 140/285] Bug 2756 - Match model update - updated openflow-extensible-match and openflow-augments revisions Change-Id: I87188326bd2365133fc55f1ebddf78e0e453bb44 Signed-off-by: Michal Polkorab --- .../SerializerExtensionProvider.java | 4 +- .../api/keys/MatchEntryDeserializerKey.java | 4 +- .../api/keys/MatchEntrySerializerKey.java | 10 +- .../src/main/yang/openflow-augments.yang | 181 +--- .../main/yang/openflow-extensible-match.yang | 868 ++++++++++++------ .../protocol/api/keys/KeysTest.java | 10 +- .../keys/MatchEntryDeserializerKeyTest.java | 6 +- .../api/keys/MatchEntrySerializerKeyTest.java | 17 +- .../core/SwitchConnectionProviderImpl.java | 4 +- .../DeserializerRegistryImpl.java | 4 +- .../AbstractEthertypeActionDeserializer.java | 6 +- ...10AbstractIpAddressActionDeserializer.java | 6 +- ...0AbstractMacAddressActionDeserializer.java | 6 +- .../OF10AbstractPortActionDeserializer.java | 6 +- .../action/OF10EnqueueActionDeserializer.java | 6 +- .../action/OF10OutputActionDeserializer.java | 4 +- .../OF10SetNwTosActionDeserializer.java | 6 +- .../OF10SetVlanPcpActionDeserializer.java | 6 +- .../OF10SetVlanVidActionDeserializer.java | 6 +- .../action/OF13GroupActionDeserializer.java | 4 +- .../action/OF13OutputActionDeserializer.java | 10 +- .../OF13SetFieldActionDeserializer.java | 12 +- .../OF13SetMplsTtlActionDeserializer.java | 6 +- .../OF13SetNwTtlActionDeserializer.java | 6 +- .../OF13SetQueueActionDeserializer.java | 4 +- .../factories/FlowRemovedMessageFactory.java | 2 +- .../MultipartReplyMessageFactory.java | 28 +- .../OF10FlowRemovedMessageFactory.java | 2 +- ...OF10QueueGetConfigReplyMessageFactory.java | 4 +- .../OF10StatsReplyMessageFactory.java | 2 +- .../factories/PacketInMessageFactory.java | 2 +- .../QueueGetConfigReplyMessageFactory.java | 4 +- ...AbstractActionInstructionDeserializer.java | 6 +- .../ClearActionsInstructionDeserializer.java | 4 +- .../GoToTableInstructionDeserializer.java | 4 +- .../MeterInstructionDeserializer.java | 4 +- .../WriteMetadataInstructionDeserializer.java | 4 +- .../AbstractOxmIpv4AddressDeserializer.java | 43 - .../AbstractOxmIpv6AddressDeserializer.java | 44 - .../AbstractOxmMacAddressDeserializer.java | 45 - .../AbstractOxmMatchEntryDeserializer.java | 18 +- .../AbstractOxmMetadataDeserializer.java | 43 - .../match/AbstractOxmPortDeserializer.java | 38 - .../AbstractOxmPortNumberDeserializer.java | 34 - .../match/OxmArpOpDeserializer.java | 34 +- .../match/OxmArpShaDeserializer.java | 37 +- .../match/OxmArpSpaDeserializer.java | 39 +- .../match/OxmArpThaDeserializer.java | 37 +- .../match/OxmArpTpaDeserializer.java | 39 +- .../match/OxmDeserializerHelper.java | 48 + .../match/OxmEthDstDeserializer.java | 37 +- .../match/OxmEthSrcDeserializer.java | 37 +- .../match/OxmEthTypeDeserializer.java | 34 +- .../match/OxmIcmpv4CodeDeserializer.java | 35 +- .../match/OxmIcmpv4TypeDeserializer.java | 35 +- .../match/OxmIcmpv6CodeDeserializer.java | 35 +- .../match/OxmIcmpv6TypeDeserializer.java | 34 +- .../match/OxmInPhyPortDeserializer.java | 34 +- .../match/OxmInPortDeserializer.java | 34 +- .../match/OxmIpDscpDeserializer.java | 32 +- .../match/OxmIpEcnDeserializer.java | 32 +- .../match/OxmIpProtoDeserializer.java | 34 +- .../match/OxmIpv4DstDeserializer.java | 39 +- .../match/OxmIpv4SrcDeserializer.java | 39 +- .../match/OxmIpv6DstDeserializer.java | 39 +- .../match/OxmIpv6ExtHdrDeserializer.java | 44 +- .../match/OxmIpv6FlabelDeserializer.java | 42 +- .../match/OxmIpv6NdSllDeserializer.java | 33 +- .../match/OxmIpv6NdTargetDeserializer.java | 35 +- .../match/OxmIpv6NdTllDeserializer.java | 33 +- .../match/OxmIpv6SrcDeserializer.java | 39 +- .../match/OxmMaskDeserializer.java | 40 - .../match/OxmMetadataDeserializer.java | 40 +- .../match/OxmMplsBosDeserializer.java | 34 +- .../match/OxmMplsLabelDeserializer.java | 35 +- .../match/OxmMplsTcDeserializer.java | 33 +- .../match/OxmPbbIsidDeserializer.java | 40 +- .../match/OxmSctpDstDeserializer.java | 34 +- .../match/OxmSctpSrcDeserializer.java | 34 +- .../match/OxmTcpDstDeserializer.java | 35 +- .../match/OxmTcpSrcDeserializer.java | 34 +- .../match/OxmTunnelIdDeserializer.java | 40 +- .../match/OxmUdpDstDeserializer.java | 34 +- .../match/OxmUdpSrcDeserializer.java | 34 +- .../match/OxmVlanPcpDeserializer.java | 34 +- .../match/OxmVlanVidDeserializer.java | 43 +- .../MatchEntriesInitializer.java | 86 +- .../serialization/SerializerRegistryImpl.java | 4 +- .../AbstractEthertypeActionSerializer.java | 2 +- ...OF10AbstractIpAddressActionSerializer.java | 2 +- ...F10AbstractMacAddressActionSerializer.java | 2 +- .../OF10AbstractPortActionSerializer.java | 2 +- .../action/OF10EnqueueActionSerializer.java | 4 +- .../action/OF10OutputActionSerializer.java | 4 +- .../action/OF10SetNwTosActionSerializer.java | 2 +- .../OF10SetVlanPcpActionSerializer.java | 2 +- .../OF10SetVlanVidActionSerializer.java | 2 +- .../action/OF13GroupActionSerializer.java | 2 +- .../action/OF13OutputActionSerializer.java | 4 +- .../action/OF13SetFieldActionSerializer.java | 16 +- .../OF13SetMplsTtlActionSerializer.java | 2 +- .../action/OF13SetNwTtlActionSerializer.java | 2 +- .../action/OF13SetQueueActionSerializer.java | 2 +- .../factories/FlowModInputMessageFactory.java | 4 +- .../MeterModInputMessageFactory.java | 2 +- .../MultipartRequestInputFactory.java | 24 +- .../OF10FlowModInputMessageFactory.java | 6 +- .../OF10StatsRequestInputFactory.java | 4 +- .../AbstractActionInstructionSerializer.java | 6 +- .../GoToTableInstructionSerializer.java | 2 +- .../MeterInstructionSerializer.java | 2 +- .../WriteMetadataInstructionSerializer.java | 2 +- .../AbstractOxmIpv4AddressSerializer.java | 14 +- .../AbstractOxmIpv6AddressSerializer.java | 10 +- .../AbstractOxmMacAddressSerializer.java | 11 +- .../AbstractOxmMatchEntrySerializer.java | 22 +- .../match/AbstractOxmMetadataSerializer.java | 27 - .../AbstractOxmPortNumberSerializer.java | 26 - .../match/AbstractOxmPortSerializer.java | 26 - .../match/OxmArpOpSerializer.java | 9 +- .../match/OxmArpShaSerializer.java | 14 + .../match/OxmArpSpaSerializer.java | 15 + .../match/OxmArpThaSerializer.java | 14 + .../match/OxmArpTpaSerializer.java | 15 + .../match/OxmEthDstSerializer.java | 14 + .../match/OxmEthSrcSerializer.java | 14 + .../match/OxmEthTypeSerializer.java | 9 +- .../match/OxmIcmpv4CodeSerializer.java | 9 +- .../match/OxmIcmpv4TypeSerializer.java | 9 +- .../match/OxmIcmpv6CodeSerializer.java | 9 +- .../match/OxmIcmpv6TypeSerializer.java | 9 +- .../match/OxmInPhyPortSerializer.java | 13 +- .../match/OxmInPortSerializer.java | 13 +- .../match/OxmIpDscpSerializer.java | 9 +- .../match/OxmIpEcnSerializer.java | 9 +- .../match/OxmIpProtoSerializer.java | 9 +- .../match/OxmIpv4DstSerializer.java | 15 + .../match/OxmIpv4SrcSerializer.java | 15 + .../match/OxmIpv6DstSerializer.java | 15 + .../match/OxmIpv6ExtHdrSerializer.java | 15 +- .../match/OxmIpv6FlabelSerializer.java | 13 +- .../match/OxmIpv6NdSllSerializer.java | 11 + .../match/OxmIpv6NdTargetSerializer.java | 11 + .../match/OxmIpv6NdTllSerializer.java | 11 + .../match/OxmIpv6SrcSerializer.java | 15 + .../match/OxmMetadataSerializer.java | 17 +- .../match/OxmMplsBosSerializer.java | 9 +- .../match/OxmMplsLabelSerializer.java | 9 +- .../match/OxmMplsTcSerializer.java | 9 +- .../match/OxmPbbIsidSerializer.java | 13 +- .../match/OxmSctpDstSerializer.java | 13 +- .../match/OxmSctpSrcSerializer.java | 13 +- .../match/OxmTcpDstSerializer.java | 13 +- .../match/OxmTcpSrcSerializer.java | 13 +- .../match/OxmTunnelIdSerializer.java | 17 +- .../match/OxmUdpDstSerializer.java | 13 +- .../match/OxmUdpSrcSerializer.java | 13 +- .../match/OxmVlanPcpSerializer.java | 9 +- .../match/OxmVlanVidSerializer.java | 14 +- .../protocol/impl/util/MatchDeserializer.java | 12 +- .../MatchEntrySerializerRegistryHelper.java | 4 +- .../impl/util/OF10MatchDeserializer.java | 4 +- .../impl/util/OF10MatchSerializer.java | 2 +- .../impl/util/OF13MatchSerializer.java | 22 +- .../impl/util/TypeKeyMakerFactory.java | 20 +- .../SwitchConnectionProviderImpl02Test.java | 4 +- .../DeserializerRegistryImplTest.java | 4 +- .../MultipartReplyMessageFactoryTest.java | 35 +- ...QueueGetConfigReplyMessageFactoryTest.java | 4 +- .../OF10StatsReplyMessageFactoryTest.java | 6 +- ...GetConfigReplyMessageFactoryMultiTest.java | 6 +- ...QueueGetConfigReplyMessageFactoryTest.java | 6 +- .../multipart/MultipartReplyFlowTest.java | 2 +- .../MultipartReplyTableFeaturesTest.java | 4 +- .../match/OxmIpv6ExtHdrDeserializerTest.java | 16 +- .../match/OxmIpv6FlabelDeserializerTest.java | 34 +- .../match/OxmMetadataDeserializerTest.java | 12 +- .../match/OxmMplsBosDeserializerTest.java | 13 +- .../match/OxmPbbIsidDeserializerTest.java | 13 +- .../match/OxmVlanVidDeserializerTest.java | 14 +- .../SerializerRegistryImplTest.java | 2 +- .../OF13SetFieldActionSerializerTest.java | 38 +- .../FlowModInputMessageFactoryTest.java | 66 +- .../OF10FlowModInputMessageFactoryTest.java | 12 +- .../OF10PacketOutInputMessageFactoryTest.java | 10 +- .../OF10StatsRequestInputFactoryTest.java | 2 +- .../PacketOutInputMessageFactoryTest.java | 6 +- .../MultipartRequestExperimenterTest.java | 4 +- .../MultipartRequestTableFeaturesTest.java | 60 +- .../OF10StatsRequestAggregateTest.java | 2 +- .../OF10StatsRequestExperimenterTest.java | 4 +- .../match/OxmArpOpSerializerTest.java | 30 +- .../match/OxmArpShaSerializerTest.java | 48 +- .../match/OxmArpSpaSerializerTest.java | 40 +- .../match/OxmArpThaSerializerTest.java | 48 +- .../match/OxmArpTpaSerializerTest.java | 40 +- .../match/OxmEthDstSerializerTest.java | 40 +- .../match/OxmEthSrcSerializerTest.java | 40 +- .../match/OxmEthTypeSerializerTest.java | 31 +- .../match/OxmIcmpv4CodeSerializerTest.java | 31 +- .../match/OxmIcmpv4TypeSerializerTest.java | 31 +- .../match/OxmIcmpv6CodeSerializerTest.java | 30 +- .../match/OxmIcmpv6TypeSerializerTest.java | 31 +- .../match/OxmIpDscpSerializerTest.java | 28 +- .../match/OxmIpProtoSerializerTest.java | 28 +- .../match/OxmIpv4DstSerializerTest.java | 40 +- .../match/OxmIpv4SrcSerializerTest.java | 40 +- .../match/OxmIpv6ExtHdrSerializerTest.java | 45 +- .../match/OxmIpv6NdSllSerializerTest.java | 37 +- .../match/OxmIpv6NdTllSerializerTest.java | 37 +- .../match/OxmMetadataSerializerTest.java | 40 +- .../match/OxmMplsBosSerializerTest.java | 31 +- .../match/OxmMplsLabelSerializerTest.java | 30 +- .../match/OxmMplsTcSerializerTest.java | 30 +- .../match/OxmPbbIsidSerializerTest.java | 41 +- .../match/OxmSctpDstSerializerTest.java | 30 +- .../match/OxmSctpSrcSerializerTest.java | 30 +- .../match/OxmTcpDstSerializerTest.java | 30 +- .../match/OxmTcpSrcSerializerTest.java | 30 +- .../match/OxmTunnelIdSerializerTest.java | 40 +- .../match/OxmUdpDstSerializerTest.java | 30 +- .../match/OxmUdpSrcSerializerTest.java | 30 +- .../match/OxmVlanPcpSerializerTest.java | 30 +- .../match/OxmVlanVidSerializerTest.java | 42 +- .../impl/util/ActionsDeserializerTest.java | 29 +- .../util/InstructionsDeserializerTest.java | 18 +- .../impl/util/MatchDeserializerTest.java | 381 ++++---- .../util/OF10ActionsDeserializerTest.java | 16 +- .../impl/util/OF10ActionsSerializerTest.java | 32 +- .../impl/util/OF10MatchDeserializerTest.java | 2 +- .../impl/util/OF10MatchSerializerTest.java | 5 +- .../impl/util/OF13ActionsSerializerTest.java | 72 +- .../util/OF13InstructionsSerializerTest.java | 32 +- .../impl/util/OF13MatchSerializer02Test.java | 699 +++++++------- .../impl/util/OF13MatchSerializerTest.java | 180 ++-- .../impl/util/TypeKeyMakerFactoryTest.java | 44 +- .../protocol/it/integration/MockPlugin.java | 5 +- 237 files changed, 3958 insertions(+), 3043 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index fc4b089f..8729f874 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -13,8 +13,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index d6938402..4f995959 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * @author michal.polkorab @@ -27,7 +27,7 @@ public final class MatchEntryDeserializerKey extends MessageCodeKey */ public MatchEntryDeserializerKey(short version, int oxmClass, int oxmField) { - super(version, oxmClass, MatchEntries.class); + super(version, oxmClass, MatchEntry.class); this.oxmField = oxmField; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index d3cf7c1e..a0867ceb 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * @author michal.polkorab @@ -18,7 +18,7 @@ * @param oxm_field (see specification) */ public final class MatchEntrySerializerKey - extends MessageTypeKey implements ExperimenterSerializerKey { + extends MessageTypeKey implements ExperimenterSerializerKey { private Class oxmClass; private Class oxmField; @@ -32,7 +32,7 @@ public final class MatchEntrySerializerKey oxmClass, Class oxmField) { - super(msgVersion, MatchEntries.class); + super(msgVersion, MatchEntry.class); this.oxmClass = oxmClass; this.oxmField = oxmField; } diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 229d5f5a..d90e4400 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -20,7 +20,7 @@ import openflow-instruction {prefix ofinstruction;} import openflow-extensible-match {prefix oxm;} - revision "2013-10-02" { + revision "2015-02-25" { description "OpenFlow 1.3 - augments model. Please visit https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf @@ -28,175 +28,14 @@ } // OFP_MATCH AUGMENTS - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-number-match-entry"; - leaf port-number { - type oft:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "metadata-match-entry"; - leaf metadata { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mask-match-entry"; - leaf mask { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mac-address-match-entry"; - leaf mac-address { - type yang:mac-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "eth-type-match-entry"; - leaf eth-type { - type oft:ether-type; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-vid-match-entry"; - leaf vlan-vid { - type uint16; - } - leaf cfi-bit { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-pcp-match-entry"; - leaf vlan-pcp { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "dscp-match-entry"; - leaf dscp { - type inet:dscp; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ecn-match-entry"; - leaf ecn { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "protocol-number-match-entry"; - leaf protocol-number { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-match-entry"; - leaf port { - type inet:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-type-match-entry"; - leaf icmpv4-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-code-match-entry"; - leaf icmpv4-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "op-code-match-entry"; - leaf op-code { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-flabel-match-entry"; - leaf ipv6-flabel { - type inet:ipv6-flow-label; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-type-match-entry"; - leaf icmpv6-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-code-match-entry"; - leaf icmpv6-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-address-match-entry"; - leaf ipv6-address { - type inet:ipv6-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv4-address-match-entry"; - leaf ipv4-address { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mpls-label-match-entry"; - leaf mpls-label { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tc-match-entry"; - leaf tc { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "bos-match-entry"; - leaf bos { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "isid-match-entry"; - leaf isid { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "pseudo-field-match-entry"; - leaf pseudo-field { - type oft:ipv6-exthdr-flags; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { + augment "/oxm:oxm-container/oxm:match-entry-value" { ext:augment-identifier "experimenter-id-match-entry"; - leaf experimenter { - type oft:experimenter-id; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tcp-flag-match-entry"; - leaf tcp-flag { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-dst-match-entry"; - leaf tunnel-ipv4-dst { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-src-match-entry"; - leaf tunnel-ipv4-src { - type inet:ipv4-address; + case experimenter-id-case { + container experimenter { + leaf experimenter { + type oft:experimenter-id; + } + } } } @@ -245,7 +84,7 @@ } augment "/ofaction:actions-container/ofaction:action" { ext:augment-identifier "oxm-fields-action"; - uses oxm:oxm-fields-grouping; + uses oxm:match-entries-grouping; } augment "/ofaction:actions-container/ofaction:action" { ext:augment-identifier "experimenter-id-action"; @@ -310,7 +149,7 @@ } augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { ext:augment-identifier "oxm-related-table-feature-property"; - uses oxm:oxm-fields-grouping; + uses oxm:match-entries-grouping; } augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { ext:augment-identifier "experimenter-id-table-feature-property"; diff --git a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang index e1f5514f..f9d3f6c3 100644 --- a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang +++ b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang @@ -14,7 +14,7 @@ import ietf-inet-types {prefix inet;} import openflow-types {prefix oft;} - revision "2013-07-31" { + revision "2015-02-25" { description "OpenFlow 1.3 - match model"; } @@ -26,309 +26,637 @@ } // oxm classes - identity oxm-class-base { - description "Base identity for OXM classes"; - } + identity oxm-class-base { + description "Base identity for OXM classes"; + } - identity nxm-0-class { - description "Match class for backward compatibility with NXM"; - base oxm-class-base; - } - identity nxm-1-class { - description "Match class for backward compatibility with NXM"; - base oxm-class-base; - } - identity openflow-basic-class { - description "Basic class for OpenFlow"; - base oxm-class-base; - } - identity experimenter-class { - description - "Marks Experimenter match type class. - All experimenter match classes MUST use this class as a base."; - base oxm-class-base; - } + identity nxm-0-class { + description "Match class for backward compatibility with NXM"; + base oxm-class-base; + } + identity nxm-1-class { + description "Match class for backward compatibility with NXM"; + base oxm-class-base; + } + identity openflow-basic-class { + description "Basic class for OpenFlow"; + base oxm-class-base; + } + identity experimenter-class { + description + "Marks Experimenter match type class. + All experimenter match classes MUST use this class as a base."; + base oxm-class-base; + } - // field types - identity match-field { - description "Base identity for OXM Fields"; - } + // match-field types + identity match-field { + description "Base identity for OXM Fields"; + } - identity in_port { - base match-field; - description "OXM field for Switch input port."; - } - identity in_phy_port { - base match-field; - description "OXM field for Switch physical input port."; - } - identity metadata { - base match-field; - description "OXM field for Metadata passed between tables."; - } - identity eth_dst { - base match-field; - description "OXM field for Ethernet destination address."; - } - identity eth_src { - base match-field; - description "OXM field for Ethernet source address."; - } - identity eth_type { - base match-field; - description "OXM field for Ethernet frame type."; - } - identity vlan_vid { - base match-field; - description "OXM field for VLAN id."; - } - identity vlan_pcp { - base match-field; - description "OXM field for VLAN priority."; - } - identity ip_dscp { - base match-field; - description "OXM field for IP DSCP (6 bits in ToS field)."; - } - identity ip_ecn { - base match-field; - description "OXM field for IP ECN (2 bits in ToS field)."; - } - identity ip_proto { - base match-field; - description "OXM field for IP protocol."; - } - identity ipv4_src { - base match-field; - description "OXM field for IPv4 source address."; - } - identity ipv4_dst { - base match-field; - description "OXM field for IPv4 destination address."; - } - identity tcp_src { - base match-field; - description "OXM field for TCP source port."; - } - identity tcp_dst { - base match-field; - description "OXM field for TCP destination port."; - } - identity udp_src { - base match-field; - description "OXM field for UDP source port."; - } - identity udp_dst { - base match-field; - description "OXM field for UDP destination port."; - } - identity sctp_src { - base match-field; - description "OXM field for SCTP source port."; - } - identity sctp_dst { - base match-field; - description "OXM field for SCTP destination port."; - } - identity icmpv4_type { - base match-field; - description "OXM field for ICMP type."; - } - identity icmpv4_code { - base match-field; - description "OXM field for ICMP code."; - } - identity arp_op { - base match-field; - description "OXM field for ARP opcode."; - } - identity arp_spa { - base match-field; - description "OXM field for ARP source IPv4 address."; - } - identity arp_tpa { - base match-field; - description "OXM field for ARP target IPv4 address."; - } - identity arp_sha { - base match-field; - description "OXM field for ARP source hardware address."; - } - identity arp_tha { - base match-field; - description "OXM field for ARP target hardware address."; - } - identity ipv6_src { - base match-field; - description "OXM field for IPv6 source address."; - } - identity ipv6_dst { - base match-field; - description "OXM field for IPv6 destination address."; - } - identity ipv6_flabel { - base match-field; - description "OXM field for IPv6 Flow Label"; - } - identity icmpv6_type { - base match-field; - description "OXM field for ICMPv6 type."; - } - identity icmpv6_code { - base match-field; - description "OXM field for ICMPv6 code."; - } - identity ipv6_nd_target { - base match-field; - description "OXM field for Target address for ND."; - } - identity ipv6_nd_sll { - base match-field; - description "OXM field for Source link-layer for ND."; - } - identity ipv6_nd_tll { - base match-field; - description "OXM field for Target link-layer for ND."; - } - identity mpls_label { - base match-field; - description "OXM field for MPLS label."; - } - identity mpls_tc { - base match-field; - description "OXM field for MPLS TC."; - } - identity mpls_bos { - base match-field; - description "OXM field for MPLS BoS bit."; - } - identity pbb_isid { - base match-field; - description "OXM field for PBB I-SID."; - } - identity tunnel_id { - base match-field; - description "OXM field for Logical Port Metadata"; - } - identity ipv6_exthdr { - base match-field; - description "OXM field for IPv6 Extension Header pseudo-field"; + identity in_port { + base match-field; + description "OXM field for Switch input port."; + } + identity in_phy_port { + base match-field; + description "OXM field for Switch physical input port."; + } + identity metadata { + base match-field; + description "OXM field for Metadata passed between tables."; + } + identity eth_dst { + base match-field; + description "OXM field for Ethernet destination address."; + } + identity eth_src { + base match-field; + description "OXM field for Ethernet source address."; + } + identity eth_type { + base match-field; + description "OXM field for Ethernet frame type."; + } + identity vlan_vid { + base match-field; + description "OXM field for VLAN id."; + } + identity vlan_pcp { + base match-field; + description "OXM field for VLAN priority."; + } + identity ip_dscp { + base match-field; + description "OXM field for IP DSCP (6 bits in ToS field)."; + } + identity ip_ecn { + base match-field; + description "OXM field for IP ECN (2 bits in ToS field)."; + } + identity ip_proto { + base match-field; + description "OXM field for IP protocol."; + } + identity ipv4_src { + base match-field; + description "OXM field for IPv4 source address."; + } + identity ipv4_dst { + base match-field; + description "OXM field for IPv4 destination address."; + } + identity tcp_src { + base match-field; + description "OXM field for TCP source port."; + } + identity tcp_dst { + base match-field; + description "OXM field for TCP destination port."; + } + identity udp_src { + base match-field; + description "OXM field for UDP source port."; + } + identity udp_dst { + base match-field; + description "OXM field for UDP destination port."; + } + identity sctp_src { + base match-field; + description "OXM field for SCTP source port."; + } + identity sctp_dst { + base match-field; + description "OXM field for SCTP destination port."; + } + identity icmpv4_type { + base match-field; + description "OXM field for ICMP type."; + } + identity icmpv4_code { + base match-field; + description "OXM field for ICMP code."; + } + identity arp_op { + base match-field; + description "OXM field for ARP opcode."; + } + identity arp_spa { + base match-field; + description "OXM field for ARP source IPv4 address."; + } + identity arp_tpa { + base match-field; + description "OXM field for ARP target IPv4 address."; + } + identity arp_sha { + base match-field; + description "OXM field for ARP source hardware address."; + } + identity arp_tha { + base match-field; + description "OXM field for ARP target hardware address."; + } + identity ipv6_src { + base match-field; + description "OXM field for IPv6 source address."; + } + identity ipv6_dst { + base match-field; + description "OXM field for IPv6 destination address."; + } + identity ipv6_flabel { + base match-field; + description "OXM field for IPv6 Flow Label"; + } + identity icmpv6_type { + base match-field; + description "OXM field for ICMPv6 type."; + } + identity icmpv6_code { + base match-field; + description "OXM field for ICMPv6 code."; + } + identity ipv6_nd_target { + base match-field; + description "OXM field for Target address for ND."; + } + identity ipv6_nd_sll { + base match-field; + description "OXM field for Source link-layer for ND."; + } + identity ipv6_nd_tll { + base match-field; + description "OXM field for Target link-layer for ND."; + } + identity mpls_label { + base match-field; + description "OXM field for MPLS label."; + } + identity mpls_tc { + base match-field; + description "OXM field for MPLS TC."; + } + identity mpls_bos { + base match-field; + description "OXM field for MPLS BoS bit."; + } + identity pbb_isid { + base match-field; + description "OXM field for PBB I-SID."; + } + identity tunnel_id { + base match-field; + description "OXM field for Logical Port Metadata"; + } + identity ipv6_exthdr { + base match-field; + description "OXM field for IPv6 Extension Header pseudo-field"; + } + + grouping match-grouping { + container match { + description "Match structure (OF v1.3)"; + leaf type { + type identityref { + base oft:match-type-base; + } + } + uses match-entries-grouping; } - identity tcp_flag { - base match-field; - description "NXM field for NXM_NX_TCP_FLAGS"; + } + + grouping match-entries-grouping { + list match-entry { + config false; + uses match-entry-fields-grouping; + uses match-entry-value-grouping; } - identity tunnel_ipv4_dst { - base match-field; - description "NXM field for NXM_NX_TUN_IPV4_DST"; + } + + grouping match-entry-fields-grouping { + leaf oxm-class { + type identityref { + base oxm-class-base; + } } - identity tunnel_ipv4_src { - base match-field; - description "NXM field for NXM_NX_TUN_IPV4_SRC"; + leaf oxm-match-field { + type identityref { + base match-field; + } } - container oxm-container { - uses oxm-fields-grouping; + leaf has-mask { + type boolean; } + } - grouping oxm-fields-grouping { - list match-entries { - description "OXM TLV-structures (Type Length Value)"; - config false; - leaf oxm-class { - type identityref { - base oxm-class-base; + container oxm-container { + uses match-entry-value-grouping; + } + + grouping match-entry-value-grouping { + choice match-entry-value { + case in-port-case { + container in-port { + leaf port-number { + type oft:port-number; } } - leaf oxm-match-field { - type identityref { - base match-field; + } + case in-phy-port-case { + container in-phy-port { + leaf port-number { + type oft:port-number; } } - leaf has-mask { - type boolean; + } + case metadata-case { + container metadata { + leaf metadata { + type binary; + } + leaf mask { + type binary; + } } } - } - - grouping match-grouping { - container match { - description "Match structure (OF v1.3)"; - leaf type { - type identityref { - base oft:match-type-base; + case eth-src-case { + container eth-src { + leaf mac-address { + type yang:mac-address; + } + leaf mask { + type binary; } } - uses oxm-fields-grouping; } - } - - // OF1.0 structures - grouping match-v10-grouping { - container match-v10 { - description "OF v1.0 match structure"; - leaf wildcards { - description "Wildcard fields (only flags)."; - type oft:flow-wildcards-v10; + case eth-dst-case { + container eth-dst { + leaf mac-address { + type yang:mac-address; + } + leaf mask { + type binary; + } } - leaf nw-src-mask { - description "IP source address mask (definition differs from OF v1.0.0 spec to ease - understanding, library does the transformation into OF v1.0 spec correct data)"; - type uint8; + } + case eth-type-case { + container eth-type { + leaf eth-type { + type oft:ether-type; + } } - leaf nw-dst-mask { - description "IP destination address mask (definition differs from OF v1.0.0 spec to ease - understanding, library does the transformation into OF v1.0 spec correct data)"; - type uint8; + } + case vlan-vid-case { + container vlan-vid { + leaf vlan-vid { + type uint16; + } + leaf cfi-bit { + type boolean; + } + leaf mask { + type binary; + } + } + } + case vlan-pcp-case { + container vlan-pcp { + leaf vlan-pcp { + type uint8; + } + } + } + case ip-dscp-case { + container ip-dscp { + leaf dscp { + type inet:dscp; + } + } + } + case ip-ecn-case { + container ip-ecn { + leaf ecn { + type uint8; + } + } + } + case ip-proto-case { + container ip-proto { + leaf protocol-number { + type uint8; + } + } + } + case ipv4-src-case { + container ipv4-src { + leaf ipv4-address { + type inet:ipv4-address; + } + leaf mask { + type binary; + } + } + } + case ipv4-dst-case { + container ipv4-dst { + leaf ipv4-address { + type inet:ipv4-address; + } + leaf mask { + type binary; + } + } + } + case tcp-src-case { + container tcp-src { + leaf port { + type inet:port-number; + } + } + } + case tcp-dst-case { + container tcp-dst { + leaf port { + type inet:port-number; + } + } + } + case udp-src-case { + container udp-src { + leaf port { + type inet:port-number; + } + } + } + case udp-dst-case { + container udp-dst { + leaf port { + type inet:port-number; + } + } + } + case sctp-src-case { + container sctp-src { + leaf port { + type inet:port-number; + } + } + } + case sctp-dst-case { + container sctp-dst { + leaf port { + type inet:port-number; + } + } + } + case icmpv4-type-case { + container icmpv4-type { + leaf icmpv4-type { + type uint8; + } + } + } + case icmpv4-code-case { + container icmpv4-code { + leaf icmpv4-code { + type uint8; + } + } + } + case arp-op-case { + container arp-op { + leaf op-code { + type uint16; + } + } + } + case arp-spa-case { + container arp-spa { + leaf ipv4-address { + type inet:ipv4-address; + } + leaf mask { + type binary; + } + } + } + case arp-tpa-case { + container arp-tpa { + leaf ipv4-address { + type inet:ipv4-address; + } + leaf mask { + type binary; + } + } + } + case arp-sha-case { + container arp-sha { + leaf mac-address { + type yang:mac-address; + } + leaf mask { + type binary; + } } - leaf in-port { - description "Input switch port."; - type uint16; + } + case arp-tha-case { + container arp-tha { + leaf mac-address { + type yang:mac-address; + } + leaf mask { + type binary; + } } - leaf dl-src { - description "Ethernet source address."; - type yang:mac-address; + } + case ipv6-src-case { + container ipv6-src { + leaf ipv6-address { + type inet:ipv6-address; + } + leaf mask { + type binary; + } } - leaf dl-dst { - description "Ethernet destination address."; - type yang:mac-address; + } + case ipv6-dst-case { + container ipv6-dst { + leaf ipv6-address { + type inet:ipv6-address; + } + leaf mask { + type binary; + } } - leaf dl-vlan { - description "Input VLAN id."; - type uint16; + } + case ipv6-flabel-case { + container ipv6-flabel { + leaf ipv6-flabel { + type inet:ipv6-flow-label; + } + leaf mask { + type binary; + } } - leaf dl-vlan-pcp { - description "Input VLAN priority."; - type uint8; + } + case icmpv6-type-case { + container icmpv6-type { + leaf icmpv6-type { + type uint8; + } } - leaf dl-type { - description "Ethernet frame type."; - type uint16; + } + case icmpv6-code-case { + container icmpv6-code { + leaf icmpv6-code { + type uint8; + } } - leaf nw-tos { - description "IP ToS (actually DSCP field, 6 bits)."; - type uint8; + } + case ipv6-nd-target-case { + container ipv6-nd-target { + leaf ipv6-address { + type inet:ipv6-address; + } } - leaf nw-proto { - description "IP protocol or lower 8 bits of ARP opcode."; - type uint8; + } + case ipv6-nd-sll-case { + container ipv6-nd-sll { + leaf mac-address { + type yang:mac-address; + } } - leaf nw-src { - description "IP source address."; - type inet:ipv4-address; + } + case ipv6-nd-tll-case { + container ipv6-nd-tll { + leaf mac-address { + type yang:mac-address; + } } - leaf nw-dst { - description "IP destination address."; - type inet:ipv4-address; + } + case mpls-label-case { + container mpls-label { + leaf mpls-label { + type uint32; + } } - leaf tp-src { - description "TCP/UDP source port."; - type uint16; + } + case mpls-tc-case { + container mpls-tc { + leaf tc { + type uint8; + } } - leaf tp-dst { - description "TCP/UDP destination port."; - type uint16; + } + case mpls-bos-case { + container mpls-bos { + leaf bos { + type boolean; + } + } + } + case pbb-isid-case { + container pbb-isid { + leaf isid { + type uint32; + } + leaf mask { + type binary; + } + } + } + case tunnel-id-case { + container tunnel-id { + leaf tunnel-id { + type binary; + } + leaf mask { + type binary; + } + } + } + case ipv6-exthdr-case { + container ipv6-exthdr { + leaf pseudo-field { + type oft:ipv6-exthdr-flags; + } + leaf mask { + type binary; + } } } } + } + // OF1.0 structures + grouping match-v10-grouping { + container match-v10 { + description "OF v1.0 match structure"; + leaf wildcards { + description "Wildcard fields (only flags)."; + type oft:flow-wildcards-v10; + } + leaf nw-src-mask { + description "IP source address mask (definition differs from OF v1.0.0 spec to ease + understanding, library does the transformation into OF v1.0 spec correct data)"; + type uint8; + } + leaf nw-dst-mask { + description "IP destination address mask (definition differs from OF v1.0.0 spec to ease + understanding, library does the transformation into OF v1.0 spec correct data)"; + type uint8; + } + leaf in-port { + description "Input switch port."; + type uint16; + } + leaf dl-src { + description "Ethernet source address."; + type yang:mac-address; + } + leaf dl-dst { + description "Ethernet destination address."; + type yang:mac-address; + } + leaf dl-vlan { + description "Input VLAN id."; + type uint16; + } + leaf dl-vlan-pcp { + description "Input VLAN priority."; + type uint8; + } + leaf dl-type { + description "Ethernet frame type."; + type uint16; + } + leaf nw-tos { + description "IP ToS (actually DSCP field, 6 bits)."; + type uint8; + } + leaf nw-proto { + description "IP protocol or lower 8 bits of ARP opcode."; + type uint8; + } + leaf nw-src { + description "IP source address."; + type inet:ipv4-address; + } + leaf nw-dst { + description "IP destination address."; + type inet:ipv4-address; + } + leaf tp-src { + description "TCP/UDP source port."; + type uint16; + } + leaf tp-dst { + description "TCP/UDP destination port."; + type uint16; + } + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index 769bfc92..fdf0f38f 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -2,18 +2,12 @@ import org.junit.Assert; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; /** * @author michal.polkorab diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index c3d9cf90..c9c84688 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -76,8 +76,8 @@ public void testEquals() { public void testToString(){ MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" - + " experimenterID: null", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry" + + " msgType: 32768 oxm_field: 42 experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 8bf98fda..fbd5e26a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -11,10 +11,10 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; /** * @author michal.polkorab @@ -99,9 +99,10 @@ public void testToString(){ MatchEntrySerializerKey key1; key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry" + + " oxm_class: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225" + + ".OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow" + + ".oxm.rev150225.InPort experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 92f05827..852ce64f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -37,8 +37,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 0cd70fd8..0ee3fb28 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -18,8 +18,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java index cddf6f2d..e97d2a77 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java index 97c10e5c..94c5dcaf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java @@ -10,11 +10,11 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java index cdbc69e2..46022f0c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java @@ -10,12 +10,12 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java index 9c7476d5..9511a0c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index 9316971e..cec5f70c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index 64707081..0993bbac 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index 925ecfec..79da6a3e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index ac511552..afa3dca0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index 623341a9..33683519 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index dbf147d2..43bbcf5a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index 9e9d54f3..f2f2c0b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -10,12 +10,12 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 190c3b80..5a1a533a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -18,13 +18,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * @author michal.polkorab @@ -53,10 +53,10 @@ public Action deserialize(ByteBuf input) { + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); key.setExperimenterId(expId); } - OFDeserializer matchDeserializer = registry.getDeserializer(key); - List entry = new ArrayList<>(); + OFDeserializer matchDeserializer = registry.getDeserializer(key); + List entry = new ArrayList<>(); entry.add(matchDeserializer.deserialize(input)); - matchEntries.setMatchEntries(entry); + matchEntries.setMatchEntry(entry); builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index 0a22ae73..4f1bb2ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index f247c3a7..8d8915e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -10,10 +10,10 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index 1df22b1b..d71b5d68 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java index 3e736fab..05ababb3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index cbebe33e..1d071396 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -25,16 +25,16 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; @@ -55,8 +55,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; @@ -423,9 +423,9 @@ private List createTableFeaturesProperties(ByteBuf input OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); CodeKeyMaker keyMaker = CodeKeyMakerFactory .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - List entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + List entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java index 72365a7e..b110e2d5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowRemovedMessageFactory.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java index e0110c40..6ca9474e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactory.java @@ -15,8 +15,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 5bb680bc..728a3098 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -28,7 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java index 7b1944a4..44679569 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java index d6090a32..6d6f7747 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactory.java @@ -18,8 +18,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 78d868a0..24950a0d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -14,13 +14,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index 75bf6f50..3e0ebc5f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -15,8 +15,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index 317e69c2..0940aae9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -12,8 +12,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java index 1021987f..fa6c6bb5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index 9412413b..51646b62 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -12,8 +12,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java deleted file mode 100644 index 510b5da3..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv4AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv4AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder(); - ipv4AddressBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java deleted file mode 100644 index ca5ac7ea..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, - EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder(); - ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); - builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java deleted file mode 100644 index aa4b5884..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMacAddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH); - } - return builder.build(); - } - - private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); - builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index 5b9c6ba5..7eb47808 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -11,20 +11,20 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; /** * @author michal.polkorab * */ -public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { +public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { @Override - public MatchEntries deserializeHeader(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + public MatchEntry deserializeHeader(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); return builder.build(); } @@ -47,9 +47,9 @@ public MatchEntries deserializeHeader(ByteBuf input) { * @param input input bytebuf * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation */ - protected MatchEntriesBuilder processHeader(Class oxmClass, + protected MatchEntryBuilder processHeader(Class oxmClass, Class oxmField, ByteBuf input) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(oxmClass); // skip oxm_class (provided) input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java deleted file mode 100644 index 4de031f7..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMetadataAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES); - } - return builder.build(); - } - - private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder(); - byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataBytes); - metadata.setMetadata(metadataBytes); - builder.addAugmentation(MetadataMatchEntry.class, metadata.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java deleted file mode 100644 index 0b3530db..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPortAugmentation(builder, input); - return builder.build(); - } - - private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(input.readUnsignedShort())); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java deleted file mode 100644 index 35895a9b..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); - port.setPortNumber(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortNumberMatchEntry.class, port.build()); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java index 2d438398..ebfa5160 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java @@ -10,33 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder; /** * @author michal.polkorab * */ public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addArpOpAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpOpValue(input, builder); return builder.build(); } - private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); - opcodeBuilder.setOpCode(input.readUnsignedShort()); - builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); + private static void addArpOpValue(ByteBuf input, MatchEntryBuilder builder) { + ArpOpCaseBuilder caseBuilder = new ArpOpCaseBuilder(); + ArpOpBuilder opBuilder = new ArpOpBuilder(); + opBuilder.setOpCode(input.readUnsignedShort()); + caseBuilder.setArpOp(opBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java index b26b9e3a..91b4514e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java @@ -7,16 +7,43 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder; /** * @author michal.polkorab * */ -public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmArpShaDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpShaValue(input, builder); + return builder.build(); + } + + private static void addArpShaValue(ByteBuf input, MatchEntryBuilder builder) { + ArpShaCaseBuilder caseBuilder = new ArpShaCaseBuilder(); + ArpShaBuilder shaBuilder = new ArpShaBuilder(); + shaBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + if (builder.isHasMask()) { + shaBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.MAC_ADDRESS_LENGTH)); + } + caseBuilder.setArpSha(shaBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java index cb83cb24..149ebb0e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder; /** * @author michal.polkorab * */ -public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer { +public class OxmArpSpaDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpSpaValue(input, builder); + return builder.build(); + } + + private static void addArpSpaValue(ByteBuf input, MatchEntryBuilder builder) { + ArpSpaCaseBuilder caseBuilder = new ArpSpaCaseBuilder(); + ArpSpaBuilder arpBuilder = new ArpSpaBuilder(); + arpBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + if (builder.isHasMask()) { + arpBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); + } + caseBuilder.setArpSpa(arpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java index 69ce30a8..0e034c1f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java @@ -7,16 +7,43 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder; /** * @author michal.polkorab * */ -public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmArpThaDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpThaValue(input, builder); + return builder.build(); + } + + private static void addArpThaValue(ByteBuf input, MatchEntryBuilder builder) { + ArpThaCaseBuilder caseBuilder = new ArpThaCaseBuilder(); + ArpThaBuilder thaBuilder = new ArpThaBuilder(); + thaBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + if (builder.isHasMask()) { + thaBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.MAC_ADDRESS_LENGTH)); + } + caseBuilder.setArpTha(thaBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java index dd7b27c9..fdeaddc5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder; /** * @author michal.polkorab * */ -public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer { +public class OxmArpTpaDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpTpaValue(input, builder); + return builder.build(); + } + + private static void addArpTpaValue(ByteBuf input, MatchEntryBuilder builder) { + ArpTpaCaseBuilder caseBuilder = new ArpTpaCaseBuilder(); + ArpTpaBuilder arpBuilder = new ArpTpaBuilder(); + arpBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + if (builder.isHasMask()) { + arpBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); + } + caseBuilder.setArpTpa(arpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java new file mode 100644 index 00000000..1127faea --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; + +/** + * @author michal.polkorab + * + */ +public final class OxmDeserializerHelper { + + private OxmDeserializerHelper() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Converts binary data into binary mask (for match entries) + * @param input input ByteBuf + * @param matchEntryLength mask length + * @return binary mask + */ + public static byte[] convertMask(ByteBuf input, int matchEntryLength) { + byte[] mask = new byte[matchEntryLength]; + input.readBytes(mask); + return mask; + } + + /** + * Converts binary data into mac address + * @param input input ByteBuf + * @return mac address + */ + public static MacAddress convertMacAddress(ByteBuf input) { + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + return new MacAddress(ByteBufUtils.macAddressToString(address)); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java index 9e1e6e20..1229ff13 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java @@ -7,16 +7,43 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder; /** * @author michal.polkorab * */ -public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmEthDstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addEthDstValue(input, builder); + return builder.build(); + } + + private static void addEthDstValue(ByteBuf input, MatchEntryBuilder builder) { + EthDstCaseBuilder caseBuilder = new EthDstCaseBuilder(); + EthDstBuilder ethBuilder = new EthDstBuilder(); + ethBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + if (builder.isHasMask()) { + ethBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.MAC_ADDRESS_LENGTH)); + } + caseBuilder.setEthDst(ethBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java index 3302a650..dc7bb803 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java @@ -7,16 +7,43 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder; /** * @author michal.polkorab * */ -public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmEthSrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addEthSrcValue(input, builder); + return builder.build(); + } + + private static void addEthSrcValue(ByteBuf input, MatchEntryBuilder builder) { + EthSrcCaseBuilder caseBuilder = new EthSrcCaseBuilder(); + EthSrcBuilder ethBuilder = new EthSrcBuilder(); + ethBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + if (builder.isHasMask()) { + ethBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.MAC_ADDRESS_LENGTH)); + } + caseBuilder.setEthSrc(ethBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java index 94d08706..5da869e0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java @@ -10,34 +10,36 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder; /** * @author michal.polkorab * */ public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addEthTypeAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addEthTypeValue(input, builder); return builder.build(); } - private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); - ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); + private static void addEthTypeValue(ByteBuf input, MatchEntryBuilder builder) { + EthTypeCaseBuilder caseBuilder = new EthTypeCaseBuilder(); + EthTypeBuilder ethBuilder = new EthTypeBuilder(); + ethBuilder.setEthType(new EtherType(input.readUnsignedShort())); + caseBuilder.setEthType(ethBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java index 8ac68433..87a35d4e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java @@ -10,34 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder; /** * @author michal.polkorab * */ public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4CodeAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4CodeValue(input, builder); return builder.build(); } - private static void addIcmpv4CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + private static void addIcmpv4CodeValue(ByteBuf input, MatchEntryBuilder builder) { + Icmpv4CodeCaseBuilder caseBuilder = new Icmpv4CodeCaseBuilder(); + Icmpv4CodeBuilder icmpBuilder = new Icmpv4CodeBuilder(); + icmpBuilder.setIcmpv4Code(input.readUnsignedByte()); + caseBuilder.setIcmpv4Code(icmpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java index 4134bb1c..60aedde2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java @@ -10,34 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder; /** * @author michal.polkorab * */ public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4TypeAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4TypeValue(input, builder); return builder.build(); } - private static void addIcmpv4TypeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); + private static void addIcmpv4TypeValue(ByteBuf input, MatchEntryBuilder builder) { + Icmpv4TypeCaseBuilder caseBuilder = new Icmpv4TypeCaseBuilder(); + Icmpv4TypeBuilder icmpBuilder = new Icmpv4TypeBuilder(); + icmpBuilder.setIcmpv4Type(input.readUnsignedByte()); + caseBuilder.setIcmpv4Type(icmpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java index 7cc38f19..52221c78 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java @@ -10,34 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder; /** * @author michal.polkorab * */ public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv6CodeAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv6CodeValue(input, builder); return builder.build(); } - private static void addIcmpv6CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + private static void addIcmpv6CodeValue(ByteBuf input, MatchEntryBuilder builder) { + Icmpv6CodeCaseBuilder caseBuilder = new Icmpv6CodeCaseBuilder(); + Icmpv6CodeBuilder icmpBuilder = new Icmpv6CodeBuilder(); + icmpBuilder.setIcmpv6Code(input.readUnsignedByte()); + caseBuilder.setIcmpv6Code(icmpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java index de155fcb..5d112185 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java @@ -10,31 +10,37 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder; /** * @author michal.polkorab * */ public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv6TypeValue(input, builder); return builder.build(); } + private static void addIcmpv6TypeValue(ByteBuf input, MatchEntryBuilder builder) { + Icmpv6TypeCaseBuilder caseBuilder = new Icmpv6TypeCaseBuilder(); + Icmpv6TypeBuilder icmpBuilder = new Icmpv6TypeBuilder(); + icmpBuilder.setIcmpv6Type(input.readUnsignedByte()); + caseBuilder.setIcmpv6Type(icmpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } + @Override protected Class getOxmField() { return Icmpv6Type.class; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java index 54b826f8..8f44c8f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; /** * @author michal.polkorab * */ -public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer { +public class OxmInPhyPortDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addInPhyPortValue(input, builder); + return builder.build(); + } + + private static void addInPhyPortValue(ByteBuf input, MatchEntryBuilder builder) { + InPhyPortCaseBuilder caseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(input.readUnsignedInt())); + caseBuilder.setInPhyPort(inPhyPortBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java index 342d2a33..3f08f5e9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder; /** * @author michal.polkorab * */ -public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer { +public class OxmInPortDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addInPortValue(input, builder); + return builder.build(); + } + + private static void addInPortValue(ByteBuf input, MatchEntryBuilder builder) { + InPortCaseBuilder caseBuilder = new InPortCaseBuilder(); + InPortBuilder inPortBuilder = new InPortBuilder(); + inPortBuilder.setPortNumber(new PortNumber(input.readUnsignedInt())); + caseBuilder.setInPort(inPortBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index e4880ba9..b18a9de3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -11,33 +11,35 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder; /** * @author michal.polkorab * */ public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpDscpAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpDscpValue(input, builder); return builder.build(); } - private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + private static void addIpDscpValue(ByteBuf input, MatchEntryBuilder builder) { + IpDscpCaseBuilder caseBuilder = new IpDscpCaseBuilder(); + IpDscpBuilder dscpBuilder = new IpDscpBuilder(); dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + caseBuilder.setIpDscp(dscpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java index 150c6dc6..9dd928d8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java @@ -10,33 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; /** * @author michal.polkorab * */ public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpEcnAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpEcnValue(input, builder); return builder.build(); } - private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); + private static void addIpEcnValue(ByteBuf input, MatchEntryBuilder builder) { + IpEcnCaseBuilder caseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ecnBuilder = new IpEcnBuilder(); ecnBuilder.setEcn(input.readUnsignedByte()); - builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + caseBuilder.setIpEcn(ecnBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java index 9e67af39..4861841d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java @@ -10,33 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder; /** * @author michal.polkorab * */ public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpProtoAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpProtoValue(input, builder); return builder.build(); } - private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); - protoNumberBuilder.setProtocolNumber(input.readUnsignedByte()); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); + private static void addIpProtoValue(ByteBuf input, MatchEntryBuilder builder) { + IpProtoCaseBuilder caseBuilder = new IpProtoCaseBuilder(); + IpProtoBuilder protoBuilder = new IpProtoBuilder(); + protoBuilder.setProtocolNumber(input.readUnsignedByte()); + caseBuilder.setIpProto(protoBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java index 9939fed9..d0e5fc1a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder; /** * @author michal.polkorab * */ -public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { +public class OxmIpv4DstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv4DstValue(input, builder); + return builder.build(); + } + + private static void addIpv4DstValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv4DstCaseBuilder caseBuilder = new Ipv4DstCaseBuilder(); + Ipv4DstBuilder ipv4Builder = new Ipv4DstBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + if (builder.isHasMask()) { + ipv4Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); + } + caseBuilder.setIpv4Dst(ipv4Builder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java index a84b2fa3..fdd020c6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder; /** * @author michal.polkorab * */ -public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { +public class OxmIpv4SrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv4SrcValue(input, builder); + return builder.build(); + } + + private static void addIpv4SrcValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv4SrcCaseBuilder caseBuilder = new Ipv4SrcCaseBuilder(); + Ipv4SrcBuilder ipv4Builder = new Ipv4SrcBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + if (builder.isHasMask()) { + ipv4Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); + } + caseBuilder.setIpv4Src(ipv4Builder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java index 11b5cc3a..364cbaef 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder; /** * @author michal.polkorab * */ -public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer { +public class OxmIpv6DstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6DstValue(input, builder); + return builder.build(); + } + + private static void addIpv6DstValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6DstCaseBuilder caseBuilder = new Ipv6DstCaseBuilder(); + Ipv6DstBuilder ipv6Builder = new Ipv6DstBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + if (builder.isHasMask()) { + ipv6Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES)); + } + caseBuilder.setIpv6Dst(ipv6Builder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index 7267333c..9b17035b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -11,36 +11,43 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder; /** * @author michal.polkorab * */ public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6ExtHdrAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6ExtHdrValue(input, builder); + return builder.build(); + } + + private static void addIpv6ExtHdrValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6ExthdrCaseBuilder caseBuilder = new Ipv6ExthdrCaseBuilder(); + Ipv6ExthdrBuilder extHdrBuilder = new Ipv6ExthdrBuilder(); + extHdrBuilder.setPseudoField(convertPseudofields(input)); if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + extHdrBuilder.setMask(OxmDeserializerHelper + .convertMask(input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES)); } - return builder.build(); + caseBuilder.setIpv6Exthdr(extHdrBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } - private static void addIpv6ExtHdrAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + private static Ipv6ExthdrFlags convertPseudofields(ByteBuf input) { int bitmap = input.readUnsignedShort(); final Boolean nonext = ((bitmap) & (1<<0)) != 0; final Boolean esp = ((bitmap) & (1<<1)) != 0; @@ -51,8 +58,7 @@ private static void addIpv6ExtHdrAugmentation(ByteBuf input, final Boolean hop = ((bitmap) & (1<<6)) != 0; final Boolean unrep = ((bitmap) & (1<<7)) != 0; final Boolean unseq = ((bitmap) & (1<<8)) != 0; - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + return new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index 15c8aa07..9016af5d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -12,37 +12,39 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder; /** * @author michal.polkorab * */ public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6FlabelAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6FlabelValue(input, builder); return builder.build(); } - private static void addIpv6FlabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); - builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); + private static void addIpv6FlabelValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6FlabelCaseBuilder caseBuilder = new Ipv6FlabelCaseBuilder(); + Ipv6FlabelBuilder labelBuilder = new Ipv6FlabelBuilder(); + labelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); + if (builder.isHasMask()) { + labelBuilder.setMask(OxmDeserializerHelper.convertMask(input, + EncodeConstants.SIZE_OF_INT_IN_BYTES)); + } + caseBuilder.setIpv6Flabel(labelBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java index 3ca7b686..ad37cd0e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java @@ -7,16 +7,39 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder; /** * @author michal.polkorab * */ -public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmIpv6NdSllDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6NdSllValue(input, builder); + return builder.build(); + } + + private static void addIpv6NdSllValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6NdSllCaseBuilder caseBuilder = new Ipv6NdSllCaseBuilder(); + Ipv6NdSllBuilder ndBuilder = new Ipv6NdSllBuilder(); + ndBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + caseBuilder.setIpv6NdSll(ndBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java index 5b2543c1..2afd9a50 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java @@ -7,16 +7,41 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder; /** * @author michal.polkorab * */ -public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer { +public class OxmIpv6NdTargetDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6NdTargetValue(input, builder); + return builder.build(); + } + + private static void addIpv6NdTargetValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6NdTargetCaseBuilder caseBuilder = new Ipv6NdTargetCaseBuilder(); + Ipv6NdTargetBuilder ipv6Builder = new Ipv6NdTargetBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + caseBuilder.setIpv6NdTarget(ipv6Builder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java index fabc8d45..449c01ca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java @@ -7,16 +7,39 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder; /** * @author michal.polkorab * */ -public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer { +public class OxmIpv6NdTllDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6NdTllValue(input, builder); + return builder.build(); + } + + private static void addIpv6NdTllValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6NdTllCaseBuilder caseBuilder = new Ipv6NdTllCaseBuilder(); + Ipv6NdTllBuilder ndBuilder = new Ipv6NdTllBuilder(); + ndBuilder.setMacAddress(OxmDeserializerHelper.convertMacAddress(input)); + caseBuilder.setIpv6NdTll(ndBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java index 59152b45..4b486f0b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java @@ -7,16 +7,45 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder; /** * @author michal.polkorab * */ -public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer { +public class OxmIpv6SrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6SrcValue(input, builder); + return builder.build(); + } + + private static void addIpv6SrcValue(ByteBuf input, MatchEntryBuilder builder) { + Ipv6SrcCaseBuilder caseBuilder = new Ipv6SrcCaseBuilder(); + Ipv6SrcBuilder ipv6Builder = new Ipv6SrcBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + if (builder.isHasMask()) { + ipv6Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES)); + } + caseBuilder.setIpv6Src(ipv6Builder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java deleted file mode 100644 index ff8b7ff0..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public final class OxmMaskDeserializer { - - private OxmMaskDeserializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Appends mask to match entry (match entry builder) - * @param builder builder which the mask will append to - * @param input input ByteBuf - * @param matchEntryLength mask length - */ - public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input, - int matchEntryLength) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - byte[] mask = new byte[matchEntryLength]; - input.readBytes(mask); - maskBuilder.setMask(mask); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java index ae34635b..0f16de8a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java @@ -7,16 +7,46 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder; /** * @author michal.polkorab * */ -public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer { +public class OxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMetadataValue(input, builder); + return builder.build(); + } + + private static void addMetadataValue(ByteBuf input, MatchEntryBuilder builder) { + MetadataCaseBuilder caseBuilder = new MetadataCaseBuilder(); + MetadataBuilder metadataBuilder = new MetadataBuilder(); + byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataBytes); + metadataBuilder.setMetadata(metadataBytes); + if (builder.isHasMask()) { + metadataBuilder.setMask(OxmDeserializerHelper + .convertMask(input, EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + } + caseBuilder.setMetadata(metadataBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java index 65ebac39..ec68bef8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java @@ -10,39 +10,39 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder; /** * @author michal.polkorab * */ public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsBosDeserializer(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsBosValue(input, builder); return builder.build(); } - - private static void addMplsBosDeserializer(ByteBuf input, - MatchEntriesBuilder builder) { - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + private static void addMplsBosValue(ByteBuf input, MatchEntryBuilder builder) { + MplsBosCaseBuilder caseBuilder = new MplsBosCaseBuilder(); + MplsBosBuilder bosBuilder = new MplsBosBuilder(); if (input.readUnsignedByte() != 0) { bosBuilder.setBos(true); } else { bosBuilder.setBos(false); } - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + caseBuilder.setMplsBos(bosBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java index d7c4fe4f..afc41d27 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java @@ -10,34 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder; /** * @author michal.polkorab * */ public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer -implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsLabelAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsLabelValue(input, builder); return builder.build(); } - private static void addMplsLabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); - mplsLabelBuilder.setMplsLabel(input.readUnsignedInt()); - builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); + private static void addMplsLabelValue(ByteBuf input, MatchEntryBuilder builder) { + MplsLabelCaseBuilder caseBuilder = new MplsLabelCaseBuilder(); + MplsLabelBuilder labelBuilder = new MplsLabelBuilder(); + labelBuilder.setMplsLabel(input.readUnsignedInt()); + caseBuilder.setMplsLabel(labelBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java index 10cb8d28..ed77c902 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java @@ -10,34 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder; /** * @author michal.polkorab * */ public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsTcAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsTcValue(input, builder); return builder.build(); } - private static void addMplsTcAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + private static void addMplsTcValue(ByteBuf input, MatchEntryBuilder builder) { + MplsTcCaseBuilder caseBuilder = new MplsTcCaseBuilder(); + MplsTcBuilder tcBuilder = new MplsTcBuilder(); tcBuilder.setTc(input.readUnsignedByte()); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + caseBuilder.setMplsTc(tcBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java index e400ba36..5c5b1592 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java @@ -11,38 +11,40 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder; /** * @author michal.polkorab * */ public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPbbIsidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES); - } + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addPbbIsidValue(input, builder); return builder.build(); } - private static void addPbbIsidAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + private static void addPbbIsidValue(ByteBuf input, MatchEntryBuilder builder) { + PbbIsidCaseBuilder caseBuilder = new PbbIsidCaseBuilder(); + PbbIsidBuilder isidBuilder = new PbbIsidBuilder(); Integer isid = input.readUnsignedMedium(); isidBuilder.setIsid(isid.longValue()); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + if (builder.isHasMask()) { + isidBuilder.setMask(OxmDeserializerHelper + .convertMask(input, EncodeConstants.SIZE_OF_3_BYTES)); + } + caseBuilder.setPbbIsid(isidBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index 0985b752..bbc137d5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder; /** * @author michal.polkorab * */ -public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer { +public class OxmSctpDstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addSctpDstValue(input, builder); + return builder.build(); + } + + private static void addSctpDstValue(ByteBuf input, MatchEntryBuilder builder) { + SctpDstCaseBuilder caseBuilder = new SctpDstCaseBuilder(); + SctpDstBuilder sctpBuilder = new SctpDstBuilder(); + sctpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setSctpDst(sctpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index 087e86b0..4a46edfd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder; /** * @author michal.polkorab * */ -public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer { +public class OxmSctpSrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addSctpSrcValue(input, builder); + return builder.build(); + } + + private static void addSctpSrcValue(ByteBuf input, MatchEntryBuilder builder) { + SctpSrcCaseBuilder caseBuilder = new SctpSrcCaseBuilder(); + SctpSrcBuilder sctpBuilder = new SctpSrcBuilder(); + sctpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setSctpSrc(sctpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index 1ab75029..55769578 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder; /** * @author michal.polkorab * */ -public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer { +public class OxmTcpDstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addTcpDstValue(input, builder); + return builder.build(); + } + + private static void addTcpDstValue(ByteBuf input, MatchEntryBuilder builder) { + TcpDstCaseBuilder caseBuilder = new TcpDstCaseBuilder(); + TcpDstBuilder tcpBuilder = new TcpDstBuilder(); + tcpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setTcpDst(tcpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { @@ -27,4 +51,5 @@ protected Class getOxmField() { protected Class getOxmClass() { return OpenflowBasicClass.class; } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index e1509dc7..57f44d16 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder; /** * @author michal.polkorab * */ -public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer { +public class OxmTcpSrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addTcpSrcValue(input, builder); + return builder.build(); + } + + private static void addTcpSrcValue(ByteBuf input, MatchEntryBuilder builder) { + TcpSrcCaseBuilder caseBuilder = new TcpSrcCaseBuilder(); + TcpSrcBuilder tcpBuilder = new TcpSrcBuilder(); + tcpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setTcpSrc(tcpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java index 84a407af..86e1865b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java @@ -7,16 +7,46 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder; /** * @author michal.polkorab * */ -public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer { +public class OxmTunnelIdDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addTunnelIdValue(input, builder); + return builder.build(); + } + + private static void addTunnelIdValue(ByteBuf input, MatchEntryBuilder builder) { + TunnelIdCaseBuilder caseBuilder = new TunnelIdCaseBuilder(); + TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder(); + byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataBytes); + tunnelIdBuilder.setTunnelId(metadataBytes); + if (builder.isHasMask()) { + tunnelIdBuilder.setMask(OxmDeserializerHelper + .convertMask(input, EncodeConstants.SIZE_OF_LONG_IN_BYTES)); + } + caseBuilder.setTunnelId(tunnelIdBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index 01d37beb..b631c815 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder; /** * @author michal.polkorab * */ -public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer { +public class OxmUdpDstDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addUdpDstValue(input, builder); + return builder.build(); + } + + private static void addUdpDstValue(ByteBuf input, MatchEntryBuilder builder) { + UdpDstCaseBuilder caseBuilder = new UdpDstCaseBuilder(); + UdpDstBuilder udpBuilder = new UdpDstBuilder(); + udpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setUdpDst(udpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index d4da0752..29c722d8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -7,16 +7,40 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder; /** * @author michal.polkorab * */ -public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer { +public class OxmUdpSrcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addUdpSrcValue(input, builder); + return builder.build(); + } + + private static void addUdpSrcValue(ByteBuf input, MatchEntryBuilder builder) { + UdpSrcCaseBuilder caseBuilder = new UdpSrcCaseBuilder(); + UdpSrcBuilder udpBuilder = new UdpSrcBuilder(); + udpBuilder.setPort(new PortNumber(input.readUnsignedShort())); + caseBuilder.setUdpSrc(udpBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + } @Override protected Class getOxmField() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java index 332fa751..28c60783 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java @@ -10,33 +10,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder; /** * @author michal.polkorab * */ public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanPcpAugmentation(input, builder); + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanPcpValue(input, builder); return builder.build(); } - private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); - vlanPcpBuilder.setVlanPcp(input.readUnsignedByte()); - builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); + private static void addVlanPcpValue(ByteBuf input, MatchEntryBuilder builder) { + VlanPcpCaseBuilder caseBuilder = new VlanPcpCaseBuilder(); + VlanPcpBuilder vlanBuilder = new VlanPcpBuilder(); + vlanBuilder.setVlanPcp(input.readUnsignedByte()); + caseBuilder.setVlanPcp(vlanBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index 0508dbab..7292e61f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -11,38 +11,41 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder; /** * @author michal.polkorab * */ public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { + implements OFDeserializer { @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanVidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - } + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanVidValue(input, builder); return builder.build(); } - private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); + private static void addVlanVidValue(ByteBuf input, MatchEntryBuilder builder) { + VlanVidCaseBuilder caseBuilder = new VlanVidCaseBuilder(); + VlanVidBuilder vlanBuilder = new VlanVidBuilder(); int vidEntryValue = input.readUnsignedShort(); - vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit - vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit - builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); + vlanBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit + vlanBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit + if (builder.isHasMask()) { + vlanBuilder.setMask(OxmDeserializerHelper + .convertMask(input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES)); + } + caseBuilder.setVlanVid(vlanBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 027b8006..55d92239 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -50,51 +50,47 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; /** * Initializes serializer registry with match entry serializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index e1f2d447..26cdda1a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -18,8 +18,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializer; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java index 33858e33..57f3ae43 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java index fd7c4b5f..cbc37908 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java index 770d1892..cfc6088e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java index 194669a8..3e179228 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index 59ec7d61..4b087681 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java index 38e45587..83396c9e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index c75335c2..20365dbb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 973d026c..1a7683b4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index afe000c9..e9aac905 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java index 6e87760a..86627899 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 0b6c5658..001cf46e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 65eefec9..3e1e77f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -16,12 +16,12 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * @author michal.polkorab @@ -39,16 +39,16 @@ public void serialize(Action action, ByteBuf outBuffer) { int lengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); - MatchEntries entry = oxmField.getMatchEntries().get(0); + MatchEntry entry = oxmField.getMatchEntry().get(0); MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); + ExperimenterIdCase experimenterIdCase = (ExperimenterIdCase) entry.getMatchEntryValue(); + key.setExperimenterId(experimenterIdCase.getExperimenter().getExperimenter().getValue()); } else { key.setExperimenterId(null); } - OFSerializer serializer = registry.getSerializer(key); + OFSerializer serializer = registry.getSerializer(key); serializer.serialize(entry, outBuffer); int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index db740a4a..a47a6a1a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index 70796dc5..8b36e7c0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java index 4586b926..aa8e9f51 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 7c5cd03a..79f831ba 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -15,13 +15,13 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java index 1da3fb3c..770c0cfd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -18,7 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMeterBand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 29e5fd2c..b374bef5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -22,20 +22,20 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; @@ -401,10 +401,10 @@ private void writeOxmRelatedTableProperty(final ByteBuf output, output.writeShort(code); int lengthIndex = output.writerIndex(); output.writeShort(EncodeConstants.EMPTY_LENGTH); - List entries = property. - getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntries(); + List entries = property. + getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntry(); if (entries != null) { - TypeKeyMaker keyMaker = TypeKeyMakerFactory + TypeKeyMaker keyMaker = TypeKeyMakerFactory .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); ListSerializer.serializeHeaderList(entries, keyMaker, registry, output); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index 6ed067fe..f7f8448c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -14,14 +14,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index 2684f042..ca81ef13 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -17,9 +17,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 217fb120..965f6eef 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -15,11 +15,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 9e18a12f..47c7c43c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java index 5a8f5ab8..1387d1e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 43d3e27a..3b407fdc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index 4ce543e6..ea9d0a5c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -10,8 +10,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; /** * Parent for Ipv4 address based match entry serializers @@ -19,16 +17,8 @@ */ public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - writeIpv4Address(entry, outBuffer); - writeMask(entry, outBuffer, getValueLength()); - } - - private static void writeIpv4Address(final MatchEntries entry, final ByteBuf out) { - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue()); + protected static void writeIpv4Address(String address, final ByteBuf out) { + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER.split(address); for (String group : addressGroups) { out.writeByte(Short.parseShort(group)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index 496505b8..9fa730bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -13,10 +13,8 @@ import java.util.Arrays; import java.util.List; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.openflowjava.util.ByteBufUtils; import com.google.common.collect.Lists; @@ -26,10 +24,7 @@ */ public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue(); + protected void writeIpv6Address(String textAddress, final ByteBuf outBuffer) { List address; if (textAddress.equals("::")) { String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; @@ -41,7 +36,6 @@ public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { for (String group : address) { outBuffer.writeShort(Integer.parseInt(group, 16)); } - writeMask(entry, outBuffer, getValueLength()); } private static List parseIpv6Address(final List addressGroups) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index 51b62df9..a665eb79 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -10,8 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; /** * Parent for MAC address based match entry serializers @@ -19,11 +18,7 @@ */ public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(macAddress)); // 48 b + mask [OF 1.3.2 spec] - writeMask(entry, outBuffer, getValueLength()); + protected void writeMacAddress(MacAddress address, ByteBuf outBuffer) { + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(address.getValue())); // 48 b + mask [OF 1.3.2 spec] } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java index 5c669647..d2b96e20 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java @@ -11,37 +11,33 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * Parent for all match entry serializers * @author michal.polkorab */ public abstract class AbstractOxmMatchEntrySerializer - implements OFSerializer, HeaderSerializer{ + implements OFSerializer, HeaderSerializer{ @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { serializeHeader(entry, outBuffer); } @Override - public void serializeHeader(MatchEntries entry, ByteBuf outBuffer) { + public void serializeHeader(MatchEntry entry, ByteBuf outBuffer) { outBuffer.writeShort(getOxmClassCode()); writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), getValueLength()); } - protected static void writeMask(MatchEntries entry, ByteBuf out, int length) { - if (entry.isHasMask()) { - byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask(); - if (mask != null && mask.length != length) { - throw new IllegalArgumentException("incorrect length of mask: "+ - mask.length + ", expected: " + length); - } - out.writeBytes(mask); + protected static void writeMask(byte[] mask, ByteBuf out, int length) { + if (mask != null && mask.length != length) { + throw new IllegalArgumentException("incorrect length of mask: "+ + mask.length + ", expected: " + length); } + out.writeBytes(mask); } protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java deleted file mode 100644 index b3fedcc6..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for metadata based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); - writeMask(entry, outBuffer, getValueLength()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java deleted file mode 100644 index 394d8c40..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(32-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortNumberSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java deleted file mode 100644 index 9dd6a55f..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(16-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java index 1a37f284..c9ca7967 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode()); + ArpOpCase entryValue = (ArpOpCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getArpOp().getOpCode()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java index d4e8c3c0..13903be3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase; /** * @author michal.polkorab @@ -16,6 +20,16 @@ */ public class OxmArpShaSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + ArpShaCase entryValue = (ArpShaCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getArpSha().getMacAddress(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getArpSha().getMask(), outBuffer, EncodeConstants.MAC_ADDRESS_LENGTH); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java index 505cf052..6bdff69a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + ArpSpaCase entryValue = (ArpSpaCase) entry.getMatchEntryValue(); + writeIpv4Address(entryValue.getArpSpa().getIpv4Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getArpSpa().getMask(), outBuffer, + EncodeConstants.GROUPS_IN_IPV4_ADDRESS); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java index 531b21c6..8ed15f75 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase; /** * @author michal.polkorab @@ -16,6 +20,16 @@ */ public class OxmArpThaSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + ArpThaCase entryValue = (ArpThaCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getArpTha().getMacAddress(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getArpTha().getMask(), outBuffer, EncodeConstants.MAC_ADDRESS_LENGTH); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java index ec6ee771..32ce8ffc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + ArpTpaCase entryValue = (ArpTpaCase) entry.getMatchEntryValue(); + writeIpv4Address(entryValue.getArpTpa().getIpv4Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getArpTpa().getMask(), outBuffer, + EncodeConstants.GROUPS_IN_IPV4_ADDRESS); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java index c6c07bad..c34299f5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCase; /** * @author michal.polkorab @@ -16,6 +20,16 @@ */ public class OxmEthDstSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + EthDstCase entryValue = (EthDstCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getEthDst().getMacAddress(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getEthDst().getMask(), outBuffer, EncodeConstants.MAC_ADDRESS_LENGTH); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java index 5a2df0a8..5efe5b29 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCase; /** * @author michal.polkorab @@ -16,6 +20,16 @@ */ public class OxmEthSrcSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + EthSrcCase entryValue = (EthSrcCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getEthSrc().getMacAddress(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getEthSrc().getMask(), outBuffer, EncodeConstants.MAC_ADDRESS_LENGTH); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java index 6bd7b575..58ee4503 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmEthTypeSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue()); + EthTypeCase entryValue = (EthTypeCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getEthType().getEthType().getValue().shortValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java index 664b68b0..ad80424c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code()); + Icmpv4CodeCase entryValue = (Icmpv4CodeCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIcmpv4Code().getIcmpv4Code()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java index 6ae6dfaa..46190709 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type()); + Icmpv4TypeCase entryValue = (Icmpv4TypeCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIcmpv4Type().getIcmpv4Type()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java index 7e38d36f..6b5daf81 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code()); + Icmpv6CodeCase entryValue = (Icmpv6CodeCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIcmpv6Code().getIcmpv6Code()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java index adc06c22..abf5227a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type()); + Icmpv6TypeCase entryValue = (Icmpv6TypeCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIcmpv6Type().getIcmpv6Type()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java index 7e6d7a86..cc22a341 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase; /** * @author michal.polkorab * */ -public class OxmInPhyPortSerializer extends AbstractOxmPortNumberSerializer { +public class OxmInPhyPortSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + InPhyPortCase entryValue = (InPhyPortCase) entry.getMatchEntryValue(); + outBuffer.writeInt(entryValue.getInPhyPort().getPortNumber().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java index 7a3422e0..4fbae264 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase; /** * @author michal.polkorab * */ -public class OxmInPortSerializer extends AbstractOxmPortNumberSerializer { +public class OxmInPortSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + InPortCase entryValue = (InPortCase) entry.getMatchEntryValue(); + outBuffer.writeInt(entryValue.getInPort().getPortNumber().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java index d2cb0416..f06cd690 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue()); + IpDscpCase entryValue = (IpDscpCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIpDscp().getDscp().getValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java index 3270eeea..2edd06ac 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn()); + IpEcnCase entryValue = (IpEcnCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIpEcn().getEcn()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java index d24c0f87..a9b4871b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber()); + IpProtoCase entryValue = (IpProtoCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getIpProto().getProtocolNumber()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java index a7d23c94..4a3ba4cb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv4DstCase entryValue = (Ipv4DstCase) entry.getMatchEntryValue(); + writeIpv4Address(entryValue.getIpv4Dst().getIpv4Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getIpv4Dst().getMask(), outBuffer, + EncodeConstants.GROUPS_IN_IPV4_ADDRESS); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java index 4b8ddbc7..08bca868 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv4SrcCase entryValue = (Ipv4SrcCase) entry.getMatchEntryValue(); + writeIpv4Address(entryValue.getIpv4Src().getIpv4Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getIpv4Src().getMask(), outBuffer, + EncodeConstants.GROUPS_IN_IPV4_ADDRESS); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java index cc892b8d..0e749610 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmIpv6DstSerializer extends AbstractOxmIpv6AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6DstCase entryValue = (Ipv6DstCase) entry.getMatchEntryValue(); + writeIpv6Address(entryValue.getIpv6Dst().getIpv6Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getIpv6Dst().getMask(), outBuffer, + EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java index fa7ef802..d60c392d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java @@ -9,12 +9,12 @@ import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase; /** * @author michal.polkorab @@ -23,9 +23,10 @@ public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField(); + Ipv6ExthdrCase entryValue = (Ipv6ExthdrCase) entry.getMatchEntryValue(); + Ipv6ExthdrFlags pseudoField = entryValue.getIpv6Exthdr().getPseudoField(); int bitmap = ByteBufUtils.fillBitMask(0, pseudoField.isNonext(), pseudoField.isEsp(), @@ -37,7 +38,9 @@ public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { pseudoField.isUnrep(), pseudoField.isUnseq()); outBuffer.writeShort(bitmap); - writeMask(entry, outBuffer, getValueLength()); + if (entry.isHasMask()) { + outBuffer.writeBytes(entryValue.getIpv6Exthdr().getMask()); + } } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java index bb6c0450..4f86b252 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase; /** * @author michal.polkorab @@ -21,10 +21,13 @@ public class OxmIpv6FlabelSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - writeMask(entry, outBuffer, getValueLength()); + Ipv6FlabelCase entryValue = (Ipv6FlabelCase) entry.getMatchEntryValue(); + outBuffer.writeInt(entryValue.getIpv6Flabel().getIpv6Flabel().getValue().intValue()); + if (entry.isHasMask()) { + writeMask(entryValue.getIpv6Flabel().getMask(), outBuffer, EncodeConstants.SIZE_OF_INT_IN_BYTES); + } } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java index f5952b8b..31441503 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCase; /** * @author michal.polkorab @@ -16,6 +20,13 @@ */ public class OxmIpv6NdSllSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6NdSllCase entryValue = (Ipv6NdSllCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getIpv6NdSll().getMacAddress(), outBuffer); + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java index a8f32b11..cb5bd7ca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCase; /** * @author michal.polkorab @@ -16,6 +20,13 @@ */ public class OxmIpv6NdTargetSerializer extends AbstractOxmIpv6AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6NdTargetCase entryValue = (Ipv6NdTargetCase) entry.getMatchEntryValue(); + writeIpv6Address(entryValue.getIpv6NdTarget().getIpv6Address().getValue(), outBuffer); + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java index e215a2f3..3e5a17ad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCase; /** * @author michal.polkorab @@ -16,6 +20,13 @@ */ public class OxmIpv6NdTllSerializer extends AbstractOxmMacAddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6NdTllCase entryValue = (Ipv6NdTllCase) entry.getMatchEntryValue(); + writeMacAddress(entryValue.getIpv6NdTll().getMacAddress(), outBuffer); + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java index 9aeca979..4072b767 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java @@ -7,8 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase; /** * @author michal.polkorab @@ -16,6 +20,17 @@ */ public class OxmIpv6SrcSerializer extends AbstractOxmIpv6AddressSerializer { + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6SrcCase entryValue = (Ipv6SrcCase) entry.getMatchEntryValue(); + writeIpv6Address(entryValue.getIpv6Src().getIpv6Address().getValue(), outBuffer); + if (entry.isHasMask()) { + writeMask(entryValue.getIpv6Src().getMask(), outBuffer, + EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); + } + } + @Override protected int getOxmClassCode() { return OxmMatchConstants.OPENFLOW_BASIC_CLASS; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java index 09099c54..1927e4c8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java @@ -7,14 +7,29 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase; /** * @author michal.polkorab * */ -public class OxmMetadataSerializer extends AbstractOxmMetadataSerializer { +public class OxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + MetadataCase entryValue = (MetadataCase) entry.getMatchEntryValue(); + outBuffer.writeBytes(entryValue.getMetadata().getMetadata()); + if (entry.isHasMask()) { + writeMask(entryValue.getMetadata().getMask(), outBuffer, + EncodeConstants.SIZE_OF_LONG_IN_BYTES); + } + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java index 52e41c93..6e4e3348 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmMplsBosSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue()); + MplsBosCase entryValue = (MplsBosCase) entry.getMatchEntryValue(); + outBuffer.writeBoolean(entryValue.getMplsBos().isBos().booleanValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java index 85ec956b..a22e2089 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmMplsLabelSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); + MplsLabelCase entryValue = (MplsLabelCase) entry.getMatchEntryValue(); + outBuffer.writeInt(entryValue.getMplsLabel().getMplsLabel().intValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java index ff2b6fe4..5abc5b02 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc()); + MplsTcCase entryValue = (MplsTcCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getMplsTc().getTc()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java index 96c24a68..dba3e87e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase; /** * @author michal.polkorab @@ -21,10 +21,13 @@ public class OxmPbbIsidSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - writeMask(entry, outBuffer, getValueLength()); + PbbIsidCase entryValue = (PbbIsidCase) entry.getMatchEntryValue(); + outBuffer.writeMedium(entryValue.getPbbIsid().getIsid().intValue()); + if (entry.isHasMask()) { + writeMask(entryValue.getPbbIsid().getMask(), outBuffer, getValueLength()); + } } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java index 4e3e2738..fe66a7d8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCase; /** * @author michal.polkorab * */ -public class OxmSctpDstSerializer extends AbstractOxmPortSerializer { +public class OxmSctpDstSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + SctpDstCase entryValue = (SctpDstCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getSctpDst().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java index 96629ff1..eea24117 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCase; /** * @author michal.polkorab * */ -public class OxmSctpSrcSerializer extends AbstractOxmPortSerializer { +public class OxmSctpSrcSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + SctpSrcCase entryValue = (SctpSrcCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getSctpSrc().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java index c7b42281..2e91d378 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase; /** * @author michal.polkorab * */ -public class OxmTcpDstSerializer extends AbstractOxmPortSerializer{ +public class OxmTcpDstSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + TcpDstCase entryValue = (TcpDstCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getTcpDst().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java index 0a8a01e7..6d761a1c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase; /** * @author michal.polkorab * */ -public class OxmTcpSrcSerializer extends AbstractOxmPortSerializer { +public class OxmTcpSrcSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + TcpSrcCase entryValue = (TcpSrcCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getTcpSrc().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java index 035bb7ff..aea8545a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java @@ -7,14 +7,29 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase; /** * @author michal.polkorab * */ -public class OxmTunnelIdSerializer extends AbstractOxmMetadataSerializer { +public class OxmTunnelIdSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + TunnelIdCase entryValue = (TunnelIdCase) entry.getMatchEntryValue(); + outBuffer.writeBytes(entryValue.getTunnelId().getTunnelId()); + if (entry.isHasMask()) { + writeMask(entryValue.getTunnelId().getMask(), outBuffer, + EncodeConstants.SIZE_OF_LONG_IN_BYTES); + } + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java index bd4e705f..110dede9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCase; /** * @author michal.polkorab * */ -public class OxmUdpDstSerializer extends AbstractOxmPortSerializer { +public class OxmUdpDstSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + UdpDstCase entryValue = (UdpDstCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getUdpDst().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java index 5929909a..a1db321d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java @@ -7,14 +7,25 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase; /** * @author michal.polkorab * */ -public class OxmUdpSrcSerializer extends AbstractOxmPortSerializer { +public class OxmUdpSrcSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + UdpSrcCase entryValue = (UdpSrcCase) entry.getMatchEntryValue(); + outBuffer.writeShort(entryValue.getUdpSrc().getPort().getValue().intValue()); + } @Override protected int getOxmClassCode() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java index ad7e9643..a344e997 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java @@ -11,8 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase; /** * @author michal.polkorab @@ -21,9 +21,10 @@ public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue()); + VlanPcpCase entryValue = (VlanPcpCase) entry.getMatchEntryValue(); + outBuffer.writeByte(entryValue.getVlanPcp().getVlanPcp()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java index 975cc3d0..0a76f895 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java @@ -11,8 +11,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVid; /** * @author michal.polkorab @@ -21,17 +22,18 @@ public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { + public void serialize(MatchEntry entry, ByteBuf outBuffer) { super.serialize(entry, outBuffer); - VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class); + VlanVid vlanVid = ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid(); int vlanVidValue = vlanVid.getVlanVid(); if (vlanVid.isCfiBit()) { short cfi = 1 << 12; // 13-th bit vlanVidValue = vlanVidValue | cfi; } - outBuffer.writeShort(vlanVidValue); - writeMask(entry, outBuffer, getValueLength()); + if (entry.isHasMask()) { + writeMask(vlanVid.getMask(), outBuffer, getValueLength()); + } } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java index 09cc3119..0a6852de 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializer.java @@ -17,10 +17,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; /** * Deserializes ofp_match (OpenFlow v1.3) and its oxm_fields structures @@ -50,9 +50,9 @@ public Match deserialize(ByteBuf input) { } CodeKeyMaker keyMaker = CodeKeyMakerFactory .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - List entries = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + List entries = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, length - 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES, input, keyMaker, registry); - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); int paddingRemainder = length % EncodeConstants.PADDING; if (paddingRemainder != 0) { input.skipBytes(EncodeConstants.PADDING - paddingRemainder); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 76f1f2ec..1c704bb2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -10,8 +10,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index 645df95c..b0a4f41c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -16,8 +16,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; /** * Deserializes ofp_match (OpenFlow v1.0) structure diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index bff38ae2..830753ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; /** * Serializes ofp_match (OpenFlow v1.0) structure diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index c5b07583..32ecb5de 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -17,12 +17,12 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +47,7 @@ public void serialize(Match match, ByteBuf outBuffer) { serializeType(match, outBuffer); int matchLengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - serializeMatchEntries(match.getMatchEntries(), outBuffer); + serializeMatchEntries(match.getMatchEntry(), outBuffer); // Length of ofp_match (excluding padding) int matchLength = outBuffer.writerIndex() - matchStartIndex; outBuffer.setShort(matchLengthIndex, matchLength); @@ -70,22 +70,22 @@ private static void serializeType(Match match, ByteBuf out) { * @param matchEntries list of match entries (oxm_fields) * @param out output ByteBuf */ - public void serializeMatchEntries(List matchEntries, ByteBuf out) { + public void serializeMatchEntries(List matchEntries, ByteBuf out) { if (matchEntries == null) { LOGGER.debug("Match entries are null"); return; } - for (MatchEntries entry : matchEntries) { + for (MatchEntry entry : matchEntries) { MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); + ExperimenterIdCase entryValue = (ExperimenterIdCase) entry.getMatchEntryValue(); + key.setExperimenterId(entryValue.getExperimenter().getExperimenter().getValue()); } else { key.setExperimenterId(null); } - OFSerializer entrySerializer = registry.getSerializer(key); + OFSerializer entrySerializer = registry.getSerializer(key); entrySerializer.serialize(entry, out); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 37ba6dd9..63563de3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -14,14 +14,14 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** * Creates KeyMakers @@ -38,16 +38,16 @@ private TypeKeyMakerFactory() { * in lookup key * @return lookup key */ - public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { + public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { @Override - public MatchEntrySerializerKey make(MatchEntries entry) { + public MatchEntrySerializerKey make(MatchEntry entry) { MatchEntrySerializerKey key; key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); + ExperimenterIdCase entryValue = (ExperimenterIdCase) entry.getMatchEntryValue(); + key.setExperimenterId(entryValue.getExperimenter().getExperimenter().getValue()); return key; } key.setExperimenterId(null); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index bc1a2718..9f4bbab5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -37,8 +37,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java index de4dad5d..a689db6b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImplTest.java @@ -12,8 +12,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; /** * * @author madamjak diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 351a8726..bad774f4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -21,15 +21,14 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; @@ -47,8 +46,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; @@ -1003,15 +1004,15 @@ public void testMultipartReplyGroupDescBody04(){ Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmClass()); + .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0).getOxmClass()); Assert.assertEquals("Wrong setFieldOXMField", InPort.class, message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0).getOxmMatchField()); + .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0).getOxmMatchField()); - Assert.assertEquals("Wrong setFieldOXMValue", 255, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntries().get(0). - getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + MatchEntry entry = message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0); + Assert.assertEquals("Wrong setFieldOXMValue", 255, ((InPortCase) entry.getMatchEntryValue()) + .getInPort().getPortNumber().getValue().intValue()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java index 322e5d98..c4ccb4e3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java @@ -16,10 +16,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 4a75d0ab..77ac5d91 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -20,9 +20,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java index 9670461f..f8102e5f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryMultiTest.java @@ -19,11 +19,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java index 7cf4df2c..3be61213 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/QueueGetConfigReplyMessageFactoryTest.java @@ -19,11 +19,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index a8652756..4183a352 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -23,7 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java index 2b223ca2..96a7c1c0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java @@ -16,8 +16,8 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java index 3b464f39..6fbdbaa4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java @@ -13,12 +13,11 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase; /** * @author michal.polkorab @@ -35,15 +34,16 @@ public void test() { buffer.skipBytes(4); // skip XID OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), - entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); - Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); + ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField()); + Assert.assertEquals("Wrong entry mask", null, ((Ipv6ExthdrCase) entry.getMatchEntryValue()) + .getIpv6Exthdr().getMask()); Assert.assertTrue("Unread data", buffer.readableBytes() == 0); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java index 17bc3abd..2a08e85e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java @@ -13,10 +13,10 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase; /** * @author michal.polkorab @@ -33,12 +33,34 @@ public void test() { buffer.skipBytes(4); // skip XID OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals("Wrong entry value", 2, - entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + ((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel() + .getIpv6Flabel().getValue().intValue()); + } + + /** + * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} + */ + @Test + public void testWithMask() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 39 08 00 00 00 02 00 00 00 05"); + + buffer.skipBytes(4); // skip XID + OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); + MatchEntry entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + ((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel() + .getIpv6Flabel().getValue().intValue()); + Assert.assertArrayEquals("Wrong entry mask", new byte[]{0, 0, 0, 5}, + ((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel().getMask()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java index c2f61840..d8c60a65 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java @@ -14,10 +14,10 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase; /** * @author michal.polkorab @@ -34,12 +34,12 @@ public void test() { buffer.skipBytes(4); // skip XID OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + ((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMetadata()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java index 728260e2..2756f063 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java @@ -13,10 +13,10 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase; /** * @author michal.polkorab @@ -33,11 +33,12 @@ public void test() { buffer.skipBytes(4); // skip XID OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); + Assert.assertEquals("Wrong entry value", false, + ((MplsBosCase) entry.getMatchEntryValue()).getMplsBos().isBos()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java index ab3e125e..45e4a4fd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java @@ -13,10 +13,10 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase; /** * @author michal.polkorab @@ -33,11 +33,12 @@ public void test() { buffer.skipBytes(4); // skip XID OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + Assert.assertEquals("Wrong entry value", 2, ((PbbIsidCase) entry.getMatchEntryValue()) + .getPbbIsid().getIsid().intValue()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java index 5962ac37..8d2d1828 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java @@ -13,10 +13,10 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase; /** * @author michal.polkorab @@ -33,14 +33,14 @@ public void test() { buffer.skipBytes(4); // skip XID OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); + MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals("Wrong entry value", 10, - entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue()); Assert.assertEquals("Wrong entry value", false, - entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java index 046762fe..abed50d9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImplTest.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OF13MatchSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; /** * diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java index d178fdc2..a186c491 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java @@ -24,17 +24,17 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; /** * @author madamjak @@ -43,7 +43,7 @@ public class OF13SetFieldActionSerializerTest { private SerializerRegistry registry; - @Mock OFSerializer serializerMock; + @Mock OFSerializer serializerMock; /** * Initialize registry and mock @@ -64,17 +64,19 @@ public void test(){ ser.injectSerializerRegistry(registry); ActionBuilder actionBuilder = new ActionBuilder(); long experimenterId = 12L; - ExperimenterIdMatchEntryBuilder expIdMatchBuilder = new ExperimenterIdMatchEntryBuilder(); - expIdMatchBuilder.setExperimenter(new ExperimenterId(experimenterId)); - MatchEntriesBuilder meb = new MatchEntriesBuilder(); + ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder(); + ExperimenterBuilder expBuilder = new ExperimenterBuilder(); + expBuilder.setExperimenter(new ExperimenterId(experimenterId)); + expCaseBuilder.setExperimenter(expBuilder.build()); + MatchEntryBuilder meb = new MatchEntryBuilder(); meb.setOxmClass(ExperimenterClass.class); meb.setOxmMatchField(OxmMatchFieldClass.class); - meb.addAugmentation(ExperimenterIdMatchEntry.class, expIdMatchBuilder.build()); - List matchEntries = new ArrayList<>(); - MatchEntries me = meb.build(); - matchEntries.add(me); + meb.setMatchEntryValue(expCaseBuilder.build()); + List MatchEntry = new ArrayList<>(); + MatchEntry me = meb.build(); + MatchEntry.add(me); OxmFieldsActionBuilder oxmActBuilder = new OxmFieldsActionBuilder(); - oxmActBuilder.setMatchEntries(matchEntries); + oxmActBuilder.setMatchEntry(MatchEntry); actionBuilder.addAugmentation(OxmFieldsAction.class, oxmActBuilder.build()); actionBuilder.setType(SetField.class); MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( @@ -83,7 +85,7 @@ public void test(){ registry.registerSerializer(key, serializerMock); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ser.serialize(actionBuilder.build(), out); - Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntries)Mockito.anyObject(), (ByteBuf)Mockito.anyObject()); + Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry)Mockito.anyObject(), (ByteBuf)Mockito.anyObject()); int lenght = out.readableBytes(); Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort()); Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index a0c39227..f1ba2ca2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -21,23 +21,19 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; @@ -50,13 +46,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; @@ -103,23 +103,27 @@ public void testFlowModInputMessageFactory() throws Exception { builder.setFlags(new FlowModFlags(true, false, true, false, true)); MatchBuilder matchBuilder = new MatchBuilder(); matchBuilder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPhyPort.class); entriesBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(42L)); - entriesBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(42L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); entries.add(entriesBuilder.build()); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpEcn.class); entriesBuilder.setHasMask(false); - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn((short) 4); - entriesBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 4); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); entries.add(entriesBuilder.build()); - matchBuilder.setMatchEntries(entries); + matchBuilder.setMatchEntry(entries); builder.setMatch(matchBuilder.build()); List instructions = new ArrayList<>(); InstructionBuilder insBuilder = new InstructionBuilder(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 0ec4d2f4..579bd379 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -21,16 +21,16 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; @@ -39,7 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 3ce00862..01fe8871 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -20,14 +20,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 464f1c36..da2486c4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -25,7 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index f202caad..189fac23 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -20,12 +20,12 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java index 2f78055b..c4d58dc9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -24,8 +24,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index e8f7f97d..d7a19d20 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -31,18 +31,18 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; @@ -59,13 +59,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; @@ -221,63 +221,63 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPhyPort.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(InPort.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpProto.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(IpEcn.class); entriesBuilder.setHasMask(false); entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); propBuilder = new TableFeaturePropertiesBuilder(); propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); + oxmBuilder.setMatchEntry(entries); propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); properties.add(propBuilder.build()); tableFeaturesBuilder.setTableFeatureProperties(properties); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 412adb56..220a2af5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -26,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java index 955c1221..0fcacef1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -24,8 +24,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java index ab564ee0..322d1786 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmArpOpSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); + MatchEntryBuilder builder = prepareArpOpMatchEntry(1402); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareArpOpHeader(false); + MatchEntryBuilder builder = prepareArpOpHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { - MatchEntriesBuilder builder = prepareArpOpHeader(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(value); - builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + private static MatchEntryBuilder prepareArpOpMatchEntry(int value) { + MatchEntryBuilder builder = prepareArpOpHeader(false); + ArpOpCaseBuilder casebuilder = new ArpOpCaseBuilder(); + ArpOpBuilder valueBuilder = new ArpOpBuilder(); + valueBuilder.setOpCode(value); + casebuilder.setArpOp(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareArpOpHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(ArpOp.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java index 3cd8d886..145772b7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder; /** * @author michal.polkorab @@ -32,14 +30,14 @@ */ public class OxmArpShaSerializerTest { - OxmArpThaSerializer serializer = new OxmArpThaSerializer(); + OxmArpShaSerializer serializer = new OxmArpShaSerializer(); /** * Test correct serialization */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + MatchEntryBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -113,7 +111,7 @@ public void testGetOxmClassCode() { */ @Test public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); } /** @@ -124,23 +122,23 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + ArpShaCaseBuilder casebuilder = new ArpShaCaseBuilder(); + ArpShaBuilder valueBuilder = new ArpShaBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setArpSha(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpTha.class); + builder.setOxmMatchField(ArpSha.class); builder.setHasMask(hasMask); return builder; } @@ -148,7 +146,7 @@ private static MatchEntriesBuilder prepareHeader(boolean hasMask) { private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java index 8f60a449..176595da 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmArpSpaSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + MatchEntryBuilder builder = prepareMatchEntry(false, "10.0.0.1"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + MatchEntryBuilder builder = prepareMatchEntry(true, "120.121.122.0"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + ArpSpaCaseBuilder casebuilder = new ArpSpaCaseBuilder(); + ArpSpaBuilder valueBuilder = new ArpSpaBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0}); } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + valueBuilder.setIpv4Address(new Ipv4Address(value)); + casebuilder.setArpSpa(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(ArpSpa.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java index 1bd15a7b..a753c964 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder; /** * @author michal.polkorab @@ -32,14 +30,14 @@ */ public class OxmArpThaSerializerTest { - OxmArpShaSerializer serializer = new OxmArpShaSerializer(); + OxmArpThaSerializer serializer = new OxmArpThaSerializer(); /** * Test correct serialization */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + MatchEntryBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -113,7 +111,7 @@ public void testGetOxmClassCode() { */ @Test public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); } /** @@ -124,23 +122,23 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + ArpThaCaseBuilder casebuilder = new ArpThaCaseBuilder(); + ArpThaBuilder valueBuilder = new ArpThaBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setArpTha(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpSha.class); + builder.setOxmMatchField(ArpTha.class); builder.setHasMask(hasMask); return builder; } @@ -148,7 +146,7 @@ private static MatchEntriesBuilder prepareHeader(boolean hasMask) { private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); if (hasMask) { assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java index 5122e822..78812111 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmArpTpaSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + MatchEntryBuilder builder = prepareMatchEntry(false, "10.0.0.1"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + MatchEntryBuilder builder = prepareMatchEntry(true, "120.121.122.0"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + ArpTpaCaseBuilder casebuilder = new ArpTpaCaseBuilder(); + ArpTpaBuilder valueBuilder = new ArpTpaBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0}); } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + valueBuilder.setIpv4Address(new Ipv4Address(value)); + casebuilder.setArpTpa(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(ArpTpa.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java index 03116abd..c442608b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmEthDstSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + MatchEntryBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + EthDstCaseBuilder casebuilder = new EthDstCaseBuilder(); + EthDstBuilder valueBuilder = new EthDstBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setEthDst(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(EthDst.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java index 6f143277..263399dc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmEthSrcSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + MatchEntryBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + EthSrcCaseBuilder casebuilder = new EthSrcCaseBuilder(); + EthSrcBuilder valueBuilder = new EthSrcBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setEthSrc(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(EthSrc.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java index 7850358f..9bb5c924 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java @@ -16,12 +16,12 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmEthTypeSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); + MatchEntryBuilder builder = prepareEthTypeMatchEntry(65535); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); + MatchEntryBuilder builder = prepareEthTypeHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,17 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); - EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); - typeBuilder.setEthType(new EtherType(type)); - builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); + private static MatchEntryBuilder prepareEthTypeMatchEntry(int type) { + MatchEntryBuilder builder = prepareEthTypeHeader(false); + EthTypeCaseBuilder casebuilder = new EthTypeCaseBuilder(); + EthTypeBuilder valueBuilder = new EthTypeBuilder(); + valueBuilder.setEthType(new EtherType(type)); + casebuilder.setEthType(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareEthTypeHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(EthType.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java index 8afa0c1c..6004776e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmIcmpv4CodeSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); + MatchEntryBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + MatchEntryBuilder builder = prepareIcmpv4CodeHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,17 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Code(value); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); + private static MatchEntryBuilder prepareIcmpv4CodeMatchEntry(short value) { + MatchEntryBuilder builder = prepareIcmpv4CodeHeader(false); + Icmpv4CodeCaseBuilder casebuilder = new Icmpv4CodeCaseBuilder(); + Icmpv4CodeBuilder valueBuilder = new Icmpv4CodeBuilder(); + valueBuilder.setIcmpv4Code(value); + casebuilder.setIcmpv4Code(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIcmpv4CodeHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Icmpv4Code.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java index 23df28c8..d62c4568 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmIcmpv4TypeSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); + MatchEntryBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + MatchEntryBuilder builder = prepareIcmpv4TypeHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,17 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Type(value); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); + private static MatchEntryBuilder prepareIcmpv4TypeMatchEntry(short value) { + MatchEntryBuilder builder = prepareIcmpv4TypeHeader(false); + Icmpv4TypeCaseBuilder casebuilder = new Icmpv4TypeCaseBuilder(); + Icmpv4TypeBuilder valueBuilder = new Icmpv4TypeBuilder(); + valueBuilder.setIcmpv4Type(value); + casebuilder.setIcmpv4Type(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIcmpv4TypeHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Icmpv4Type.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java index 410fa4aa..6706a9d2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmIcmpv6CodeSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); + MatchEntryBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + MatchEntryBuilder builder = prepareIcmpv6CodeHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Code(value); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); + private static MatchEntryBuilder prepareIcmpv6CodeMatchEntry(short value) { + MatchEntryBuilder builder = prepareIcmpv6CodeHeader(false); + Icmpv6CodeCaseBuilder casebuilder = new Icmpv6CodeCaseBuilder(); + Icmpv6CodeBuilder valueBuilder = new Icmpv6CodeBuilder(); + valueBuilder.setIcmpv6Code(value); + casebuilder.setIcmpv6Code(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIcmpv6CodeHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Icmpv6Code.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java index c97a7d42..7f0ad5fb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmIcmpv6TypeSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); + MatchEntryBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + MatchEntryBuilder builder = prepareIcmpv6TypeHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,17 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Type(value); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); + private static MatchEntryBuilder prepareIcmpv6TypeMatchEntry(short value) { + MatchEntryBuilder builder = prepareIcmpv6TypeHeader(false); + Icmpv6TypeCaseBuilder casebuilder = new Icmpv6TypeCaseBuilder(); + Icmpv6TypeBuilder valueBuilder = new Icmpv6TypeBuilder(); + valueBuilder.setIcmpv6Type(value); + casebuilder.setIcmpv6Type(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIcmpv6TypeHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Icmpv6Type.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java index 9fdd7dda..527252b8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmIpDscpSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); + MatchEntryBuilder builder = prepareIpDscpMatchEntry((short) 58); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); + MatchEntryBuilder builder = prepareIpDscpHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + private static MatchEntryBuilder prepareIpDscpMatchEntry(short value) { + MatchEntryBuilder builder = prepareIpDscpHeader(false); + IpDscpCaseBuilder casebuilder = new IpDscpCaseBuilder(); + IpDscpBuilder dscpBuilder = new IpDscpBuilder(); dscpBuilder.setDscp(new Dscp(value)); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + casebuilder.setIpDscp(dscpBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIpDscpHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(IpDscp.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java index 21e2deaf..6edde4de 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmIpProtoSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry((short) 123); + MatchEntryBuilder builder = prepareMatchEntry((short) 123); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(short value) { - MatchEntriesBuilder builder = prepareHeader(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + private static MatchEntryBuilder prepareMatchEntry(short value) { + MatchEntryBuilder builder = prepareHeader(false); + IpProtoCaseBuilder casebuilder = new IpProtoCaseBuilder(); + IpProtoBuilder protoBuilder = new IpProtoBuilder(); protoBuilder.setProtocolNumber(value); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + casebuilder.setIpProto(protoBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(IpProto.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java index 7cb8db66..e4c184f9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmIpv4DstSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + MatchEntryBuilder builder = prepareMatchEntry(false, "10.0.0.1"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + MatchEntryBuilder builder = prepareMatchEntry(true, "120.121.122.0"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + Ipv4DstCaseBuilder casebuilder = new Ipv4DstCaseBuilder(); + Ipv4DstBuilder valueBuilder = new Ipv4DstBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0}); } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + valueBuilder.setIpv4Address(new Ipv4Address(value)); + casebuilder.setIpv4Dst(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Ipv4Dst.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java index 6ea93c2a..c1c8f9eb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmIpv4SrcSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + MatchEntryBuilder builder = prepareMatchEntry(false, "10.0.0.1"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + MatchEntryBuilder builder = prepareMatchEntry(true, "120.121.122.0"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -77,7 +75,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -91,7 +89,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -124,21 +122,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + Ipv4SrcCaseBuilder casebuilder = new Ipv4SrcCaseBuilder(); + Ipv4SrcBuilder valueBuilder = new Ipv4SrcBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15, 0, 0}); } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + valueBuilder.setIpv4Address(new Ipv4Address(value)); + casebuilder.setIpv4Src(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Ipv4Src.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java index eb8d3644..b775e516 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java @@ -17,14 +17,12 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder; /** * @author michal.polkorab @@ -38,8 +36,8 @@ public class OxmIpv6ExtHdrSerializerTest { * Test correct serialization */ @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, + public void testSerializeWithoutMask() { + MatchEntryBuilder builder = prepareIpv6ExtHdrMatchEntry(false, new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); @@ -54,8 +52,8 @@ public void testSerializeWithMask() { * Test correct serialization */ @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, + public void testSerializeWithMask() { + MatchEntryBuilder builder = prepareIpv6ExtHdrMatchEntry(true, new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); @@ -74,7 +72,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); + MatchEntryBuilder builder = prepareIpv6ExtHdrHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -88,7 +86,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); + MatchEntryBuilder builder = prepareIpv6ExtHdrHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -121,22 +119,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); + private static MatchEntryBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { + MatchEntryBuilder builder = prepareIpv6ExtHdrHeader(hasMask); + Ipv6ExthdrCaseBuilder casebuilder = new Ipv6ExthdrCaseBuilder(); + Ipv6ExthdrBuilder valueBuilder = new Ipv6ExthdrBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{0, 15}); } - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(flags); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + valueBuilder.setPseudoField(flags); + casebuilder.setIpv6Exthdr(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Ipv6Exthdr.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java index 3e9dce5d..d625317c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmIpv6NdSllSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry("00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -89,21 +87,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(String value) { + MatchEntryBuilder builder = prepareHeader(false); + Ipv6NdSllCaseBuilder casebuilder = new Ipv6NdSllCaseBuilder(); + Ipv6NdSllBuilder valueBuilder = new Ipv6NdSllBuilder(); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setIpv6NdSll(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Ipv6NdSll.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java index 29585d9b..02680589 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -18,13 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder; /** * @author michal.polkorab @@ -39,7 +37,7 @@ public class OxmIpv6NdTllSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + MatchEntryBuilder builder = prepareMatchEntry("00:01:02:03:04:05"); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -56,7 +54,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -89,21 +87,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(String value) { + MatchEntryBuilder builder = prepareHeader(false); + Ipv6NdTllCaseBuilder casebuilder = new Ipv6NdTllCaseBuilder(); + Ipv6NdTllBuilder valueBuilder = new Ipv6NdTllBuilder(); + valueBuilder.setMacAddress(new MacAddress(value)); + casebuilder.setIpv6NdTll(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Ipv6NdTll.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java index b790e133..3540829a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java @@ -17,13 +17,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder; /** * @author michal.polkorab @@ -38,7 +36,7 @@ public class OxmMetadataSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + MatchEntryBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -55,7 +53,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + MatchEntryBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -76,7 +74,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -90,7 +88,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -123,21 +121,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + MetadataCaseBuilder casebuilder = new MetadataCaseBuilder(); + MetadataBuilder valueBuilder = new MetadataBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + valueBuilder.setMetadata(value); + casebuilder.setMetadata(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(Metadata.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java index 0bc77dbc..da0390e4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmMplsBosSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); + MatchEntryBuilder builder = prepareMplsBosMatchEntry(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); + MatchEntryBuilder builder = prepareMplsBosHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,17 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(bos); - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + private static MatchEntryBuilder prepareMplsBosMatchEntry(boolean bos) { + MatchEntryBuilder builder = prepareMplsBosHeader(false); + MplsBosCaseBuilder casebuilder = new MplsBosCaseBuilder(); + MplsBosBuilder valueBuilder = new MplsBosBuilder(); + valueBuilder.setBos(bos); + casebuilder.setMplsBos(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareMplsBosHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(MplsBos.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java index 742001f7..4557be2f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmMplsLabelSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); + MatchEntryBuilder builder = prepareMplsLabelMatchEntry(168535); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + MatchEntryBuilder builder = prepareMplsLabelHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(label); - builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + private static MatchEntryBuilder prepareMplsLabelMatchEntry(long label) { + MatchEntryBuilder builder = prepareMplsLabelHeader(false); + MplsLabelCaseBuilder casebuilder = new MplsLabelCaseBuilder(); + MplsLabelBuilder valueBuilder = new MplsLabelBuilder(); + valueBuilder.setMplsLabel(label); + casebuilder.setMplsLabel(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareMplsLabelHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(MplsLabel.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java index 737eba0a..273f7a06 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmMplsTcSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); + MatchEntryBuilder builder = prepareMplsTcMatchEntry((short) 16); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); + MatchEntryBuilder builder = prepareMplsTcHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc(value); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + private static MatchEntryBuilder prepareMplsTcMatchEntry(short value) { + MatchEntryBuilder builder = prepareMplsTcHeader(false); + MplsTcCaseBuilder casebuilder = new MplsTcCaseBuilder(); + MplsTcBuilder valueBuilder = new MplsTcBuilder(); + valueBuilder.setTc(value); + casebuilder.setMplsTc(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareMplsTcHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(MplsTc.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java index 02742e88..3d8db87f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java @@ -17,13 +17,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder; /** * @author michal.polkorab @@ -38,7 +36,7 @@ public class OxmPbbIsidSerializerTest { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); + MatchEntryBuilder builder = preparePbbIsidMatchEntry(false, 12345); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -53,7 +51,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); + MatchEntryBuilder builder = preparePbbIsidMatchEntry(true, 6789); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -71,7 +69,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(false); + MatchEntryBuilder builder = preparePbbIsidHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -85,7 +83,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(true); + MatchEntryBuilder builder = preparePbbIsidHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -118,22 +116,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); } - - private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { - MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); + private static MatchEntryBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { + MatchEntryBuilder builder = preparePbbIsidHeader(hasMask); + PbbIsidCaseBuilder casebuilder = new PbbIsidCaseBuilder(); + PbbIsidBuilder valueBuilder = new PbbIsidBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{0, 15, 10}); } - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(value); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + valueBuilder.setIsid(value); + casebuilder.setPbbIsid(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder preparePbbIsidHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(PbbIsid.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java index 9bf4e07b..dd51c957 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmSctpDstSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); + MatchEntryBuilder builder = prepareMatchEntry(4096); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + SctpDstCaseBuilder casebuilder = new SctpDstCaseBuilder(); + SctpDstBuilder valueBuilder = new SctpDstBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setSctpDst(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(SctpDst.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java index 91d3099f..ca46f9ef 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmSctpSrcSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); + MatchEntryBuilder builder = prepareMatchEntry(4096); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + SctpSrcCaseBuilder casebuilder = new SctpSrcCaseBuilder(); + SctpSrcBuilder valueBuilder = new SctpSrcBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setSctpSrc(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(SctpSrc.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java index 431725ae..adcdf7bb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmTcpDstSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); + MatchEntryBuilder builder = prepareMatchEntry(4096); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + TcpDstCaseBuilder casebuilder = new TcpDstCaseBuilder(); + TcpDstBuilder valueBuilder = new TcpDstBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setTcpDst(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(TcpDst.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java index 3cdd17e3..003c6e62 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmTcpSrcSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(512); + MatchEntryBuilder builder = prepareMatchEntry(512); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + TcpSrcCaseBuilder casebuilder = new TcpSrcCaseBuilder(); + TcpSrcBuilder valueBuilder = new TcpSrcBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setTcpSrc(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(TcpSrc.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java index 73cc676a..193bf057 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java @@ -17,13 +17,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder; /** * @author michal.polkorab @@ -38,7 +36,7 @@ public class OxmTunnelIdSerializerTest { */ @Test public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + MatchEntryBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -55,7 +53,7 @@ public void testSerializeWithoutMask() { */ @Test public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + MatchEntryBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -76,7 +74,7 @@ public void testSerializeWithMask() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -90,7 +88,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); + MatchEntryBuilder builder = prepareHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -123,21 +121,21 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + TunnelIdCaseBuilder casebuilder = new TunnelIdCaseBuilder(); + TunnelIdBuilder valueBuilder = new TunnelIdBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + valueBuilder.setTunnelId(value); + casebuilder.setTunnelId(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(TunnelId.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java index 35318d8f..a77e20ec 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmUdpDstSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(2048); + MatchEntryBuilder builder = prepareMatchEntry(2048); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + UdpDstCaseBuilder casebuilder = new UdpDstCaseBuilder(); + UdpDstBuilder valueBuilder = new UdpDstBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setUdpDst(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(UdpDst.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java index 7cb4d0ab..9edfccb4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -17,11 +17,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder; /** * @author michal.polkorab @@ -36,7 +36,7 @@ public class OxmUdpSrcSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(1024); + MatchEntryBuilder builder = prepareMatchEntry(1024); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -51,7 +51,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); + MatchEntryBuilder builder = prepareHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -84,16 +84,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + private static MatchEntryBuilder prepareMatchEntry(int value) { + MatchEntryBuilder builder = prepareHeader(false); + UdpSrcCaseBuilder casebuilder = new UdpSrcCaseBuilder(); + UdpSrcBuilder valueBuilder = new UdpSrcBuilder(); + valueBuilder.setPort(new PortNumber(value)); + casebuilder.setUdpSrc(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(UdpSrc.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java index b96e0d76..ecadb71c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java @@ -16,11 +16,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public class OxmVlanPcpSerializerTest { */ @Test public void testSerialize() { - MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); + MatchEntryBuilder builder = prepareVlanPcpMatchEntry((short) 42); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -50,7 +50,7 @@ public void testSerialize() { */ @Test public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + MatchEntryBuilder builder = prepareVlanPcpHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -83,16 +83,18 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp(value); - builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + private static MatchEntryBuilder prepareVlanPcpMatchEntry(short value) { + MatchEntryBuilder builder = prepareVlanPcpHeader(false); + VlanPcpCaseBuilder casebuilder = new VlanPcpCaseBuilder(); + VlanPcpBuilder valueBuilder = new VlanPcpBuilder(); + valueBuilder.setVlanPcp(value); + casebuilder.setVlanPcp(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareVlanPcpHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(VlanPcp.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java index a22e6c81..effaccdb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java @@ -17,13 +17,11 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder; /** * @author michal.polkorab @@ -38,7 +36,7 @@ public class OxmVlanVidSerializerTest { */ @Test public void testSerializeWithCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); + MatchEntryBuilder builder = prepareVlanVidMatchEntry(false, true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -53,7 +51,7 @@ public void testSerializeWithCfiBitSet() { */ @Test public void testSerializeWithoutCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); + MatchEntryBuilder builder = prepareVlanVidMatchEntry(true, false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serialize(builder.build(), buffer); @@ -71,7 +69,7 @@ public void testSerializeWithoutCfiBitSet() { */ @Test public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(false); + MatchEntryBuilder builder = prepareVlanVidHeader(false); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -85,7 +83,7 @@ public void testSerializeHeaderWithoutMask() { */ @Test public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(true); + MatchEntryBuilder builder = prepareVlanVidHeader(true); ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializer.serializeHeader(builder.build(), buffer); @@ -118,22 +116,22 @@ public void testGetValueLength() { assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); } - private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { - MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); + private static MatchEntryBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { + MatchEntryBuilder builder = prepareVlanVidHeader(hasMask); + VlanVidCaseBuilder casebuilder = new VlanVidCaseBuilder(); + VlanVidBuilder valueBuilder = new VlanVidBuilder(); if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + valueBuilder.setMask(new byte[]{15, 15}); } - VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); - vlanBuilder.setVlanVid(500); - vlanBuilder.setCfiBit(cfiBit); - builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); + valueBuilder.setVlanVid(500); + valueBuilder.setCfiBit(cfiBit); + casebuilder.setVlanVid(valueBuilder.build()); + builder.setMatchEntryValue(casebuilder.build()); return builder; } - private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + private static MatchEntryBuilder prepareVlanVidHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(VlanVid.class); builder.setHasMask(hasMask); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index e9f98b7c..54dd16d0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -18,17 +18,17 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -125,15 +125,16 @@ public void test() { + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); - List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); + List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntry(); Assert.assertEquals("Wrong number of fields", 1, entries.size()); Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); + + "oxm.rev150225.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); + + "oxm.rev150225.InPhyPort", entries.get(0).getOxmMatchField().getName()); Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); Assert.assertEquals("Wrong match entry value", 11, - entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + ((InPhyPortCase) entries.get(0).getMatchEntryValue()).getInPhyPort().getPortNumber() + .getValue().intValue()); Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); Assert.assertEquals("Wrong action value", 10, diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 39452dcc..77af43c5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -18,15 +18,15 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index b139257f..4519deed 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -25,76 +25,92 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; /** * @author michal.polkorab @@ -127,10 +143,10 @@ public void testIpv4Address() { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12); key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntry entry = entryDeserializer.deserialize(buffer); Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), - entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address()); } /** @@ -143,10 +159,10 @@ public void testIpv6Address() { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26); key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntry entry = entryDeserializer.deserialize(buffer); Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), - entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address()); } /** @@ -154,7 +170,7 @@ public void testIpv6Address() { */ @Test public void testMatch() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC " + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 A8 " + "80 00 00 04 00 00 00 01 " + "80 00 02 04 00 00 00 02 " + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 " @@ -185,7 +201,7 @@ public void testMatch() { + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 " + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 " - + "80 00 39 08 00 00 00 02 00 00 00 03 " + + "80 00 38 04 00 00 00 02 " + "80 00 3A 01 15 " + "80 00 3C 01 17 " + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget @@ -196,290 +212,289 @@ public void testMatch() { + "80 00 48 01 01 " + "80 00 4B 06 00 00 02 00 00 01 " + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " - + "80 00 4F 04 00 00 03 04 " - + "00 00 00 00"); + + "80 00 4F 04 00 00 03 04"); + System.out.println(buffer.readableBytes()); Match match = matchDeserializer.deserialize(buffer); Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size()); - List entries = match.getMatchEntries(); - MatchEntries entry0 = entries.get(0); + Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntry().size()); + List entries = match.getMatchEntry(); + MatchEntry entry0 = entries.get(0); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass()); Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask()); Assert.assertEquals("Wrong entry value", 1, - entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry1 = entries.get(1); + ((InPortCase) entry0.getMatchEntryValue()).getInPort().getPortNumber().getValue().intValue()); + MatchEntry entry1 = entries.get(1); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass()); Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask()); Assert.assertEquals("Wrong entry value", 2, - entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry2 = entries.get(2); + ((InPhyPortCase) entry1.getMatchEntryValue()).getInPhyPort().getPortNumber().getValue().intValue()); + MatchEntry entry2 = entries.get(2); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); + ((MetadataCase) entry2.getMatchEntryValue()).getMetadata().getMetadata()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), - entry2.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry3 = entries.get(3); + ((MetadataCase) entry2.getMatchEntryValue()).getMetadata().getMask()); + MatchEntry entry3 = entries.get(3); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), - entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + ((EthDstCase) entry3.getMatchEntryValue()).getEthDst().getMacAddress()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), - entry3.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry4 = entries.get(4); + ((EthDstCase) entry3.getMatchEntryValue()).getEthDst().getMask()); + MatchEntry entry4 = entries.get(4); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), - entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + ((EthSrcCase) entry4.getMatchEntryValue()).getEthSrc().getMacAddress()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), - entry4.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry5 = entries.get(5); + ((EthSrcCase) entry4.getMatchEntryValue()).getEthSrc().getMask()); + MatchEntry entry5 = entries.get(5); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask()); Assert.assertEquals("Wrong entry value", 9, - entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue()); - MatchEntries entry6 = entries.get(6); + ((EthTypeCase) entry5.getMatchEntryValue()).getEthType().getEthType().getValue().intValue()); + MatchEntry entry6 = entries.get(6); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass()); Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); Assert.assertEquals("Wrong entry value", 10, - entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + ((VlanVidCase) entry6.getMatchEntryValue()).getVlanVid().getVlanVid().intValue()); Assert.assertEquals("Wrong entry value", false, - entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + ((VlanVidCase) entry6.getMatchEntryValue()).getVlanVid().isCfiBit()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), - entry6.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry7 = entries.get(7); + ((VlanVidCase) entry6.getMatchEntryValue()).getVlanVid().getMask()); + MatchEntry entry7 = entries.get(7); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask()); Assert.assertEquals("Wrong entry value", 12, - entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue()); - MatchEntries entry8 = entries.get(8); + ((VlanPcpCase) entry7.getMatchEntryValue()).getVlanPcp().getVlanPcp().intValue()); + MatchEntry entry8 = entries.get(8); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass()); Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask()); Assert.assertEquals("Wrong entry value", 13, - entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue()); - MatchEntries entry9 = entries.get(9); + ((IpDscpCase) entry8.getMatchEntryValue()).getIpDscp().getDscp().getValue().intValue()); + MatchEntry entry9 = entries.get(9); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass()); Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask()); Assert.assertEquals("Wrong entry value", 14, - entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue()); - MatchEntries entry10 = entries.get(10); + ((IpEcnCase) entry9.getMatchEntryValue()).getIpEcn().getEcn().intValue()); + MatchEntry entry10 = entries.get(10); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass()); Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask()); Assert.assertEquals("Wrong entry value", 15, - entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue()); - MatchEntries entry11 = entries.get(11); + ((IpProtoCase) entry10.getMatchEntryValue()).getIpProto().getProtocolNumber().intValue()); + MatchEntry entry11 = entries.get(11); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), - entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + ((Ipv4SrcCase) entry11.getMatchEntryValue()).getIpv4Src().getIpv4Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry11.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry12 = entries.get(12); + ((Ipv4SrcCase) entry11.getMatchEntryValue()).getIpv4Src().getMask()); + MatchEntry entry12 = entries.get(12); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), - entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + ((Ipv4DstCase) entry12.getMatchEntryValue()).getIpv4Dst().getIpv4Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry12.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry13 = entries.get(13); + ((Ipv4DstCase) entry12.getMatchEntryValue()).getIpv4Dst().getMask()); + MatchEntry entry13 = entries.get(13); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask()); Assert.assertEquals("Wrong entry value", 3, - entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry14 = entries.get(14); + ((TcpSrcCase) entry13.getMatchEntryValue()).getTcpSrc().getPort().getValue().intValue()); + MatchEntry entry14 = entries.get(14); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass()); Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask()); Assert.assertEquals("Wrong entry value", 4, - entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry15 = entries.get(15); + ((TcpDstCase) entry14.getMatchEntryValue()).getTcpDst().getPort().getValue().intValue()); + MatchEntry entry15 = entries.get(15); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass()); Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask()); Assert.assertEquals("Wrong entry value", 5, - entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry16 = entries.get(16); + ((UdpSrcCase) entry15.getMatchEntryValue()).getUdpSrc().getPort().getValue().intValue()); + MatchEntry entry16 = entries.get(16); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass()); Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask()); Assert.assertEquals("Wrong entry value", 6, - entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry17 = entries.get(17); + ((UdpDstCase) entry16.getMatchEntryValue()).getUdpDst().getPort().getValue().intValue()); + MatchEntry entry17 = entries.get(17); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass()); Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask()); Assert.assertEquals("Wrong entry value", 7, - entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry18 = entries.get(18); + ((SctpSrcCase) entry17.getMatchEntryValue()).getSctpSrc().getPort().getValue().intValue()); + MatchEntry entry18 = entries.get(18); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass()); Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask()); Assert.assertEquals("Wrong entry value", 8, - entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry19 = entries.get(19); + ((SctpDstCase) entry18.getMatchEntryValue()).getSctpDst().getPort().getValue().intValue()); + MatchEntry entry19 = entries.get(19); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask()); Assert.assertEquals("Wrong entry value", 5, - entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue()); - MatchEntries entry20 = entries.get(20); + ((Icmpv4TypeCase) entry19.getMatchEntryValue()).getIcmpv4Type().getIcmpv4Type().intValue()); + MatchEntry entry20 = entries.get(20); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask()); Assert.assertEquals("Wrong entry value", 7, - entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue()); - MatchEntries entry21 = entries.get(21); + ((Icmpv4CodeCase) entry20.getMatchEntryValue()).getIcmpv4Code().getIcmpv4Code().intValue()); + MatchEntry entry21 = entries.get(21); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask()); Assert.assertEquals("Wrong entry value", 16, - entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue()); - MatchEntries entry22 = entries.get(22); + ((ArpOpCase) entry21.getMatchEntryValue()).getArpOp().getOpCode().intValue()); + MatchEntry entry22 = entries.get(22); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), - entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + ((ArpSpaCase) entry22.getMatchEntryValue()).getArpSpa().getIpv4Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry22.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry23 = entries.get(23); + ((ArpSpaCase) entry22.getMatchEntryValue()).getArpSpa().getMask()); + MatchEntry entry23 = entries.get(23); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), - entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + ((ArpTpaCase) entry23.getMatchEntryValue()).getArpTpa().getIpv4Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry23.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry24 = entries.get(24); + ((ArpTpaCase) entry23.getMatchEntryValue()).getArpTpa().getMask()); + MatchEntry entry24 = entries.get(24); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), - entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + ((ArpShaCase) entry24.getMatchEntryValue()).getArpSha().getMacAddress()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), - entry24.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry25 = entries.get(25); + ((ArpShaCase) entry24.getMatchEntryValue()).getArpSha().getMask()); + MatchEntry entry25 = entries.get(25); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), - entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + ((ArpThaCase) entry25.getMatchEntryValue()).getArpTha().getMacAddress()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), - entry25.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry26 = entries.get(26); + ((ArpThaCase) entry25.getMatchEntryValue()).getArpTha().getMask()); + MatchEntry entry26 = entries.get(26); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), - entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + ((Ipv6SrcCase) entry26.getMatchEntryValue()).getIpv6Src().getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), - entry26.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry27 = entries.get(27); + ((Ipv6SrcCase) entry26.getMatchEntryValue()).getIpv6Src().getMask()); + MatchEntry entry27 = entries.get(27); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), - entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + ((Ipv6DstCase) entry27.getMatchEntryValue()).getIpv6Dst().getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), - entry27.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry28 = entries.get(28); + ((Ipv6DstCase) entry27.getMatchEntryValue()).getIpv6Dst().getMask()); + MatchEntry entry28 = entries.get(28); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); + Assert.assertEquals("Wrong entry hasMask", false, entry28.isHasMask()); Assert.assertEquals("Wrong entry value", 2, - entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), - entry28.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry29 = entries.get(29); + ((Ipv6FlabelCase) entry28.getMatchEntryValue()).getIpv6Flabel().getIpv6Flabel() + .getValue().intValue()); + MatchEntry entry29 = entries.get(29); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); Assert.assertEquals("Wrong entry value", 21, - entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); - MatchEntries entry30 = entries.get(30); + ((Icmpv6TypeCase) entry29.getMatchEntryValue()).getIcmpv6Type().getIcmpv6Type().intValue()); + MatchEntry entry30 = entries.get(30); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); Assert.assertEquals("Wrong entry value", 23, - entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); - MatchEntries entry31 = entries.get(31); + ((Icmpv6CodeCase) entry30.getMatchEntryValue()).getIcmpv6Code().getIcmpv6Code().intValue()); + MatchEntry entry31 = entries.get(31); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), - entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - MatchEntries entry32 = entries.get(32); + ((Ipv6NdTargetCase) entry31.getMatchEntryValue()).getIpv6NdTarget().getIpv6Address()); + MatchEntry entry32 = entries.get(32); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), - entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry33 = entries.get(33); + ((Ipv6NdSllCase) entry32.getMatchEntryValue()).getIpv6NdSll().getMacAddress()); + MatchEntry entry33 = entries.get(33); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask()); Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"), - entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry34 = entries.get(34); + ((Ipv6NdTllCase) entry33.getMatchEntryValue()).getIpv6NdTll().getMacAddress()); + MatchEntry entry34 = entries.get(34); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass()); Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask()); Assert.assertEquals("Wrong entry value", 515, - entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); - MatchEntries entry35 = entries.get(35); + ((MplsLabelCase) entry34.getMatchEntryValue()).getMplsLabel().getMplsLabel().intValue()); + MatchEntry entry35 = entries.get(35); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass()); Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask()); Assert.assertEquals("Wrong entry value", 3, - entry35.getAugmentation(TcMatchEntry.class).getTc().intValue()); - MatchEntries entry36 = entries.get(36); + ((MplsTcCase) entry35.getMatchEntryValue()).getMplsTc().getTc().intValue()); + MatchEntry entry36 = entries.get(36); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass()); Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask()); Assert.assertEquals("Wrong entry value", true, - entry36.getAugmentation(BosMatchEntry.class).isBos()); - MatchEntries entry37 = entries.get(37); + ((MplsBosCase) entry36.getMatchEntryValue()).getMplsBos().isBos()); + MatchEntry entry37 = entries.get(37); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass()); Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask()); Assert.assertEquals("Wrong entry value", 2, - entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + ((PbbIsidCase) entry37.getMatchEntryValue()).getPbbIsid().getIsid().intValue()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"), - entry37.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry38 = entries.get(38); + ((PbbIsidCase) entry37.getMatchEntryValue()).getPbbIsid().getMask()); + MatchEntry entry38 = entries.get(38); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass()); Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask()); Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"), - entry38.getAugmentation(MetadataMatchEntry.class).getMetadata()); + ((TunnelIdCase) entry38.getMatchEntryValue()).getTunnelId().getTunnelId()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"), - entry38.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry39 = entries.get(39); + ((TunnelIdCase) entry38.getMatchEntryValue()).getTunnelId().getMask()); + MatchEntry entry39 = entries.get(39); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); Assert.assertEquals("Wrong entry value", new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), - entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + ((Ipv6ExthdrCase) entry39.getMatchEntryValue()).getIpv6Exthdr().getPseudoField()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), - entry39.getAugmentation(MaskMatchEntry.class).getMask()); + ((Ipv6ExthdrCase) entry39.getMatchEntryValue()).getIpv6Exthdr().getMask()); Assert.assertTrue("Unread data", buffer.readableBytes() == 0); } @@ -493,12 +508,12 @@ public void testHeaders() { MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12); key.setExperimenterId(null); - HeaderDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserializeHeader(buffer); + HeaderDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntry entry = entryDeserializer.deserializeHeader(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); + Assert.assertNull("Wrong Ipv4 address", entry.getMatchEntryValue()); } /** @@ -511,6 +526,6 @@ public void testStandardMatch() { Match match = matchDeserializer.deserialize(buffer); Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); + Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntry().size()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 2dd21e82..b0fc2115 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -19,14 +19,14 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index ad9f0c14..16e9a8fa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -22,22 +22,22 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 35f70325..83242ce4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index b1b6d103..db16f9c5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -10,6 +10,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -22,8 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index ed47b014..7e614b67 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -19,24 +19,22 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; @@ -57,10 +55,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder; /** * @author michal.polkorab @@ -154,16 +154,18 @@ public void test() { actionBuilder = new ActionBuilder(); actionBuilder.setType(SetField.class); OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder matchBuilder = new MatchEntryBuilder(); matchBuilder.setOxmClass(OpenflowBasicClass.class); matchBuilder.setOxmMatchField(InPort.class); matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder(); + InPortBuilder inPortBuilder = new InPortBuilder(); + inPortBuilder.setPortNumber(new PortNumber(1L)); + inPortCaseBuilder.setInPort(inPortBuilder.build()); + matchBuilder.setMatchEntryValue(inPortCaseBuilder.build()); entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); + matchEntries.setMatchEntry(entries); actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); @@ -261,16 +263,18 @@ public void testHeaders() { actionBuilder = new ActionBuilder(); actionBuilder.setType(SetField.class); OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder matchBuilder = new MatchEntryBuilder(); matchBuilder.setOxmClass(OpenflowBasicClass.class); matchBuilder.setOxmMatchField(InPort.class); matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder(); + InPortBuilder inPortBuilder = new InPortBuilder(); + inPortBuilder.setPortNumber(new PortNumber(1L)); + inPortCaseBuilder.setInPort(inPortBuilder.build()); + matchBuilder.setMatchEntryValue(inPortCaseBuilder.build()); entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); + matchEntries.setMatchEntry(entries); actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); actions.add(actionBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 6e972f82..b48c265f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -20,22 +20,22 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index de60195a..a7bad7ae 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -26,103 +26,135 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; /** * @author michal.polkorab @@ -168,395 +200,439 @@ public void testEmptyMatch() { public void test() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(InPort.class); entryBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(42L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder(); + InPortBuilder inPortBuilder = new InPortBuilder(); + inPortBuilder.setPortNumber(new PortNumber(42L)); + inPortCaseBuilder.setInPort(inPortBuilder.build()); + entryBuilder.setMatchEntryValue(inPortCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(InPhyPort.class); entryBuilder.setHasMask(false); - portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(43L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(43L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entryBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Metadata.class); entryBuilder.setHasMask(true); - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + MetadataCaseBuilder metaCaseBuilder = new MetadataCaseBuilder(); + MetadataBuilder metadataBuilder = new MetadataBuilder(); metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + metadataBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + metaCaseBuilder.setMetadata(metadataBuilder.build()); + entryBuilder.setMatchEntryValue(metaCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthDst.class); entryBuilder.setHasMask(true); - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,5}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder(); + EthDstBuilder ethDstBuilder = new EthDstBuilder(); + ethDstBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + ethDstBuilder.setMask(new byte[]{0,0,0,0,0,5}); + ethDstCaseBuilder.setEthDst(ethDstBuilder.build()); + entryBuilder.setMatchEntryValue(ethDstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthSrc.class); entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder(); + EthSrcBuilder ethSrcBuilder = new EthSrcBuilder(); + ethSrcBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + ethSrcBuilder.setMask(new byte[]{0,0,0,0,0,2}); + ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build()); + entryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthType.class); entryBuilder.setHasMask(false); - EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); - ethBuilder.setEthType(new EtherType(46)); - entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); + EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder(); + EthTypeBuilder ethTypeBuilder = new EthTypeBuilder(); + ethTypeBuilder.setEthType(new EtherType(46)); + ethTypeCaseBuilder.setEthType(ethTypeBuilder.build()); + entryBuilder.setMatchEntryValue(ethTypeCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanVid.class); entryBuilder.setHasMask(true); - VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); - vidBuilder.setCfiBit(true); - vidBuilder.setVlanVid(45); - entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,9}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder(); + VlanVidBuilder vlanVidBuilder = new VlanVidBuilder(); + vlanVidBuilder.setVlanVid(45); + vlanVidBuilder.setCfiBit(true); + vlanVidBuilder.setMask(new byte[]{0,9}); + vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build()); + entryBuilder.setMatchEntryValue(vlanVidCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanPcp.class); entryBuilder.setHasMask(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp((short) 14); - entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder(); + VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder(); + vlanPcpBuilder.setVlanPcp((short) 14); + vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build()); + entryBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpDscp.class); entryBuilder.setHasMask(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp((short) 48)); - entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder(); + IpDscpBuilder ipDscpBuilder = new IpDscpBuilder(); + ipDscpBuilder.setDscp(new Dscp((short) 48)); + ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build()); + entryBuilder.setMatchEntryValue(ipDscpCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpEcn.class); entryBuilder.setHasMask(false); - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn((short) 49); - entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 49); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entryBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpProto.class); entryBuilder.setHasMask(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); - protoBuilder.setProtocolNumber((short) 50); - entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder(); + IpProtoBuilder ipProtoBuilder = new IpProtoBuilder(); + ipProtoBuilder.setProtocolNumber((short) 50); + ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build()); + entryBuilder.setMatchEntryValue(ipProtoCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Src.class); entryBuilder.setHasMask(true); - Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,14}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder(); + Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder(); + ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1")); + ipv4SrcBuilder.setMask(new byte[]{0,0,0,14}); + ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build()); + entryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Dst.class); entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,15}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder(); + Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder(); + ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2")); + ipv4DstBuilder.setMask(new byte[]{0,0,0,15}); + ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build()); + entryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpSrc.class); entryBuilder.setHasMask(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder(); + TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder(); + tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build()); + entryBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpDst.class); entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder(); + TcpDstBuilder tcpDstBuilder = new TcpDstBuilder(); + tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build()); + entryBuilder.setMatchEntryValue(tcpDstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpSrc.class); entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder(); + UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder(); + udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build()); + entryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpDst.class); entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder(); + UdpDstBuilder udpDstBuilder = new UdpDstBuilder(); + udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + udpDstCaseBuilder.setUdpDst(udpDstBuilder.build()); + entryBuilder.setMatchEntryValue(udpDstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpSrc.class); entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder(); + SctpSrcBuilder sctpSrcBuilder = new SctpSrcBuilder(); + sctpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + sctpSrcCaseBuilder.setSctpSrc(sctpSrcBuilder.build()); + entryBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpDst.class); entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder(); + SctpDstBuilder sctpDstBuilder = new SctpDstBuilder(); + sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build()); + entryBuilder.setMatchEntryValue(sctpDstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Type.class); entryBuilder.setHasMask(false); - Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4typeBuilder.setIcmpv4Type((short) 51); - entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); + Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder(); + Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder(); + icmpv4TypeBuilder.setIcmpv4Type((short) 51); + icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build()); + entryBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Code.class); entryBuilder.setHasMask(false); - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); + Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder(); + Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder(); icmpv4CodeBuilder.setIcmpv4Code((short) 52); - entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build()); + entryBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpOp.class); entryBuilder.setHasMask(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(53); - entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder(); + ArpOpBuilder arpOpBuilder = new ArpOpBuilder(); + arpOpBuilder.setOpCode(53); + arpOpCaseBuilder.setArpOp(arpOpBuilder.build()); + entryBuilder.setMatchEntryValue(arpOpCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSpa.class); entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,16}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder(); + ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder(); + arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4")); + arpSpaBuilder.setMask(new byte[]{0,0,0,16}); + arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build()); + entryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTpa.class); entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,17}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder(); + ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder(); + arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.5")); + arpTpaBuilder.setMask(new byte[]{0,0,0,17}); + arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build()); + entryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSha.class); entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,4,0,0,6}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder(); + ArpShaBuilder arpShaBuilder = new ArpShaBuilder(); + arpShaBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); + arpShaBuilder.setMask(new byte[]{0,0,4,0,0,6}); + arpShaCaseBuilder.setArpSha(arpShaBuilder.build()); + entryBuilder.setMatchEntryValue(arpShaCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTha.class); entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,6,0,0,4}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder(); + ArpThaBuilder arpThaBuilder = new ArpThaBuilder(); + arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); + arpThaBuilder.setMask(new byte[]{0,0,6,0,0,4}); + arpThaCaseBuilder.setArpTha(arpThaBuilder.build()); + entryBuilder.setMatchEntryValue(arpThaCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Src.class); entryBuilder.setHasMask(true); - Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder(); + Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder(); + ipv6SrcBuilder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); + ipv6SrcBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); + ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Dst.class); entryBuilder.setHasMask(true); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder(); + Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder(); + ipv6DstBuilder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); + ipv6DstBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); + ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Flabel.class); - entryBuilder.setHasMask(true); - Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); - entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entryBuilder.setHasMask(false); + Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder(); + Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder(); + ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); + ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Type.class); entryBuilder.setHasMask(false); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); + Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder(); + Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder(); icmpv6TypeBuilder.setIcmpv6Type((short) 59); - entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build()); + entryBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Code.class); entryBuilder.setHasMask(false); - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code((short) 60); - entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + Icmpv6CodeCaseBuilder Icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder(); + Icmpv6CodeBuilder Icmpv6CodeBuilder = new Icmpv6CodeBuilder(); + Icmpv6CodeBuilder.setIcmpv6Code((short) 60); + Icmpv6CodeCaseBuilder.setIcmpv6Code(Icmpv6CodeBuilder.build()); + entryBuilder.setMatchEntryValue(Icmpv6CodeCaseBuilder.build()); entries.add(entryBuilder.build()); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTarget.class); entryBuilder.setHasMask(false); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder(); + Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder(); + ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); + ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdSll.class); entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder(); + Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder(); + ipv6NdSllBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTll.class); entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder(); + Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder(); + ipv6NdTllBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsLabel.class); entryBuilder.setHasMask(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(61L); - entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder(); + MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder(); + mplsLabelBuilder.setMplsLabel(61L); + mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build()); + entryBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsTc.class); entryBuilder.setHasMask(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc((short) 62); - entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + MplsTcCaseBuilder MplsTcCaseBuilder = new MplsTcCaseBuilder(); + MplsTcBuilder MplsTcBuilder = new MplsTcBuilder(); + MplsTcBuilder.setTc((short) 62); + MplsTcCaseBuilder.setMplsTc(MplsTcBuilder.build()); + entryBuilder.setMatchEntryValue(MplsTcCaseBuilder.build()); entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsBos.class); entryBuilder.setHasMask(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(true); - entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + MplsBosCaseBuilder MplsBosCaseBuilder = new MplsBosCaseBuilder(); + MplsBosBuilder MplsBosBuilder = new MplsBosBuilder(); + MplsBosBuilder.setBos(true); + MplsBosCaseBuilder.setMplsBos(MplsBosBuilder.build()); + entryBuilder.setMatchEntryValue(MplsBosCaseBuilder.build()); entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(PbbIsid.class); entryBuilder.setHasMask(true); - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(64L); - entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder(); + PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder(); + pbbIsidBuilder.setIsid(64L); + pbbIsidBuilder.setMask(new byte[]{0,1,2}); + pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build()); + entryBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build()); entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TunnelId.class); entryBuilder.setHasMask(true); - metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder(); + TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder(); + tunnelIdBuilder.setTunnelId(new byte[]{0,0,0,0,0,0,0,1}); + tunnelIdBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build()); + entryBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build()); entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); + entryBuilder = new MatchEntryBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Exthdr.class); entryBuilder.setHasMask(true); - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder(); + Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder(); + ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, + false, true, false, true, false, true)); + ipv6ExthdrBuilder.setMask(new byte[]{0,2}); + ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build()); + entryBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build()); entries.add(entryBuilder.build()); - - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 424, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); @@ -724,12 +800,9 @@ public void test() { out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry field & hasMask", 56, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); //8, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,0,2}, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); @@ -787,7 +860,7 @@ public void test() { array = new byte[2]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,2}, array); - Assert.assertTrue("Wrong padding", out.readableBytes() == 4); + Assert.assertTrue("Wrong padding", out.readableBytes() == 0); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index deb3df01..fe1812c9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -26,31 +26,33 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,16 +85,18 @@ public void startUp() { public void testIpv4Src() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv4Src.class); entriesBuilder.setHasMask(false); - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address("1.2.3.4")); - entriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder(); + Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder(); + ipv4SrcBuilder.setIpv4Address(new Ipv4Address("1.2.3.4")); + ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build()); entries.add(entriesBuilder.build()); - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); @@ -116,53 +120,63 @@ public void testIpv4Src() { public void testIpv6Various() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); + List entries = new ArrayList<>(); // ipv6 match entry with correct Ipv6 address - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Src.class); entriesBuilder.setHasMask(false); - Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder(); + Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder(); + ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2:3:4:5:6:7:8")); + ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build()); entries.add(entriesBuilder.build()); // ipv6 match entry with abbreviated Ipv6 address - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6NdTarget.class); entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder(); + Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder(); + ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("1:2::6:7:8")); + ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build()); entries.add(entriesBuilder.build()); // ipv6 match entry with abbreviated Ipv6 address - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Dst.class); entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1::8")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder(); + Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder(); + ipv6DstBuilder.setIpv6Address(new Ipv6Address("1::8")); + ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build()); entries.add(entriesBuilder.build()); // ipv6 match entry with abbreviated Ipv6 address - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Dst.class); entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("::1")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + ipv6DstCaseBuilder = new Ipv6DstCaseBuilder(); + ipv6DstBuilder = new Ipv6DstBuilder(); + ipv6DstBuilder.setIpv6Address(new Ipv6Address("::1")); + ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build()); entries.add(entriesBuilder.build()); // ipv6 match entry with abbreviated Ipv6 address - entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Dst.class); entriesBuilder.setHasMask(false); - addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("::")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + ipv6DstCaseBuilder = new Ipv6DstCaseBuilder(); + ipv6DstBuilder = new Ipv6DstBuilder(); + ipv6DstBuilder.setIpv6Address(new Ipv6Address("::")); + ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build()); entries.add(entriesBuilder.build()); - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); @@ -233,17 +247,19 @@ public void testIpv6Various() { public void testIpv6Incorrect() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); + List entries = new ArrayList<>(); // ipv6 match entry with incorrect Ipv6 address - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Src.class); entriesBuilder.setHasMask(false); - Ipv6AddressMatchEntryBuilder addressBuilder = new Ipv6AddressMatchEntryBuilder(); - addressBuilder.setIpv6Address(new Ipv6Address("1:2::::8")); - entriesBuilder.addAugmentation(Ipv6AddressMatchEntry.class, addressBuilder.build()); + Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder(); + Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder(); + ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1:2::::8")); + ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build()); entries.add(entriesBuilder.build()); - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); @@ -262,7 +278,7 @@ public void testIpv6Flabel() { Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong field and mask", 28<<1, out.readUnsignedByte()); + Assert.assertEquals("Wrong field and mask", 56, out.readUnsignedByte()); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); byte[] label = new byte[4]; out.readBytes(label); @@ -272,11 +288,11 @@ public void testIpv6Flabel() { } /** - * Test for correct serialization of Ipv4Address match entry with mask + * Test for correct serialization of Ipv4Address match entry */ @Test public void testIpv6FlabelWithMask() { - Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 0x0c, 0x7b, 0x6a}); + Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0, 1, 2, 3}); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); matchSerializer.serialize(match, out); @@ -284,13 +300,14 @@ public void testIpv6FlabelWithMask() { Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong field and mask", 28<<1 | 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong field and mask", 57, out.readUnsignedByte()); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - byte[] labelAndMask = new byte[8]; - out.readBytes(labelAndMask); - - LOG.debug("label: "+ByteBufUtils.bytesToHexString(labelAndMask)); - Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d, 0, 0x0c, 0x7b, 0x6a}, labelAndMask); + byte[] label = new byte[4]; + out.readBytes(label); + Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label); + byte[] mask = new byte[4]; + out.readBytes(mask); + Assert.assertArrayEquals("Wrong ipv6FLabel mask", new byte[]{0, 1, 2, 3}, mask); } /** @@ -299,7 +316,6 @@ public void testIpv6FlabelWithMask() { @Test public void testIpv6FlabelWithMaskBad() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[]{0x0c, 0x7b, 0x6a}); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); try { @@ -319,19 +335,19 @@ public void testIpv6FlabelWithMaskBad() { private static Match buildIpv6FLabelMatch(long labelValue, boolean hasMask, byte[] mask) { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); entriesBuilder.setOxmClass(OpenflowBasicClass.class); entriesBuilder.setOxmMatchField(Ipv6Flabel.class); entriesBuilder.setHasMask(hasMask); - Ipv6FlabelMatchEntryBuilder ip6FLabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - ip6FLabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue)); - entriesBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, ip6FLabelBuilder.build()); - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(mask); - entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder(); + Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder(); + ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(labelValue)); + ipv6FlabelBuilder.setMask(mask); + ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build()); + entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build()); entries.add(entriesBuilder.build()); - builder.setMatchEntries(entries); + builder.setMatchEntry(entries); Match match = builder.build(); return match; } @@ -360,14 +376,16 @@ public void testStandardMatchType() { */ @Test(expected=IllegalStateException.class) public void testSerializeExperimenterMatchEntry() { - List entries = new ArrayList<>(); - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(ExperimenterClass.class); builder.setOxmMatchField(OxmMatchFieldClass.class); builder.setHasMask(true); - ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); + ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder(); + ExperimenterBuilder expBuilder = new ExperimenterBuilder(); + expBuilder.setExperimenter(new ExperimenterId(42L)); + caseBuilder.setExperimenter(expBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); entries.add(builder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index f4a37a52..99d297c7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -17,12 +17,12 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; @@ -32,12 +32,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; /** * @author michal.polkorab @@ -130,14 +130,14 @@ public void testExperimenterInstructionKeyMaker() { */ @Test public void testMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); Assert.assertNotNull("Null keyMaker", keyMaker); - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(OpenflowBasicClass.class); builder.setOxmMatchField(InPort.class); builder.setHasMask(true); - MatchEntries entry = builder.build(); + MatchEntry entry = builder.build(); MessageTypeKey key = keyMaker.make(entry); Assert.assertNotNull("Null key", key); @@ -151,17 +151,19 @@ public void testMatchEntriesKeyMaker() { */ @Test public void testExperimenterMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); Assert.assertNotNull("Null keyMaker", keyMaker); - MatchEntriesBuilder builder = new MatchEntriesBuilder(); + MatchEntryBuilder builder = new MatchEntryBuilder(); builder.setOxmClass(ExperimenterClass.class); builder.setOxmMatchField(OxmMatchFieldClass.class); builder.setHasMask(true); - ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); - MatchEntries entry = builder.build(); + ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder(); + ExperimenterBuilder expBuilder = new ExperimenterBuilder(); + expBuilder.setExperimenter(new ExperimenterId(42L)); + caseBuilder.setExperimenter(expBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + MatchEntry entry = builder.build(); MessageTypeKey key = keyMaker.make(entry); Assert.assertNotNull("Null key", key); diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index e83bac83..36a8d277 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -19,7 +19,6 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; @@ -192,8 +191,8 @@ public void onPacketInMessage(PacketInMessage notification) { LOGGER.debug("Reason: " + notification.getReason()); LOGGER.debug("TableId: " + notification.getTableId()); LOGGER.debug("Cookie: " + notification.getCookie()); - LOGGER.debug("Class: " + notification.getMatch().getMatchEntries().get(0).getOxmClass()); - LOGGER.debug("Field: " + notification.getMatch().getMatchEntries().get(0).getOxmMatchField()); + LOGGER.debug("Class: " + notification.getMatch().getMatchEntry().get(0).getOxmClass()); + LOGGER.debug("Field: " + notification.getMatch().getMatchEntry().get(0).getOxmMatchField()); LOGGER.debug("Datasize: " + notification.getData().length); } From 5f5622e79402f70a944fa93fd7ee2d84d1776b08 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 9 Jan 2015 09:04:07 +0100 Subject: [PATCH 141/285] Bug 2756 - Action model update Change-Id: I63b715c3de85201bb351f9468dea1bedcef702b4 Signed-off-by: Michal Polkorab --- .../api/keys/ActionDeserializerKey.java | 2 +- .../api/keys/ActionSerializerKey.java | 6 +- .../keys/ExperimenterActionSerializerKey.java | 8 +- .../src/main/yang/openflow-action.yang | 299 +++++++++++------- .../src/main/yang/openflow-augments.yang | 97 +----- .../src/main/yang/openflow-protocol.yang | 1 - .../EnhancedMessageTypeKeyTest.java | 35 +- .../api/keys/ActionDeserializerKeyTest.java | 2 +- .../api/keys/ActionSerializerKeyTest.java | 35 +- .../protocol/api/keys/KeysTest.java | 8 +- .../ExperimenterActionSerializerKeyTest.java | 5 +- .../action/AbstractActionDeserializer.java | 13 +- .../AbstractEthertypeActionDeserializer.java | 38 --- .../AbstractHeaderActionDeserializer.java | 33 -- ...10AbstractIpAddressActionDeserializer.java | 45 --- ...0AbstractMacAddressActionDeserializer.java | 46 --- .../OF10AbstractPortActionDeserializer.java | 43 --- .../action/OF10EnqueueActionDeserializer.java | 34 +- .../action/OF10OutputActionDeserializer.java | 32 +- .../OF10SetDlDstActionDeserializer.java | 34 +- .../OF10SetDlSrcActionDeserializer.java | 34 +- .../OF10SetNwDstActionDeserializer.java | 30 +- .../OF10SetNwSrcActionDeserializer.java | 30 +- .../OF10SetNwTosActionDeserializer.java | 25 +- .../OF10SetTpDstActionDeserializer.java | 31 +- .../OF10SetTpSrcActionDeserializer.java | 30 +- .../OF10SetVlanPcpActionDeserializer.java | 29 +- .../OF10SetVlanVidActionDeserializer.java | 29 +- .../OF10StripVlanActionDeserializer.java | 25 +- .../OF13CopyTtlInActionDeserializer.java | 25 +- .../OF13CopyTtlOutActionDeserializer.java | 25 +- .../OF13DecMplsTtlActionDeserializer.java | 25 +- .../OF13DecNwTtlActionDeserializer.java | 25 +- .../action/OF13GroupActionDeserializer.java | 26 +- .../action/OF13OutputActionDeserializer.java | 32 +- .../action/OF13PopMplsActionDeserializer.java | 31 +- .../action/OF13PopPbbActionDeserializer.java | 25 +- .../action/OF13PopVlanActionDeserializer.java | 25 +- .../OF13PushMplsActionDeserializer.java | 31 +- .../action/OF13PushPbbActionDeserializer.java | 31 +- .../OF13PushVlanActionDeserializer.java | 31 +- .../OF13SetFieldActionDeserializer.java | 26 +- .../OF13SetMplsTtlActionDeserializer.java | 24 +- .../OF13SetNwTtlActionDeserializer.java | 24 +- .../OF13SetQueueActionDeserializer.java | 24 +- .../MultipartReplyMessageFactory.java | 2 +- .../OF10StatsReplyMessageFactory.java | 2 +- ...AbstractActionInstructionDeserializer.java | 2 +- .../ClearActionsInstructionDeserializer.java | 2 +- .../serialization/ActionsInitializer.java | 111 +++---- .../action/AbstractActionSerializer.java | 2 +- .../AbstractEthertypeActionSerializer.java | 35 -- .../AbstractHeaderActionSerializer.java | 32 -- ...OF10AbstractIpAddressActionSerializer.java | 32 -- ...F10AbstractMacAddressActionSerializer.java | 32 -- .../OF10AbstractPortActionSerializer.java | 30 -- .../action/OF10EnqueueActionSerializer.java | 13 +- .../action/OF10OutputActionSerializer.java | 13 +- .../action/OF10SetDlDstActionSerializer.java | 15 +- .../action/OF10SetDlSrcActionSerializer.java | 15 +- .../action/OF10SetNwDstActionSerializer.java | 18 +- .../action/OF10SetNwSrcActionSerializer.java | 19 +- .../action/OF10SetNwTosActionSerializer.java | 6 +- .../action/OF10SetTpDstActionSerializer.java | 14 +- .../action/OF10SetTpSrcActionSerializer.java | 14 +- .../OF10SetVlanPcpActionSerializer.java | 6 +- .../OF10SetVlanVidActionSerializer.java | 6 +- .../action/OF10StripVlanActionSerializer.java | 16 +- .../action/OF13CopyTtlInActionSerializer.java | 16 +- .../OF13CopyTtlOutActionSerializer.java | 16 +- .../OF13DecMplsTtlActionSerializer.java | 16 +- .../action/OF13DecNwTtlActionSerializer.java | 16 +- .../action/OF13GroupActionSerializer.java | 7 +- .../action/OF13OutputActionSerializer.java | 12 +- .../action/OF13PopMplsActionSerializer.java | 19 +- .../action/OF13PopPbbActionSerializer.java | 16 +- .../action/OF13PopVlanActionSerializer.java | 16 +- .../action/OF13PushMplsActionSerializer.java | 19 +- .../action/OF13PushPbbActionSerializer.java | 19 +- .../action/OF13PushVlanActionSerializer.java | 19 +- .../action/OF13SetFieldActionSerializer.java | 8 +- .../OF13SetMplsTtlActionSerializer.java | 9 +- .../action/OF13SetNwTtlActionSerializer.java | 7 +- .../action/OF13SetQueueActionSerializer.java | 8 +- .../MultipartRequestInputFactory.java | 2 +- .../OF10FlowModInputMessageFactory.java | 2 +- .../PacketOutInputMessageFactory.java | 4 +- .../AbstractActionInstructionSerializer.java | 2 +- .../util/ActionSerializerRegistryHelper.java | 4 +- .../impl/util/TypeKeyMakerFactory.java | 17 +- .../SwitchConnectionProviderImpl02Test.java | 2 +- .../MultipartReplyMessageFactoryTest.java | 201 +++++------- .../OF10StatsReplyMessageFactoryTest.java | 25 +- .../OF13SetFieldActionSerializerTest.java | 22 +- .../FlowModInputMessageFactoryTest.java | 24 +- .../OF10FlowModInputMessageFactoryTest.java | 32 +- .../OF10PacketOutInputMessageFactoryTest.java | 28 +- .../PacketOutInputMessageFactoryTest.java | 22 +- .../MultipartRequestTableFeaturesTest.java | 8 +- .../impl/util/ActionsDeserializerTest.java | 117 ++++--- .../util/InstructionsDeserializerTest.java | 37 ++- .../impl/util/ListSerializerTest.java | 2 +- .../util/OF10ActionsDeserializerTest.java | 95 +++--- .../impl/util/OF10ActionsSerializerTest.java | 163 +++++----- .../impl/util/OF13ActionsSerializerTest.java | 190 +++++------ .../util/OF13InstructionsSerializerTest.java | 56 ++-- .../impl/util/TypeKeyMakerFactoryTest.java | 29 +- 107 files changed, 1693 insertions(+), 1560 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index 17e2358b..208a1227 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index affd4207..f23c01c6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -8,14 +8,14 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * @param action type */ -public class ActionSerializerKey extends MessageTypeKey { +public class ActionSerializerKey extends MessageTypeKey { private Class actionType; private Long experimenterId; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java index 32a1afd3..b07c696a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterActionSerializerKey.java @@ -8,13 +8,13 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; /** * @author michal.polkorab */ -public final class ExperimenterActionSerializerKey extends ActionSerializerKey +public final class ExperimenterActionSerializerKey extends ActionSerializerKey implements ExperimenterSerializerKey { private Class actionSubType; @@ -25,7 +25,7 @@ public final class ExperimenterActionSerializerKey extends ActionSerializerKey actionSubType) { - super(msgVersion, Experimenter.class, experimenterId); + super(msgVersion, ExperimenterIdCase.class, experimenterId); this.actionSubType = actionSubType; } diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 0f579fa0..4655d15a 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -10,144 +10,199 @@ namespace "urn:opendaylight:openflow:common:action"; prefix "ofaction"; + import ietf-inet-types {prefix inet;} + import ietf-yang-types {prefix yang;} + import openflow-types { prefix oft; } + import openflow-extensible-match { prefix oxm;} - revision "2013-07-31" { + revision "2015-02-03" { description "OpenFlow 1.3 - action model"; } - identity output { - description " Output to switch port. (both OF v1.0 and v1.3)"; - base oft:action-base; - } - identity copy_ttl_out { - description " Copy TTL \"outwards\" -- from next-to-outermost to outermost "; - base oft:action-base; - } - identity copy_ttl_in { - description " Copy TTL \"inwards\" -- from outermost to next-to-outermost "; - base oft:action-base; - } - identity set_mpls_ttl { - description " MPLS TTL "; - base oft:action-base; - } - identity dec_mpls_ttl { - description " Decrement MPLS TTL "; - base oft:action-base; - } - identity push_vlan { - description " Push a new VLAN tag "; - base oft:action-base; - } - identity pop_vlan { - description " Pop the outer VLAN tag "; - base oft:action-base; - } - identity push_mpls { - description " Push a new MPLS tag "; - base oft:action-base; - } - identity pop_mpls { - description " Pop the outer MPLS tag "; - base oft:action-base; - } - identity set_queue { - description " Set queue id when outputting to a port "; - base oft:action-base; - } - identity group { - description " Apply group. "; - base oft:action-base; - } - identity set_nw_ttl { - description " IP TTL. "; - base oft:action-base; - } - identity dec_nw_ttl { - description " Decrement IP TTL. "; - base oft:action-base; - } - identity set_field { - description " Set a header field using OXM TLV format. "; - base oft:action-base; - } - identity push_pbb { - description " Push a new PBB service tag (I-TAG) "; - base oft:action-base; - } - identity pop_pbb { - description " Pop the outer PBB service tag (I-TAG) "; - base oft:action-base; - } - identity experimenter { - description ""; - base oft:action-base; - } - identity experimenter-action-sub-type { description "The base identity for vendor's actions."; } - container actions-container { - uses actions-grouping; + container action-container { + uses action-grouping; } grouping actions-grouping { list action { - config false; - leaf type { - type identityref { - base oft:action-base; - } - } + uses action-grouping; } } - // OF1.0 structures - identity set_vlan_vid { - description "Set the 802.1q VLAN id (OF v1.0)."; - base oft:action-base; - } - identity set_vlan_pcp { - description "Set the 802.1q priority (OF v1.0)."; - base oft:action-base; - } - identity strip_vlan { - description "Strip the 802.1q header (OF v1.0)."; - base oft:action-base; - } - identity set_dl_src { - description "Ethernet source address (OF v1.0)."; - base oft:action-base; - } - identity set_dl_dst { - description "Ethernet destination address (OF v1.0)."; - base oft:action-base; - } - identity set_nw_src { - description "IP source address (OF v1.0)."; - base oft:action-base; - } - identity set_nw_dst { - description "IP destination address (OF v1.0)."; - base oft:action-base; - } - identity set_nw_tos { - description "IP ToS (DSCP field, 6 bits) (OF v1.0)."; - base oft:action-base; - } - identity set_tp_src { - description "TCP/UDP source port (OF v1.0)."; - base oft:action-base; - } - identity set_tp_dst { - description "TCP/UDP destination port (OF v1.0)."; - base oft:action-base; - } - identity enqueue { - description "Output to queue (OF v1.0)."; - base oft:action-base; + grouping action-grouping { + choice action-choice { + case output-action-case { + container output-action { + leaf port { + type oft:port-number; + } + leaf max-length { + type uint16; + } + } + } + case copy-ttl-out-case { + // empty action + } + case copy-ttl-in-case { + // empty action + } + case set-mpls-ttl-case { + container set-mpls-ttl-action { + leaf mpls-ttl { + type uint8; + } + } + } + case dec-mpls-ttl-case { + // empty action + } + case push-vlan-case { + container push-vlan-action { + leaf ethertype { + type oft:ether-type; + } + } + } + case pop-vlan-case { + // empty action + } + case push-mpls-case { + container push-mpls-action { + leaf ethertype { + type oft:ether-type; + } + } + } + case pop-mpls-case { + container pop-mpls-action { + leaf ethertype { + type oft:ether-type; + } + } + } + case set-queue-case { + container set-queue-action { + leaf queue-id { + type uint32; + } + } + } + case group-case { + container group-action { + leaf group-id { + type uint32; + } + } + } + case set-nw-ttl-case { + container set-nw-ttl-action { + leaf nw-ttl { + type uint8; + } + } + } + case dec-nw-ttl-case { + // empty action + } + case set-field-case { + container set-field-action { + uses oxm:match-entries-grouping; + } + } + case push-pbb-case { + container push-pbb-action { + leaf ethertype { + type oft:ether-type; + } + } + } + case pop-pbb-case { + // empty action + } + // OF1.0 structures + case set-vlan-vid-case { + container set-vlan-vid-action { + leaf vlan-vid { + type uint16; + } + } + } + case set-vlan-pcp-case { + container set-vlan-pcp-action { + leaf vlan-pcp { + type uint8; + } + } + } + case strip-vlan-case { + // empty action + } + case set-dl-src-case { + container set-dl-src-action { + leaf dl-src-address { + type yang:mac-address; + } + } + } + case set-dl-dst-case { + container set-dl-dst-action { + leaf dl-dst-address { + type yang:mac-address; + } + } + } + case set-nw-src-case { + container set-nw-src-action { + leaf ip-address { + type inet:ipv4-address; + } + } + } + case set-nw-dst-case { + container set-nw-dst-action { + leaf ip-address { + type inet:ipv4-address; + } + } + } + case set-nw-tos-case { + container set-nw-tos-action { + leaf nw-tos { + type uint8; + } + } + } + case set-tp-src-case { + container set-tp-src-action { + leaf port { + type oft:port-number; + } + } + } + case set-tp-dst-case { + container set-tp-dst-action { + leaf port { + type oft:port-number; + } + } + } + case enqueue-case { + container enqueue-action { + leaf port { + type oft:port-number; + } + leaf queue-id { + type oft:queue-id; + } + } + } + } } } diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index d90e4400..292bd961 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -40,92 +40,19 @@ } // OFP_ACTION AUGMENTS - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "port-action"; - leaf port { - type oft:port-number; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "max-length-action"; - leaf max-length { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "mpls-ttl-action"; - leaf mpls-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ethertype-action"; - leaf ethertype { - type oft:ether-type; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "queue-id-action"; - leaf queue-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "group-id-action"; - leaf group-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-ttl-action"; - leaf nw-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "oxm-fields-action"; - uses oxm:match-entries-grouping; - } - augment "/ofaction:actions-container/ofaction:action" { + augment "/ofaction:action-container/ofaction:action-choice" { ext:augment-identifier "experimenter-id-action"; - leaf experimenter { - type oft:experimenter-id; - } - leaf sub-type { - type identityref { - base ofaction:experimenter-action-sub-type; - } - } - } - // OF1.0 structures - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-vid-action"; - leaf vlan-vid { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-pcp-action"; - leaf vlan-pcp { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "dl-address-action"; - leaf dl-address { - type yang:mac-address; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-tos-action"; - leaf nw-tos { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ip-address-action"; - leaf ip-address { - type inet:ipv4-address; + case experimenter-id-case { + container experimenter { + leaf experimenter { + type oft:experimenter-id; + } + leaf sub-type { + type identityref { + base ofaction:experimenter-action-sub-type; + } + } + } } } diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 34f21818..9c9dbf0e 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -386,7 +386,6 @@ uses ofHeader; uses ofaction:actions-grouping; - leaf data { type binary; } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index 483597c6..20233893 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -11,9 +11,9 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -28,24 +28,24 @@ public class EnhancedMessageTypeKeyTest { @Test public void test() { EnhancedMessageTypeKey key1 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); EnhancedMessageTypeKey key2 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, OutputActionCase.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, OutputActionCase.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, OutputActionCase.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetFieldCase.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } @@ -57,16 +57,16 @@ public void test() { public void testEquals() { EnhancedMessageTypeKey key1; EnhancedMessageTypeKey key2; - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetFieldCase.class); Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); } @@ -76,10 +76,11 @@ public void testEquals() { @Test public void testToString() { EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, - Action.class, Output.class); + Action.class, OutputActionCase.class); - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action msgType2:" + + " org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action" + + ".grouping.action.choice.OutputActionCase", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 3b2be12c..84760e8b 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -64,7 +64,7 @@ public void testToString(){ ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" + + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action msgType: 11" + " experimenterID: null", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index 1a1021a1..caade81e 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -11,8 +11,8 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; /** * @author michal.polkorab @@ -25,25 +25,25 @@ public class ActionSerializerKeyTest { */ @Test public void test() { - ActionSerializerKey key1 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key1 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 42L); ActionSerializerKey key2 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 42L); Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOutCase.class, 42L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, 55L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); + key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlInCase.class, 55L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } @@ -54,16 +54,17 @@ public void test() { @Test public void testEquals(){ ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + CopyTtlInCase.class, 42L); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); } @@ -72,10 +73,12 @@ public void testEquals(){ */ @Test public void testToString(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + CopyTtlInCase.class, 42L); - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action action type:" + + " org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action" + + ".grouping.action.choice.CopyTtlInCase experimenterID: 42", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index fdf0f38f..09ecbda4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -4,8 +4,8 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -46,8 +46,8 @@ public void testEqualsAndHashcodeOfDeserializerKeys() { */ @Test public void testEqualsAndHashcodeOfActionDeserializerKeys() { - ActionSerializerKey actionSerializerKey = new ActionSerializerKey<>( - EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L); + ActionSerializerKey actionSerializerKey = new ActionSerializerKey<>( + EncodeConstants.OF13_VERSION_ID, ExperimenterIdCase.class, 1L); ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey( EncodeConstants.OF13_VERSION_ID, 1L, ExpSubType.class); Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index 6c469573..e3e910ca 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; /** * @author michal.polkorab @@ -49,6 +49,9 @@ public void test() { Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); } + /** + * Test ExperimenterActionSerializerKey equals + */ @Test public void testEquals() { ExperimenterActionSerializerKey key1; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java index 9dbd5790..10c65f5b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java @@ -13,9 +13,9 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -27,12 +27,11 @@ public abstract class AbstractActionDeserializer implements OFDeserializer getType(); + protected abstract ActionChoice getType(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java deleted file mode 100644 index e97d2a77..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthertypeAction.class, etherType.build()); - input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java deleted file mode 100644 index 664dfbe3..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java deleted file mode 100644 index 94c5dcaf..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yangtools.yang.binding.Augmentation; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(final ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(IpAddressAction.class, - createNwAddressAugmentationAndPad(input)); - return builder.build(); - } - - private static Augmentation createNwAddressAugmentationAndPad(final ByteBuf input) { - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - return ipBuilder.build(); - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java deleted file mode 100644 index 46022f0c..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input)); - return builder.build(); - } - - private static DlAddressAction createDlAugmentationAndPad(ByteBuf input) { - DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - dlBuilder.setDlAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); - input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - return dlBuilder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java deleted file mode 100644 index 9511a0c2..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); - return builder.build(); - } - - protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) { - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index cec5f70c..d4416dcd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -12,36 +12,38 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; /** * @author michal.polkorab * */ -public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer { +public class OF10EnqueueActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + EnqueueCaseBuilder caseBuilder = new EnqueueCaseBuilder(); + EnqueueActionBuilder actionBuilder = new EnqueueActionBuilder(); + actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + actionBuilder.setQueueId(new QueueId(input.readUnsignedInt())); + caseBuilder.setEnqueueAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return Enqueue.class; + protected ActionChoice getType() { + return new OutputActionCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index 0993bbac..073e9c5f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -11,35 +11,35 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; /** * @author michal.polkorab * */ -public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer { +public class OF10OutputActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder actionBuilder = new OutputActionBuilder(); + actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.setMaxLength(input.readUnsignedShort()); + caseBuilder.setOutputAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return Output.class; + protected ActionChoice getType() { + return new OutputActionCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java index 95762dc1..29f640f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java @@ -8,18 +8,42 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer { +public class OF10SetDlDstActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetDlDstCaseBuilder caseBuilder = new SetDlDstCaseBuilder(); + SetDlDstActionBuilder actionBuilder = new SetDlDstActionBuilder(); + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + actionBuilder.setDlDstAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + caseBuilder.setSetDlDstAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + return builder.build(); + } @Override - protected Class getType() { - return SetDlDst.class; + protected ActionChoice getType() { + return new SetDlDstCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java index 9d3d9c80..6e2428a4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java @@ -8,18 +8,42 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer { +public class OF10SetDlSrcActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetDlSrcCaseBuilder caseBuilder = new SetDlSrcCaseBuilder(); + SetDlSrcActionBuilder actionBuilder = new SetDlSrcActionBuilder(); + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + actionBuilder.setDlSrcAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + caseBuilder.setSetDlSrcAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + return builder.build(); + } @Override - protected Class getType() { - return SetDlSrc.class; + protected ActionChoice getType() { + return new SetDlSrcCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java index 97e1c6bb..1bd01e86 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java @@ -8,18 +8,38 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer { +public class OF10SetNwDstActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(final ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetNwDstCaseBuilder caseBuilder = new SetNwDstCaseBuilder(); + SetNwDstActionBuilder actionBuilder = new SetNwDstActionBuilder(); + actionBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + caseBuilder.setSetNwDstAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + return builder.build(); + } @Override - protected Class getType() { - return SetNwDst.class; + protected ActionChoice getType() { + return new SetNwDstCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java index 55d1e76d..a5899c7a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java @@ -8,18 +8,38 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer { +public class OF10SetNwSrcActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(final ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetNwSrcCaseBuilder caseBuilder = new SetNwSrcCaseBuilder(); + SetNwSrcActionBuilder actionBuilder = new SetNwSrcActionBuilder(); + actionBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + caseBuilder.setSetNwSrcAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + return builder.build(); + } @Override - protected Class getType() { - return SetNwSrc.class; + protected ActionChoice getType() { + return new SetNwSrcCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index 79da6a3e..bec85f50 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -12,12 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -28,19 +27,19 @@ public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetNwTosCaseBuilder caseBuilder = new SetNwTosCaseBuilder(); + SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder(); tosBuilder.setNwTos(input.readUnsignedByte()); - builder.addAugmentation(NwTosAction.class, tosBuilder.build()); + caseBuilder.setSetNwTosAction(tosBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); return builder.build(); } @Override - protected Class getType() { - return SetNwTos.class; + protected ActionChoice getType() { + return new SetNwTosCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java index 0bb20dbf..39643a88 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java @@ -8,18 +8,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; /** * @author michal.polkorab * */ -public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer { +public class OF10SetTpDstActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetTpDstCaseBuilder caseBuilder = new SetTpDstCaseBuilder(); + SetTpDstActionBuilder actionBuilder = new SetTpDstActionBuilder(); + actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + caseBuilder.setSetTpDstAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); + return builder.build(); + } @Override - protected Class getType() { - return SetTpDst.class; + protected ActionChoice getType() { + return new SetTpDstCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java index 3fce85bd..b07f69fc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java @@ -8,18 +8,38 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; /** * @author michal.polkorab * */ -public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer { +public class OF10SetTpSrcActionDeserializer extends AbstractActionDeserializer { @Override - protected Class getType() { - return SetTpSrc.class; + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetTpSrcCaseBuilder caseBuilder = new SetTpSrcCaseBuilder(); + SetTpSrcActionBuilder actionBuilder = new SetTpSrcActionBuilder(); + actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + caseBuilder.setSetTpSrcAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); + return builder.build(); } + @Override + protected ActionChoice getType() { + return new SetTpSrcCaseBuilder().build(); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index afa3dca0..5431f1ba 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -12,12 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -27,20 +26,20 @@ public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer @Override public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder(); - vlanBuilder.setVlanPcp(input.readUnsignedByte()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetVlanPcpCaseBuilder caseBuilder = new SetVlanPcpCaseBuilder(); + SetVlanPcpActionBuilder actionBuilder = new SetVlanPcpActionBuilder(); + actionBuilder.setVlanPcp(input.readUnsignedByte()); + caseBuilder.setSetVlanPcpAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); - builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return SetVlanPcp.class; + protected ActionChoice getType() { + return new SetVlanPcpCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index 33683519..5bef7e19 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -12,12 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -27,20 +26,20 @@ public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer @Override public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(input.readUnsignedShort()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + SetVlanVidCaseBuilder caseBuilder = new SetVlanVidCaseBuilder(); + SetVlanVidActionBuilder actionBuilder = new SetVlanVidActionBuilder(); + actionBuilder.setVlanVid(input.readUnsignedShort()); + caseBuilder.setSetVlanVidAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); - builder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return SetVlanVid.class; + protected ActionChoice getType() { + return new SetVlanVidCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java index dea7afa5..d7c94e9f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF10StripVlanActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return StripVlan.class; + protected ActionChoice getType() { + return new StripVlanCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java index a869084d..dbf2cc9e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13CopyTtlInActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return CopyTtlIn.class; + protected ActionChoice getType() { + return new CopyTtlInCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java index b066b215..a5997fca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13CopyTtlOutActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return CopyTtlOut.class; + protected ActionChoice getType() { + return new CopyTtlOutCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java index 6467e1e6..2f193962 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13DecMplsTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return DecMplsTtl.class; + protected ActionChoice getType() { + return new DecMplsTtlCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java index f920f577..d2b9cf7c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13DecNwTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return DecNwTtl.class; + protected ActionChoice getType() { + return new DecNwTtlCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index 43bbcf5a..15455bbc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -11,12 +11,11 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -26,18 +25,19 @@ public class OF13GroupActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(input.readUnsignedInt()); - builder.addAugmentation(GroupIdAction.class, group.build()); + GroupCaseBuilder caseBuilder = new GroupCaseBuilder(); + GroupActionBuilder actionBuilder = new GroupActionBuilder(); + actionBuilder.setGroupId(input.readUnsignedInt()); + caseBuilder.setGroupAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return Group.class; + protected ActionChoice getType() { + return new GroupCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index f2f2c0b0..47f0c72a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -12,14 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; /** @@ -30,22 +27,21 @@ public class OF13OutputActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder actionBuilder = new OutputActionBuilder(); + actionBuilder.setPort(new PortNumber(input.readUnsignedInt())); + actionBuilder.setMaxLength(input.readUnsignedShort()); + caseBuilder.setOutputAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.OUTPUT_PADDING); return builder.build(); } @Override - protected Class getType() { - return Output.class; + protected ActionChoice getType() { + return new OutputActionCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java index 218bedbb..3ab74229 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java @@ -8,18 +8,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; /** * @author michal.polkorab * */ -public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer { +public class OF13PopMplsActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PopMplsCaseBuilder caseBuilder = new PopMplsCaseBuilder(); + PopMplsActionBuilder mplsBuilder = new PopMplsActionBuilder(); + mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort())); + caseBuilder.setPopMplsAction(mplsBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } @Override - protected Class getType() { - return PopMpls.class; + protected ActionChoice getType() { + return new PopMplsCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java index 7ba8e324..d67923b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13PopPbbActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return PopPbb.class; + protected ActionChoice getType() { + return new PopPbbCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java index 69543ede..28ad4490 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java @@ -8,18 +8,33 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab * */ -public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer { +public class OF13PopVlanActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setActionChoice(getType()); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } @Override - protected Class getType() { - return PopVlan.class; + protected ActionChoice getType() { + return new PopVlanCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java index 38ac1821..9419181f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java @@ -8,18 +8,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; /** * @author michal.polkorab * */ -public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer { +public class OF13PushMplsActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PushMplsCaseBuilder caseBuilder = new PushMplsCaseBuilder(); + PushMplsActionBuilder mplsBuilder = new PushMplsActionBuilder(); + mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort())); + caseBuilder.setPushMplsAction(mplsBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } @Override - protected Class getType() { - return PushMpls.class; + protected ActionChoice getType() { + return new PushMplsCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java index 40cf71dc..085bbd7b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java @@ -8,18 +8,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; /** * @author michal.polkorab * */ -public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer { +public class OF13PushPbbActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PushPbbCaseBuilder caseBuilder = new PushPbbCaseBuilder(); + PushPbbActionBuilder pbbBuilder = new PushPbbActionBuilder(); + pbbBuilder.setEthertype(new EtherType(input.readUnsignedShort())); + caseBuilder.setPushPbbAction(pbbBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } @Override - protected Class getType() { - return PushPbb.class; + protected ActionChoice getType() { + return new PushPbbCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java index 8b9bbdda..d45356dd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java @@ -8,18 +8,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; /** * @author michal.polkorab * */ -public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer { +public class OF13PushVlanActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PushVlanCaseBuilder caseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder(); + vlanBuilder.setEthertype(new EtherType(input.readUnsignedShort())); + caseBuilder.setPushVlanAction(vlanBuilder.build()); + builder.setActionChoice(caseBuilder.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } @Override - protected Class getType() { - return PushVlan.class; + protected ActionChoice getType() { + return new PushVlanCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 5a1a533a..442f6d94 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -18,12 +18,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; /** @@ -37,11 +36,11 @@ public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer @Override public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); int startIndex = input.readerIndex(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder(); + SetFieldActionBuilder actionBuilder = new SetFieldActionBuilder(); int oxmClass = input.getUnsignedShort(input.readerIndex()); // get oxm_field & hasMask byte and extract the field value int oxmField = input.getUnsignedByte(input.readerIndex() @@ -56,8 +55,9 @@ public Action deserialize(ByteBuf input) { OFDeserializer matchDeserializer = registry.getDeserializer(key); List entry = new ArrayList<>(); entry.add(matchDeserializer.deserialize(input)); - matchEntries.setMatchEntry(entry); - builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actionBuilder.setMatchEntry(entry); + caseBuilder.setSetFieldAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; if (paddingRemainder != 0) { input.skipBytes(EncodeConstants.PADDING - paddingRemainder); @@ -66,8 +66,8 @@ public Action deserialize(ByteBuf input) { } @Override - protected Class getType() { - return SetField.class; + protected ActionChoice getType() { + return new SetFieldCaseBuilder().build(); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index 4f1bb2ea..2f5abcb9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -12,12 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -28,18 +27,19 @@ public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl(input.readUnsignedByte()); - builder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + SetMplsTtlCaseBuilder caseBuilder = new SetMplsTtlCaseBuilder(); + SetMplsTtlActionBuilder actionBuilder = new SetMplsTtlActionBuilder(); + actionBuilder.setMplsTtl(input.readUnsignedByte()); + caseBuilder.setSetMplsTtlAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); return builder.build(); } @Override - protected Class getType() { - return SetMplsTtl.class; + protected ActionChoice getType() { + return new SetMplsTtlCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index 8d8915e2..9d1bcaa7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -12,12 +12,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -28,18 +27,19 @@ public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl(input.readUnsignedByte()); - builder.addAugmentation(NwTtlAction.class, nwTtl.build()); + SetNwTtlCaseBuilder caseBuilder = new SetNwTtlCaseBuilder(); + SetNwTtlActionBuilder actionBuilder = new SetNwTtlActionBuilder(); + actionBuilder.setNwTtl(input.readUnsignedByte()); + caseBuilder.setSetNwTtlAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); return builder.build(); } @Override - protected Class getType() { - return SetNwTtl.class; + protected ActionChoice getType() { + return new SetNwTtlCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index d71b5d68..38d2b77d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -11,12 +11,11 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; /** * @author michal.polkorab @@ -27,17 +26,18 @@ public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { @Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueId.build()); + SetQueueCaseBuilder caseBuilder = new SetQueueCaseBuilder(); + SetQueueActionBuilder actionBuilder = new SetQueueActionBuilder(); + actionBuilder.setQueueId(input.readUnsignedInt()); + caseBuilder.setSetQueueAction(actionBuilder.build()); + builder.setActionChoice(caseBuilder.build()); return builder.build(); } @Override - protected Class getType() { - return SetQueue.class; + protected ActionChoice getType() { + return new SetQueueCaseBuilder().build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 1d071396..b6e24b45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -35,7 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 728a3098..691a270f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -25,7 +25,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.OF10MatchDeserializer; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 24950a0d..10ba7c2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -21,7 +21,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index 3e0ebc5f..b3c29c8d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index 51539db5..91de3e43 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -38,33 +38,34 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase; +//import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; /** * Initializes serializer registry with action serializers @@ -84,36 +85,36 @@ public static void registerActionSerializers(SerializerRegistry serializerRegist // register OF v1.0 action serializers ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( EncodeConstants.OF10_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); - helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); - helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); - helper.registerSerializer(StripVlan.class, new OF10StripVlanActionSerializer()); - helper.registerSerializer(SetDlSrc.class, new OF10SetDlSrcActionSerializer()); - helper.registerSerializer(SetDlDst.class, new OF10SetDlDstActionSerializer()); - helper.registerSerializer(SetNwSrc.class, new OF10SetNwSrcActionSerializer()); - helper.registerSerializer(SetNwDst.class, new OF10SetNwDstActionSerializer()); - helper.registerSerializer(SetNwTos.class, new OF10SetNwTosActionSerializer()); - helper.registerSerializer(SetTpSrc.class, new OF10SetTpSrcActionSerializer()); - helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); - helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); + helper.registerSerializer(OutputActionCase.class, new OF10OutputActionSerializer()); + helper.registerSerializer(SetVlanVidCase.class, new OF10SetVlanVidActionSerializer()); + helper.registerSerializer(SetVlanPcpCase.class, new OF10SetVlanPcpActionSerializer()); + helper.registerSerializer(StripVlanCase.class, new OF10StripVlanActionSerializer()); + helper.registerSerializer(SetDlSrcCase.class, new OF10SetDlSrcActionSerializer()); + helper.registerSerializer(SetDlDstCase.class, new OF10SetDlDstActionSerializer()); + helper.registerSerializer(SetNwSrcCase.class, new OF10SetNwSrcActionSerializer()); + helper.registerSerializer(SetNwDstCase.class, new OF10SetNwDstActionSerializer()); + helper.registerSerializer(SetNwTosCase.class, new OF10SetNwTosActionSerializer()); + helper.registerSerializer(SetTpSrcCase.class, new OF10SetTpSrcActionSerializer()); + helper.registerSerializer(SetTpDstCase.class, new OF10SetTpDstActionSerializer()); + helper.registerSerializer(EnqueueCase.class, new OF10EnqueueActionSerializer()); // register OF v1.0 action serializers helper = new ActionSerializerRegistryHelper( EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); - helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); - helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); - helper.registerSerializer(SetMplsTtl.class, new OF13SetMplsTtlActionSerializer()); - helper.registerSerializer(DecMplsTtl.class, new OF13DecMplsTtlActionSerializer()); - helper.registerSerializer(PushVlan.class, new OF13PushVlanActionSerializer()); - helper.registerSerializer(PopVlan.class, new OF13PopVlanActionSerializer()); - helper.registerSerializer(PushMpls.class, new OF13PushMplsActionSerializer()); - helper.registerSerializer(PopMpls.class, new OF13PopMplsActionSerializer()); - helper.registerSerializer(SetQueue.class, new OF13SetQueueActionSerializer()); - helper.registerSerializer(Group.class, new OF13GroupActionSerializer()); - helper.registerSerializer(SetNwTtl.class, new OF13SetNwTtlActionSerializer()); - helper.registerSerializer(DecNwTtl.class, new OF13DecNwTtlActionSerializer()); - helper.registerSerializer(SetField.class, new OF13SetFieldActionSerializer()); - helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); - helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); + helper.registerSerializer(OutputActionCase.class, new OF13OutputActionSerializer()); + helper.registerSerializer(CopyTtlOutCase.class, new OF13CopyTtlOutActionSerializer()); + helper.registerSerializer(CopyTtlInCase.class, new OF13CopyTtlInActionSerializer()); + helper.registerSerializer(SetMplsTtlCase.class, new OF13SetMplsTtlActionSerializer()); + helper.registerSerializer(DecMplsTtlCase.class, new OF13DecMplsTtlActionSerializer()); + helper.registerSerializer(PushVlanCase.class, new OF13PushVlanActionSerializer()); + helper.registerSerializer(PopVlanCase.class, new OF13PopVlanActionSerializer()); + helper.registerSerializer(PushMplsCase.class, new OF13PushMplsActionSerializer()); + helper.registerSerializer(PopMplsCase.class, new OF13PopMplsActionSerializer()); + helper.registerSerializer(SetQueueCase.class, new OF13SetQueueActionSerializer()); + helper.registerSerializer(GroupCase.class, new OF13GroupActionSerializer()); + helper.registerSerializer(SetNwTtlCase.class, new OF13SetNwTtlActionSerializer()); + helper.registerSerializer(DecNwTtlCase.class, new OF13DecNwTtlActionSerializer()); + helper.registerSerializer(SetFieldCase.class, new OF13SetFieldActionSerializer()); + helper.registerSerializer(PushPbbCase.class, new OF13PushPbbActionSerializer()); + helper.registerSerializer(PopPbbCase.class, new OF13PopPbbActionSerializer()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java index 0ab44159..22c96c95 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java deleted file mode 100644 index 57f3ae43..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); - outBuffer.writeShort(ethertype.getEthertype().getValue()); - outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java deleted file mode 100644 index 335d19e4..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java deleted file mode 100644 index cbc37908..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(final Action action, final ByteBuf outBuffer) { - super.serialize(action, outBuffer); - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(action.getAugmentation(IpAddressAction.class).getIpAddress().getValue()); - for (String group : addressGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java deleted file mode 100644 index cfc6088e..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action - .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java deleted file mode 100644 index 3e179228..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index 4b087681..282aca91 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -11,9 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -24,11 +23,11 @@ public class OF10EnqueueActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); + outBuffer.writeShort(((EnqueueCase) action.getActionChoice()).getEnqueueAction() + .getPort().getValue().intValue()); outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); + outBuffer.writeInt(((EnqueueCase) action.getActionChoice()).getEnqueueAction() + .getQueueId().getValue().intValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java index 83396c9e..4f90a40c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java @@ -11,9 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -24,10 +23,10 @@ public class OF10OutputActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); + outBuffer.writeShort(((OutputActionCase) action.getActionChoice()) + .getOutputAction().getPort().getValue().intValue()); + outBuffer.writeShort(((OutputActionCase) action.getActionChoice()) + .getOutputAction().getMaxLength()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java index b174b0f9..e654466a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java @@ -8,13 +8,26 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetDlDstActionSerializer extends OF10AbstractMacAddressActionSerializer { +public class OF10SetDlDstActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(((SetDlDstCase) action.getActionChoice()) + .getSetDlDstAction().getDlDstAddress().getValue())); + outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java index e9f002da..67db7d57 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java @@ -8,13 +8,26 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetDlSrcActionSerializer extends OF10AbstractMacAddressActionSerializer { +public class OF10SetDlSrcActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(((SetDlSrcCase) action.getActionChoice()) + .getSetDlSrcAction().getDlSrcAddress().getValue())); + outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java index 2494ced3..73ecd595 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java @@ -8,13 +8,29 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetNwDstActionSerializer extends OF10AbstractIpAddressActionSerializer { +public class OF10SetNwDstActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(final Action action, final ByteBuf outBuffer) { + super.serialize(action, outBuffer); + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(((SetNwDstCase) action.getActionChoice()).getSetNwDstAction() + .getIpAddress().getValue()); + for (String group : addressGroups) { + outBuffer.writeByte(Short.parseShort(group)); + } + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java index b708b163..d63bf9c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java @@ -8,18 +8,35 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetNwSrcActionSerializer extends OF10AbstractIpAddressActionSerializer { +public class OF10SetNwSrcActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(final Action action, final ByteBuf outBuffer) { + super.serialize(action, outBuffer); + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction() + .getIpAddress().getValue()); + for (String group : addressGroups) { + outBuffer.writeByte(Short.parseShort(group)); + } + } @Override protected int getType() { return ActionConstants.SET_NW_SRC_CODE; } + @Override protected int getLength() { return ActionConstants.GENERAL_ACTION_LENGTH; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index 20365dbb..8df8c573 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,7 +23,7 @@ public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); + outBuffer.writeByte(((SetNwTosCase) action.getActionChoice()).getSetNwTosAction().getNwTos()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java index 929db82b..d11a1fae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java @@ -8,13 +8,25 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetTpDstActionSerializer extends OF10AbstractPortActionSerializer { +public class OF10SetTpDstActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((SetTpDstCase) action.getActionChoice()).getSetTpDstAction() + .getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java index 7c062eae..ac6ad917 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java @@ -8,13 +8,25 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10SetTpSrcActionSerializer extends OF10AbstractPortActionSerializer { +public class OF10SetTpSrcActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((SetTpSrcCase) action.getActionChoice()).getSetTpSrcAction() + .getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 1a7683b4..eec2fdad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,7 +23,7 @@ public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); + outBuffer.writeByte(((SetVlanPcpCase) action.getActionChoice()).getSetVlanPcpAction().getVlanPcp()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index e9aac905..87ee1821 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,7 +23,7 @@ public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); + outBuffer.writeShort(((SetVlanVidCase) action.getActionChoice()).getSetVlanVidAction().getVlanVid()); outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java index d3903233..77df4755 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java @@ -8,14 +8,28 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF10StripVlanActionSerializer extends AbstractHeaderActionSerializer { +public class OF10StripVlanActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java index 59020cd1..5ea47c52 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java @@ -8,13 +8,27 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13CopyTtlInActionSerializer extends AbstractHeaderActionSerializer { +public class OF13CopyTtlInActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java index da6cf058..16e5d69b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java @@ -8,13 +8,27 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13CopyTtlOutActionSerializer extends AbstractHeaderActionSerializer { +public class OF13CopyTtlOutActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java index 6d7be277..ec89d2ad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java @@ -8,13 +8,27 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13DecMplsTtlActionSerializer extends AbstractHeaderActionSerializer { +public class OF13DecMplsTtlActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java index d1f44369..cb5e92e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java @@ -8,14 +8,28 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13DecNwTtlActionSerializer extends AbstractHeaderActionSerializer { +public class OF13DecNwTtlActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java index 86627899..05506643 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,8 +23,7 @@ public class OF13GroupActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - GroupIdAction groupId = action.getAugmentation(GroupIdAction.class); - outBuffer.writeInt(groupId.getGroupId().intValue()); + outBuffer.writeInt(((GroupCase) action.getActionChoice()).getGroupAction().getGroupId().intValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 001cf46e..05f78d98 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -11,9 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -24,10 +23,9 @@ public class OF13OutputActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeInt(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); + outBuffer.writeInt(((OutputActionCase) action.getActionChoice()).getOutputAction() + .getPort().getValue().intValue()); + outBuffer.writeShort(((OutputActionCase) action.getActionChoice()).getOutputAction().getMaxLength()); outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java index 2857b4a0..4cfebf7b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java @@ -8,13 +8,30 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PopMplsActionSerializer extends AbstractEthertypeActionSerializer { +public class OF13PopMplsActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((PopMplsCase) action.getActionChoice()) + .getPopMplsAction().getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java index 8187f226..fc3be2b9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java @@ -8,13 +8,27 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PopPbbActionSerializer extends AbstractHeaderActionSerializer { +public class OF13PopPbbActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java index 39ffd1a5..863d64a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java @@ -8,13 +8,27 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PopVlanActionSerializer extends AbstractHeaderActionSerializer { +public class OF13PopVlanActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java index 8c2bd764..f9d02757 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java @@ -8,13 +8,30 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PushMplsActionSerializer extends AbstractEthertypeActionSerializer { +public class OF13PushMplsActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((PushMplsCase) action.getActionChoice()) + .getPushMplsAction().getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java index 732a73cf..d3b68eb8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java @@ -8,13 +8,30 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PushPbbActionSerializer extends AbstractEthertypeActionSerializer { +public class OF13PushPbbActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((PushPbbCase) action.getActionChoice()) + .getPushPbbAction().getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java index 1dedb85b..696aa59f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java @@ -8,14 +8,31 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab * */ -public class OF13PushVlanActionSerializer extends AbstractEthertypeActionSerializer { +public class OF13PushVlanActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(((PushVlanCase) action.getActionChoice()) + .getPushVlanAction().getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 3e1e77f0..59a3e3df 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -17,9 +17,9 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -38,8 +38,8 @@ public void serialize(Action action, ByteBuf outBuffer) { outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); int lengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); - MatchEntry entry = oxmField.getMatchEntry().get(0); + MatchEntry entry = ((SetFieldCase) action.getActionChoice()).getSetFieldAction() + .getMatchEntry().get(0); MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); if (entry.getOxmClass().equals(ExperimenterClass.class)) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index a47a6a1a..95c950af 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -20,13 +20,10 @@ */ public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { - - @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); - outBuffer.writeByte(mplsTtl.getMplsTtl()); + outBuffer.writeByte(((SetMplsTtlCase) action.getActionChoice()).getSetMplsTtlAction().getMplsTtl()); outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index 8b36e7c0..7262fba0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,8 +23,7 @@ public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); - outBuffer.writeByte(nwTtl.getNwTtl()); + outBuffer.writeByte(((SetNwTtlCase) action.getActionChoice()).getSetNwTtlAction().getNwTtl()); outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java index aa8e9f51..8a2a0d85 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -23,8 +23,8 @@ public class OF13SetQueueActionSerializer extends AbstractActionSerializer { @Override public void serialize(Action action, ByteBuf outBuffer) { super.serialize(action, outBuffer); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); + outBuffer.writeInt(((SetQueueCase) action.getActionChoice()).getSetQueueAction() + .getQueueId().intValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index b374bef5..7afb253b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -29,7 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java index f7f8448c..790f0df9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactory.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java index 44c9249d..f229424d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactory.java @@ -13,10 +13,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 965f6eef..5a75e530 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index ffe274b3..32b6ac0e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -10,7 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; /** * @author michal.polkorab @@ -35,7 +35,7 @@ public ActionSerializerRegistryHelper(short version, SerializerRegistry serializ * @param actionType * @param serializer */ - public void registerSerializer(Class actionType, + public void registerSerializer(Class actionType, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, actionType, null), serializer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 63563de3..b5a2a4a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -14,11 +14,10 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -65,11 +64,17 @@ public static TypeKeyMaker createActionKeyMaker(short version) { return new AbstractTypeKeyMaker(version) { @Override public MessageTypeKey make(Action entry) { - if (entry.getType().equals(Experimenter.class)) { + if (entry.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow + .augments.rev150225.action.container.action.choice.ExperimenterIdCase) { + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action + .container.action.choice.ExperimenterIdCase expIdCase = (org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.augments.rev150225.action.container.action.choice + .ExperimenterIdCase) entry.getActionChoice(); return new ExperimenterActionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); + expIdCase.getExperimenter().getExperimenter().getValue(), + expIdCase.getExperimenter().getSubType()); } - return new ActionSerializerKey<>(getVersion(), entry.getType(), null); + return new ActionSerializerKey<>(getVersion(), (Class) entry.getActionChoice().getImplementedInterface(), null); } }; } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 9f4bbab5..c83e60c5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -33,7 +33,7 @@ import org.opendaylight.openflowjava.protocol.impl.core.ServerFacade; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index bad774f4..00785418 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -21,30 +21,22 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -748,27 +740,22 @@ public void testMultipartReplyGroupDescBody01(){ Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong outputType", Output.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); + Assert.assertTrue("Wrong outputType",message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof OutputActionCase); - Assert.assertEquals("Wrong outputPort", 4351, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getAugmentation(PortAction.class). - getPort().getValue().intValue()); + Assert.assertEquals("Wrong outputPort", 4351, ((OutputActionCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getOutputAction().getPort().getValue().intValue()); - Assert.assertEquals("Wrong outputMaxLen", 65535, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getAugmentation(MaxLengthAction.class). - getMaxLength().intValue()); + Assert.assertEquals("Wrong outputMaxLen", 65535, ((OutputActionCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getOutputAction().getMaxLength().intValue()); - Assert.assertEquals("Wrong copyTtlOutType", CopyTtlOut.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); + Assert.assertTrue("Wrong copyTtlOutType", message.getGroupDesc().get(0).getBucketsList() + .get(0).getAction().get(1).getActionChoice() instanceof CopyTtlOutCase); - Assert.assertEquals("Wrong copyTtlInType", CopyTtlIn.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); + Assert.assertTrue("Wrong copyTtlInType", message.getGroupDesc().get(0).getBucketsList() + .get(0).getAction().get(2).getActionChoice() instanceof CopyTtlInCase); } /** @@ -825,37 +812,28 @@ public void testMultipartReplyGroupDescBody02(){ message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong setMplsTtlType", SetMplsTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); - Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getAugmentation(MplsTtlAction.class). - getMplsTtl().intValue()); - Assert.assertEquals("Wrong decMplsTtlType", DecMplsTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); - Assert.assertEquals("Wrong pushVlanType", PushVlan.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); - Assert.assertEquals("Wrong pushVlanEthertype", 32, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getAugmentation(EthertypeAction.class). - getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushMplsType", PushMpls.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) - .getType()); - Assert.assertEquals("Wrong pushMplsEthertype", 255, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3). - getAugmentation(EthertypeAction.class). - getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong pushPbbType", PushPbb.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) - .getType()); - Assert.assertEquals("Wrong pushPbbEthertype", 4095, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) - .getAugmentation(EthertypeAction.class). - getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong setMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof SetMplsTtlCase); + Assert.assertEquals("Wrong setMplsTtlMPLS_TTL", 9, ((SetMplsTtlCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()).getSetMplsTtlAction() + .getMplsTtl().intValue()); + Assert.assertTrue("Wrong decMplsTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof DecMplsTtlCase); + Assert.assertTrue("Wrong pushVlanType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(2).getActionChoice() instanceof PushVlanCase); + Assert.assertEquals("Wrong pushVlanEthertype", 32,((PushVlanCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(2).getActionChoice()) + .getPushVlanAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong pushMplsType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(3).getActionChoice() instanceof PushMplsCase); + Assert.assertEquals("Wrong pushMplsEthertype", 255, ((PushMplsCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(3).getActionChoice()) + .getPushMplsAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong pushPbbType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(4).getActionChoice() instanceof PushPbbCase); + Assert.assertEquals("Wrong pushPbbEthertype", 4095, ((PushPbbCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(4).getActionChoice()) + .getPushPbbAction().getEthertype().getValue().intValue()); } /** @@ -910,36 +888,27 @@ public void testMultipartReplyGroupDescBody03(){ message.getGroupDesc().get(0).getBucketsList().get(0).getWatchPort().getValue().intValue()); Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong popVlanType", PopVlan.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); - Assert.assertEquals("Wrong popPbbType", PopPbb.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); - Assert.assertEquals("Wrong popMplsType", PopMpls.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getType()); - Assert.assertEquals("Wrong popMplsEthertype", 207, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(2) - .getAugmentation(EthertypeAction.class). - getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong setQueueType", SetQueue.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) - .getType()); - Assert.assertEquals("Wrong setQueueQueueId", 13565952, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(3) - .getAugmentation(QueueIdAction.class). - getQueueId().intValue()); - Assert.assertEquals("Wrong groupType", Group.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) - .getType()); - Assert.assertEquals("Wrong groupGroupId", 13565952, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(4) - .getAugmentation(GroupIdAction.class). - getGroupId().intValue()); - Assert.assertEquals("Wrong decNwTtlType", DecNwTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(5) - .getType()); + Assert.assertTrue("Wrong popVlanType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof PopVlanCase); + Assert.assertTrue("Wrong popPbbType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof PopPbbCase); + Assert.assertTrue("Wrong popMplsType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(2).getActionChoice() instanceof PopMplsCase); + Assert.assertEquals("Wrong popMplsEthertype", 207, ((PopMplsCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(2).getActionChoice()) + .getPopMplsAction().getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong setQueueType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(3).getActionChoice() instanceof SetQueueCase); + Assert.assertEquals("Wrong setQueueQueueId", 13565952, ((SetQueueCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(3).getActionChoice()) + .getSetQueueAction().getQueueId().intValue()); + Assert.assertTrue("Wrong groupType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(4).getActionChoice() instanceof GroupCase); + Assert.assertEquals("Wrong groupGroupId", 13565952, ((GroupCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(4).getActionChoice()) + .getGroupAction().getGroupId().intValue()); + Assert.assertTrue("Wrong decNwTtlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(5).getActionChoice() instanceof DecNwTtlCase); } /** @@ -990,28 +959,26 @@ public void testMultipartReplyGroupDescBody04(){ Assert.assertEquals("Wrong bucketWatchGroup", 4, message.getGroupDesc().get(0).getBucketsList().get(0).getWatchGroup().intValue()); - Assert.assertEquals("Wrong nwTTlType", SetNwTtl.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getType()); + Assert.assertTrue("Wrong nwTTlType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(0).getActionChoice() instanceof SetNwTtlCase); - Assert.assertEquals("Wrong nwTTlnwTTL", 14, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(0) - .getAugmentation(NwTtlAction.class).getNwTtl().intValue()); + Assert.assertEquals("Wrong nwTTlnwTTL", 14, ((SetNwTtlCase) message.getGroupDesc().get(0) + .getBucketsList().get(0).getAction().get(0).getActionChoice()) + .getSetNwTtlAction().getNwTtl().intValue()); - Assert.assertEquals("Wrong setFieldType", SetField.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getType()); + Assert.assertTrue("Wrong setFieldType", message.getGroupDesc().get(0).getBucketsList().get(0) + .getAction().get(1).getActionChoice() instanceof SetFieldCase); Assert.assertEquals("Wrong setFieldOXMClass", OpenflowBasicClass.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0).getOxmClass()); + ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmClass()); Assert.assertEquals("Wrong setFieldOXMField", InPort.class, - message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0).getOxmMatchField()); + ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0).getOxmMatchField()); - MatchEntry entry = message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) - .getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0); + MatchEntry entry = ((SetFieldCase) message.getGroupDesc().get(0).getBucketsList().get(0).getAction().get(1) + .getActionChoice()).getSetFieldAction().getMatchEntry().get(0); Assert.assertEquals("Wrong setFieldOXMValue", 255, ((InPortCase) entry.getMatchEntryValue()) .getInPort().getPortNumber().getValue().intValue()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index 77ac5d91..ce43d0f1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -20,12 +20,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; @@ -149,15 +146,15 @@ public void testFlow() { new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), message.getFlowStats().get(0).getByteCount()); Action action1 = message.getFlowStats().get(0).getAction().get(0); - Assert.assertEquals("Wrong action type", Output.class, action1.getType()); - Assert.assertEquals("Wrong action port", 1, action1.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong action port", 2, action1.getAugmentation(MaxLengthAction.class) - .getMaxLength().intValue()); + Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase); + Assert.assertEquals("Wrong action port", 1, ((OutputActionCase) action1.getActionChoice()) + .getOutputAction().getPort().getValue().intValue()); + Assert.assertEquals("Wrong action port", 2, ((OutputActionCase) action1.getActionChoice()) + .getOutputAction().getMaxLength().intValue()); Action action2 = message.getFlowStats().get(0).getAction().get(1); - Assert.assertEquals("Wrong action type", SetVlanVid.class, action2.getType()); - Assert.assertEquals("Wrong action port", 3, action2.getAugmentation(VlanVidAction.class) - .getVlanVid().intValue()); + Assert.assertTrue("Wrong action type",action2.getActionChoice() instanceof SetVlanVidCase); + Assert.assertEquals("Wrong action port", 3, ((SetVlanVidCase) action2.getActionChoice()) + .getSetVlanVidAction().getVlanVid().intValue()); Assert.assertTrue("Unread data", bb.readableBytes() == 0); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java index a186c491..45a4fc94 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializerTest.java @@ -24,12 +24,11 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -62,7 +61,7 @@ public void startUp() { public void test(){ OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer(); ser.injectSerializerRegistry(registry); - ActionBuilder actionBuilder = new ActionBuilder(); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder(); long experimenterId = 12L; ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder(); ExperimenterBuilder expBuilder = new ExperimenterBuilder(); @@ -72,13 +71,14 @@ public void test(){ meb.setOxmClass(ExperimenterClass.class); meb.setOxmMatchField(OxmMatchFieldClass.class); meb.setMatchEntryValue(expCaseBuilder.build()); - List MatchEntry = new ArrayList<>(); + List matchEntry = new ArrayList<>(); MatchEntry me = meb.build(); - MatchEntry.add(me); - OxmFieldsActionBuilder oxmActBuilder = new OxmFieldsActionBuilder(); - oxmActBuilder.setMatchEntry(MatchEntry); - actionBuilder.addAugmentation(OxmFieldsAction.class, oxmActBuilder.build()); - actionBuilder.setType(SetField.class); + matchEntry.add(me); + SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder(); + SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder(); + setFieldBuilder.setMatchEntry(matchEntry); + caseBuilder.setSetFieldAction(setFieldBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class); key.setExperimenterId(experimenterId); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index f1ba2ca2..4c3caa4d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -26,17 +26,14 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; @@ -142,13 +139,12 @@ public void testFlowModInputMessageFactory() throws Exception { insBuilder.setType(ApplyActions.class); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(52); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); ActionsInstructionBuilder actionInstructionBuilder = new ActionsInstructionBuilder(); actionInstructionBuilder.setAction(actions); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 579bd379..0d765be1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -27,14 +27,12 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; @@ -99,16 +97,18 @@ public void testFlowModInputMessageFactory() throws Exception { builder.setFlagsV10(new FlowModFlagsV10(true, false, true)); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwDst.class); - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("2.2.2.2")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder(); + SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder(); + nwDstBuilder.setIpAddress(new Ipv4Address("2.2.2.2")); + nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build()); + actionBuilder.setActionChoice(nwDstCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpSrc.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder(); + SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder(); + tpSrcBuilder.setPort(new PortNumber(42L)); + tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build()); + actionBuilder.setActionChoice(tpSrcCaseBuilder.build()); actions.add(actionBuilder.build()); builder.setAction(actions); FlowModInput message = builder.build(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 01fe8871..6b1ff682 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -24,14 +24,11 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder; @@ -68,16 +65,15 @@ public void testPacketOutInputMessage() throws Exception { builder.setInPort(new PortNumber(257L)); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber((long) 42)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(50); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(50); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(StripVlan.class); + actionBuilder.setActionChoice(new StripVlanCaseBuilder().build()); builder.setAction(actions); actions.add(actionBuilder.build()); builder.setAction(actions); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 189fac23..50c0839f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -24,12 +24,11 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; @@ -69,13 +68,14 @@ public void testPacketOutInputMessage() throws Exception { builder.setInPort(new PortNumber(256L)); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); - ethertypeBuilder.setEthertype(new EtherType(25)); - actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); + PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder(); + pushVlanBuilder.setEthertype(new EtherType(new EtherType(25))); + pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build()); + actionBuilder.setActionChoice(pushVlanCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopVlan.class); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); actions.add(actionBuilder.build()); builder.setAction(actions); builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14")); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index d7a19d20..3ad8ced1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -43,9 +43,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; @@ -192,7 +192,7 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); + actionBuilder.setActionChoice(new OutputActionCaseBuilder().build()); actions.add(actionBuilder.build()); actBuilder.setAction(actions); propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index 54dd16d0..63af2169 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -18,15 +18,23 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCase; import org.slf4j.Logger; @@ -79,53 +87,47 @@ public void test() { CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertTrue("Wrong action type", actions.get(0).getActionChoice() instanceof OutputActionCase); Assert.assertEquals("Wrong action port", 1, - actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); + ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction() + .getPort().getValue().intValue()); Assert.assertEquals("Wrong action max-length", 2, - actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); + ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction() + .getMaxLength().intValue()); + Assert.assertTrue("Wrong action type", actions.get(1).getActionChoice() instanceof CopyTtlOutCase); + Assert.assertTrue("Wrong action type", actions.get(2).getActionChoice() instanceof CopyTtlInCase); + Assert.assertTrue("Wrong action type", actions.get(3).getActionChoice() instanceof SetMplsTtlCase); Assert.assertEquals("Wrong action value", 3, - actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); + ((SetMplsTtlCase) actions.get(3).getActionChoice()).getSetMplsTtlAction() + .getMplsTtl().shortValue()); + Assert.assertTrue("Wrong action type", actions.get(4).getActionChoice() instanceof DecMplsTtlCase); + Assert.assertTrue("Wrong action type", actions.get(5).getActionChoice() instanceof PushVlanCase); Assert.assertEquals("Wrong action value", 4, - actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); + ((PushVlanCase) actions.get(5).getActionChoice()).getPushVlanAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(6).getActionChoice() instanceof PopVlanCase); + Assert.assertTrue("Wrong action type", actions.get(7).getActionChoice() instanceof PushMplsCase); Assert.assertEquals("Wrong action value", 5, - actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); + ((PushMplsCase) actions.get(7).getActionChoice()).getPushMplsAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(8).getActionChoice() instanceof PopMplsCase); Assert.assertEquals("Wrong action value", 6, - actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); + ((PopMplsCase) actions.get(8).getActionChoice()).getPopMplsAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(9).getActionChoice() instanceof SetQueueCase); Assert.assertEquals("Wrong action value", 7, - actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); + ((SetQueueCase) actions.get(9).getActionChoice()).getSetQueueAction() + .getQueueId().intValue()); + Assert.assertTrue("Wrong action type", actions.get(10).getActionChoice() instanceof GroupCase); Assert.assertEquals("Wrong action value", 8, - actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); + ((GroupCase) actions.get(10).getActionChoice()).getGroupAction().getGroupId().intValue()); + Assert.assertTrue("Wrong action type", actions.get(11).getActionChoice() instanceof SetNwTtlCase); Assert.assertEquals("Wrong action value", 9, - actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); - List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntry(); + ((SetNwTtlCase) actions.get(11).getActionChoice()).getSetNwTtlAction().getNwTtl().intValue()); + Assert.assertTrue("Wrong action type", actions.get(12).getActionChoice() instanceof DecNwTtlCase); + Assert.assertTrue("Wrong action type", actions.get(13).getActionChoice() instanceof SetFieldCase); + List entries = ((SetFieldCase) actions.get(13).getActionChoice()) + .getSetFieldAction().getMatchEntry(); Assert.assertEquals("Wrong number of fields", 1, entries.size()); Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + "oxm.rev150225.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); @@ -135,12 +137,11 @@ public void test() { Assert.assertEquals("Wrong match entry value", 11, ((InPhyPortCase) entries.get(0).getMatchEntryValue()).getInPhyPort().getPortNumber() .getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); + Assert.assertTrue("Wrong action type", actions.get(14).getActionChoice() instanceof PushPbbCase); Assert.assertEquals("Wrong action value", 10, - actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); + ((PushPbbCase) actions.get(14).getActionChoice()).getPushPbbAction() + .getEthertype().getValue().intValue()); + Assert.assertTrue("Wrong action type", actions.get(15).getActionChoice() instanceof PopPbbCase); Assert.assertTrue("Unread data in message", message.readableBytes() == 0); } @@ -156,12 +157,10 @@ public void testDeserializeHeader() { List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); - Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); + Assert.assertTrue("Wrong action type", actions.get(0).getActionChoice() instanceof OutputActionCase); + Assert.assertNull("Wrong action port", ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction()); + Assert.assertNull("Wrong action max-length", ((OutputActionCase) actions.get(0).getActionChoice()).getOutputAction()); + Assert.assertTrue("Wrong action type", actions.get(1).getActionChoice() instanceof SetFieldCase); + Assert.assertNull("Wrong action oxm field", ((SetFieldCase) actions.get(1).getActionChoice()).getSetFieldAction()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 77af43c5..909918a6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -19,15 +19,14 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -87,26 +86,26 @@ public void test() { + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong action", 53, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof OutputActionCase); + Assert.assertEquals("Wrong action", 37, ((OutputActionCase) action1.getActionChoice()).getOutputAction() + .getPort().getValue().intValue()); + Assert.assertEquals("Wrong action", 53, ((OutputActionCase) action1.getActionChoice()).getOutputAction() + .getMaxLength().intValue()); Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 80, action2.getAugmentation(GroupIdAction.class).getGroupId().intValue()); + Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof GroupCase); + Assert.assertEquals("Wrong action", 80, ((GroupCase) action2.getActionChoice()).getGroupAction().getGroupId().intValue()); Instruction i6 = instructions.get(5); Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof SetQueueCase); + Assert.assertEquals("Wrong action", 37, ((SetQueueCase) action1.getActionChoice()).getSetQueueAction() + .getQueueId().intValue()); action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 5, action2.getAugmentation(MplsTtlAction.class).getMplsTtl().intValue()); + Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof SetMplsTtlCase); + Assert.assertEquals("Wrong action", 5, ((SetMplsTtlCase) action2.getActionChoice()).getSetMplsTtlAction() + .getMplsTtl().shortValue()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java index 15c367ad..e1fdc445 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java @@ -19,7 +19,7 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index b0fc2115..fdb15dd4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -19,15 +19,19 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; /** * @author michal.polkorab @@ -70,66 +74,57 @@ public void test() { message.readableBytes(), message, keyMaker, registry); Assert.assertEquals("Wrong number of actions", 12, actions.size()); Action action1 = actions.get(0); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Output", action1.getType().getName()); + Assert.assertTrue("Wrong action type", action1.getActionChoice() instanceof OutputActionCase); Assert.assertEquals("Wrong port", 16, - action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); + ((OutputActionCase) action1.getActionChoice()).getOutputAction().getPort().getValue().intValue()); Assert.assertEquals("Wrong max-length", 8192, - action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + ((OutputActionCase) action1.getActionChoice()).getOutputAction().getMaxLength().intValue()); Action action2 = actions.get(1); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); + Assert.assertTrue("Wrong action type", action2.getActionChoice() instanceof SetVlanVidCase); Assert.assertEquals("Wrong vlan-vid", 4112, - action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); + ((SetVlanVidCase) action2.getActionChoice()).getSetVlanVidAction().getVlanVid().intValue()); Action action3 = actions.get(2); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); + Assert.assertTrue("Wrong action type", action3.getActionChoice() instanceof SetVlanPcpCase); Assert.assertEquals("Wrong vlan-pcp", 37, - action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); + ((SetVlanPcpCase) action3.getActionChoice()).getSetVlanPcpAction().getVlanPcp().intValue()); Action action4 = actions.get(3); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); + Assert.assertTrue("Wrong action type", action4.getActionChoice() instanceof StripVlanCase); Action action5 = actions.get(4); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); + Assert.assertTrue("Wrong action type", action5.getActionChoice() instanceof SetDlSrcCase); Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), - ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + ByteBufUtils.macAddressToBytes(((SetDlSrcCase) action5.getActionChoice()) + .getSetDlSrcAction().getDlSrcAddress().getValue())); Action action6 = actions.get(5); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); + Assert.assertTrue("Wrong action type", action6.getActionChoice() instanceof SetDlDstCase); Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), - ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + ByteBufUtils.macAddressToBytes(((SetDlDstCase) action6.getActionChoice()) + .getSetDlDstAction().getDlDstAddress().getValue())); Action action7 = actions.get(6); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); + Assert.assertTrue("Wrong action type", action7.getActionChoice() instanceof SetNwSrcCase); Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), - action7.getAugmentation(IpAddressAction.class).getIpAddress()); + ((SetNwSrcCase) action7.getActionChoice()).getSetNwSrcAction().getIpAddress()); Action action8 = actions.get(7); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); + Assert.assertTrue("Wrong action type", action8.getActionChoice() instanceof SetNwDstCase); Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), - action8.getAugmentation(IpAddressAction.class).getIpAddress()); + ((SetNwDstCase) action8.getActionChoice()).getSetNwDstAction().getIpAddress()); Action action9 = actions.get(8); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); - Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); + Assert.assertTrue("Wrong action type", action9.getActionChoice() instanceof SetNwTosCase); + Assert.assertEquals("Wrong nw-tos", 1, ((SetNwTosCase) action9.getActionChoice()) + .getSetNwTosAction().getNwTos().intValue()); Action action10 = actions.get(9); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); - Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); + Assert.assertTrue("Wrong action type", action10.getActionChoice() instanceof SetTpSrcCase); + Assert.assertEquals("Wrong port", 2, ((SetTpSrcCase) action10.getActionChoice()) + .getSetTpSrcAction().getPort().getValue().intValue()); Action action11 = actions.get(10); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); - Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); + Assert.assertTrue("Wrong action type", action11.getActionChoice() instanceof SetTpDstCase); + Assert.assertEquals("Wrong port", 3, ((SetTpDstCase) action11.getActionChoice()) + .getSetTpDstAction().getPort().getValue().intValue()); Action action12 = actions.get(11); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); - Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong queue-id", 48, - action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + Assert.assertTrue("Wrong action type", action12.getActionChoice() instanceof EnqueueCase); + Assert.assertEquals("Wrong port", 4, ((EnqueueCase) action12.getActionChoice()) + .getEnqueueAction().getPort().getValue().intValue()); + Assert.assertEquals("Wrong queue-id", 48, ((EnqueueCase) action12.getActionChoice()) + .getEnqueueAction().getQueueId().getValue().intValue()); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index 16e9a8fa..f66aa061 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -22,37 +22,33 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.IpAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; /** * @author michal.polkorab @@ -78,79 +74,86 @@ public void startUp() { public void test() { List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(32); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(32); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanVid.class); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(15); - actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); + SetVlanVidCaseBuilder vlanVidCaseBuilder = new SetVlanVidCaseBuilder(); + SetVlanVidActionBuilder vlanVidBuilder = new SetVlanVidActionBuilder(); + vlanVidBuilder.setVlanVid(15); + vlanVidCaseBuilder.setSetVlanVidAction(vlanVidBuilder.build()); + actionBuilder.setActionChoice(vlanVidCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanPcp.class); - VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); - pcpBuilder.setVlanPcp((short) 16); - actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); + SetVlanPcpCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpCaseBuilder(); + SetVlanPcpActionBuilder vlanPcpBuilder = new SetVlanPcpActionBuilder(); + vlanPcpBuilder.setVlanPcp((short) 16); + vlanPcpCaseBuilder.setSetVlanPcpAction(vlanPcpBuilder.build()); + actionBuilder.setActionChoice(vlanPcpCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(StripVlan.class); + actionBuilder.setActionChoice(new StripVlanCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlSrc.class); - DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + SetDlSrcCaseBuilder dlSrcCaseBuilder = new SetDlSrcCaseBuilder(); + SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder(); + dlSrcBuilder.setDlSrcAddress(new MacAddress("00:00:00:02:03:04")); + dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build()); + actionBuilder.setActionChoice(dlSrcCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlDst.class); - dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + SetDlDstCaseBuilder dlDstCaseBuilder = new SetDlDstCaseBuilder(); + SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder(); + dlDstBuilder.setDlDstAddress(new MacAddress("00:00:00:01:02:03")); + dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build()); + actionBuilder.setActionChoice(dlDstCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwSrc.class); - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder(); + SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder(); + nwSrcBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); + nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build()); + actionBuilder.setActionChoice(nwSrcCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwDst.class); - ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder(); + SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder(); + nwDstBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); + nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build()); + actionBuilder.setActionChoice(nwDstCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTos.class); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + SetNwTosCaseBuilder tosCaseBuilder = new SetNwTosCaseBuilder(); + SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder(); tosBuilder.setNwTos((short) 204); - actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); + tosCaseBuilder.setSetNwTosAction(tosBuilder.build()); + actionBuilder.setActionChoice(tosCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpSrc.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6653L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder(); + SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder(); + tpSrcBuilder.setPort(new PortNumber(6653L)); + tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build()); + actionBuilder.setActionChoice(tpSrcCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpDst.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6633L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + SetTpDstCaseBuilder tpDstCaseBuilder = new SetTpDstCaseBuilder(); + SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder(); + tpDstBuilder.setPort(new PortNumber(6633L)); + tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build()); + actionBuilder.setActionChoice(tpDstCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(Enqueue.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6613L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(400L); - actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + EnqueueCaseBuilder enqueueCaseBuilder = new EnqueueCaseBuilder(); + EnqueueActionBuilder enqueueBuilder = new EnqueueActionBuilder(); + enqueueBuilder.setPort(new PortNumber(6613L)); + enqueueBuilder.setQueueId(new QueueId(400L)); + enqueueCaseBuilder.setEnqueueAction(enqueueBuilder.build()); + actionBuilder.setActionChoice(enqueueCaseBuilder.build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index 7e614b67..66462d8b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -19,40 +19,34 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; @@ -86,74 +80,80 @@ public void startUp() { public void test() { List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(52); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlOut.class); + actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlIn.class); + actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetMplsTtl.class); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl((short) 4); - actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder(); + SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder(); + setMplsTtlBuilder.setMplsTtl((short) 4); + setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build()); + actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecMplsTtl.class); + actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(16)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder(); + pushVlanBuilder.setEthertype(new EtherType(new EtherType(16))); + pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build()); + actionBuilder.setActionChoice(pushVlanCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopVlan.class); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(17)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder(); + PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder(); + pushMplsBuilder.setEthertype(new EtherType(new EtherType(17))); + pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build()); + actionBuilder.setActionChoice(pushMplsCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(18)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder(); + PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder(); + popMplsBuilder.setEthertype(new EtherType(new EtherType(18))); + popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build()); + actionBuilder.setActionChoice(popMplsCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetQueue.class); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(1234L); - actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); + SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder(); + SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder(); + setQueueBuilder.setQueueId(1234L); + setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build()); + actionBuilder.setActionChoice(setQueueCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(Group.class); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(555L); - actionBuilder.addAugmentation(GroupIdAction.class, group.build()); + GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder(); + GroupActionBuilder groupActionBuilder = new GroupActionBuilder(); + groupActionBuilder.setGroupId(555L); + groupCaseBuilder.setGroupAction(groupActionBuilder.build()); + actionBuilder.setActionChoice(groupCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 8); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder(); + SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder(); + nwTtlBuilder.setNwTtl((short) 8); + nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build()); + actionBuilder.setActionChoice(nwTtlCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecNwTtl.class); + actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder(); + SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder(); List entries = new ArrayList<>(); MatchEntryBuilder matchBuilder = new MatchEntryBuilder(); matchBuilder.setOxmClass(OpenflowBasicClass.class); @@ -165,17 +165,19 @@ public void test() { inPortCaseBuilder.setInPort(inPortBuilder.build()); matchBuilder.setMatchEntryValue(inPortCaseBuilder.build()); entries.add(matchBuilder.build()); - matchEntries.setMatchEntry(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + setFieldBuilder.setMatchEntry(entries); + setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build()); + actionBuilder.setActionChoice(setFieldCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushPbb.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(19)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder(); + PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder(); + pushPbbBuilder.setEthertype(new EtherType(new EtherType(19))); + pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build()); + actionBuilder.setActionChoice(pushPbbCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); + actionBuilder.setActionChoice(new PopPbbCaseBuilder().build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); @@ -252,17 +254,16 @@ public void test() { public void testHeaders() { List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(52); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder(); + SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder(); List entries = new ArrayList<>(); MatchEntryBuilder matchBuilder = new MatchEntryBuilder(); matchBuilder.setOxmClass(OpenflowBasicClass.class); @@ -274,8 +275,9 @@ public void testHeaders() { inPortCaseBuilder.setInPort(inPortBuilder.build()); matchBuilder.setMatchEntryValue(inPortCaseBuilder.build()); entries.add(matchBuilder.build()); - matchEntries.setMatchEntry(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + setFieldBuilder.setMatchEntry(entries); + setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build()); + actionBuilder.setActionChoice(setFieldCaseBuilder.build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index b48c265f..99290012 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -22,26 +22,21 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; @@ -108,19 +103,19 @@ public void test() { ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(45L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); - maxBuilder.setMaxLength(55); - actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(45L)); + outputBuilder.setMaxLength(55); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 64); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder(); + SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder(); + ttlActionBuilder.setNwTtl((short) 64); + ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build()); + actionBuilder.setActionChoice(ttlCaseBuilder.build()); actions.add(actionBuilder.build()); actionsBuilder.setAction(actions); builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); @@ -131,13 +126,14 @@ public void test() { actionsBuilder = new ActionsInstructionBuilder(); actions = new ArrayList<>(); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); - ethertypeBuilder.setEthertype(new EtherType(14)); - actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); + PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder(); + vlanBuilder.setEthertype(new EtherType(new EtherType(14))); + vlanCaseBuilder.setPushVlanAction(vlanBuilder.build()); + actionBuilder.setActionChoice(vlanCaseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); + actionBuilder.setActionChoice(new PopPbbCaseBuilder().build()); actions.add(actionBuilder.build()); actionsBuilder.setAction(actions); builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index 99d297c7..629e2490 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -17,17 +17,15 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; @@ -54,13 +52,13 @@ public void testActionKeyMaker() { Assert.assertNotNull("Null keyMaker", keyMaker); ActionBuilder builder = new ActionBuilder(); - builder.setType(Output.class); + builder.setActionChoice(new OutputActionCaseBuilder().build()); Action action = builder.build(); MessageTypeKey key = keyMaker.make(action); Assert.assertNotNull("Null key", key); Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - Output.class, null), key); + OutputActionCase.class, null), key); } /** @@ -71,12 +69,17 @@ public void testExperimenterActionKeyMaker() { TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); Assert.assertNotNull("Null keyMaker", keyMaker); - ActionBuilder builder = new ActionBuilder(); - builder.setType(Experimenter.class); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice + .ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments + .rev150225.action.container.action.choice.ExperimenterIdCaseBuilder(); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice + .experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight + .openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder(); expIdBuilder.setExperimenter(new ExperimenterId(42L)); expIdBuilder.setSubType(ActionSubtypeClass.class); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + caseBuilder.setExperimenter(expIdBuilder.build()); + builder.setActionChoice(caseBuilder.build()); Action action = builder.build(); MessageTypeKey key = keyMaker.make(action); From 6ab8f0e27c9e770ebf6f76f44fde6ee3ce841502 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 4 Mar 2015 19:01:01 +0100 Subject: [PATCH 142/285] Bug 2756 - Instruction model update Change-Id: Id1fbcd55f44a7e60b24ed10d7852fa0a100cf6b5 Signed-off-by: Michal Polkorab --- .../ExperimenterInstructionSerializerKey.java | 6 +- .../api/keys/InstructionSerializerKey.java | 4 +- .../src/main/yang/openflow-augments.yang | 36 ++------- .../src/main/yang/openflow-instruction.yang | 77 +++++++++++-------- .../keys/InstructionSerializerKeyTest.java | 32 ++++---- .../protocol/api/keys/KeysTest.java | 9 ++- ...AbstractActionInstructionDeserializer.java | 24 ++---- .../AbstractInstructionDeserializer.java | 66 ---------------- .../ApplyActionsInstructionDeserializer.java | 35 +++++++-- .../ClearActionsInstructionDeserializer.java | 30 ++++---- .../GoToTableInstructionDeserializer.java | 30 +++++--- .../MeterInstructionDeserializer.java | 30 +++++--- .../WriteActionsInstructionDeserializer.java | 35 +++++++-- .../WriteMetadataInstructionDeserializer.java | 28 ++++--- .../InstructionsInitializer.java | 24 +++--- .../AbstractActionInstructionSerializer.java | 25 ++---- .../ApplyActionsInstructionSerializer.java | 21 +++++ .../ClearActionsInstructionSerializer.java | 12 ++- .../GoToTableInstructionSerializer.java | 5 +- .../MeterInstructionSerializer.java | 6 +- .../WriteActionsInstructionSerializer.java | 21 +++++ .../WriteMetadataInstructionSerializer.java | 6 +- .../InstructionSerializerRegistryHelper.java | 4 +- .../impl/util/TypeKeyMakerFactory.java | 17 ++-- .../AbstractInstructionDeserializerTest.java | 43 +++++------ .../FlowModInputMessageFactoryTest.java | 44 +++++------ .../MultipartRequestTableFeaturesTest.java | 26 +++---- .../util/InstructionsDeserializerTest.java | 53 +++++++------ .../util/OF13InstructionsSerializerTest.java | 74 +++++++++--------- .../impl/util/TypeKeyMakerFactoryTest.java | 24 +++--- 30 files changed, 442 insertions(+), 405 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java index fb2365bf..15ee03a0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java @@ -8,12 +8,12 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase; /** * @author michal.polkorab */ -public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey +public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey implements ExperimenterSerializerKey { /** @@ -21,7 +21,7 @@ public final class ExperimenterInstructionSerializerKey extends InstructionSeria * @param experimenterId experimenter / vendor ID */ public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Experimenter.class, experimenterId); + super(msgVersion, ExperimenterIdCase.class, experimenterId); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 2b7df97c..6f9a299b 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -8,14 +8,14 @@ package org.opendaylight.openflowjava.protocol.api.keys; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; /** * @author michal.polkorab * @param instruction type */ -public class InstructionSerializerKey +public class InstructionSerializerKey extends MessageTypeKey{ private Class instructionType; diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 292bd961..34ca8c43 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -89,35 +89,13 @@ } // OFP_INSTRUCTION AUGMENTS - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "table-id-instruction"; - leaf table-id { - type uint8; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "metadata-instruction"; - leaf metadata { - type binary; - } - leaf metadata-mask { - type binary; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "actions-instruction"; - uses ofaction:actions-grouping; - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "meter-id-instruction"; - leaf meter-id { - type uint32; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "experimenter-id-instruction"; - leaf experimenter { - type oft:experimenter-id; + augment "/ofinstruction:instruction-container/ofinstruction:instruction-choice" { + case experimenter-id-case { + container experimenter { + leaf experimenter-id { + type oft:experimenter-id; + } + } } } diff --git a/openflow-protocol-api/src/main/yang/openflow-instruction.yang b/openflow-protocol-api/src/main/yang/openflow-instruction.yang index 671556e1..293e3803 100644 --- a/openflow-protocol-api/src/main/yang/openflow-instruction.yang +++ b/openflow-protocol-api/src/main/yang/openflow-instruction.yang @@ -11,53 +11,62 @@ prefix "ofinstruction"; import openflow-types { prefix oft; } + import openflow-action {prefix ofaction;} revision "2013-07-31" { description "OpenFlow 1.3 - instruction model"; } - identity goto_table { - description " Setup the next table in the lookup pipeline"; - base oft:instruction-base; - } - identity write_metadata { - description " Setup the metadata field for use later in pipeline"; - base oft:instruction-base; - } - identity write_actions { - description " Write the action(s) onto the datapath action set"; - base oft:instruction-base; - } - identity apply_actions { - description " Applies the action(s) immediately"; - base oft:instruction-base; - } - identity clear_actions { - description " Clears all actions from the datapath action set"; - base oft:instruction-base; - } - identity meter { - description " Apply meter (rate limiter)"; - base oft:instruction-base; - } - identity experimenter { - description "Experimenter instruction"; - base oft:instruction-base; - } - container instruction-container { - uses instructions-grouping; + uses instruction-grouping; } grouping instructions-grouping { list instruction { config false; - leaf type { - type identityref { - base oft:instruction-base; + uses instruction-grouping; + } + } + + grouping instruction-grouping { + choice instruction-choice { + case goto-table-case { + container goto-table { + leaf table-id { + type uint8; + } + } + } + case write-metadata-case { + container write-metadata { + leaf metadata { + type binary; + } + leaf metadata-mask { + type binary; + } + } + } + case write-actions-case { + container write-actions { + uses ofaction:actions-grouping; + } + } + case apply-actions-case { + container apply-actions { + uses ofaction:actions-grouping; + } + } + case clear-actions-case { + // empty instruction + } + case meter-case { + container meter { + leaf meter-id { + type uint32; + } } } } } - } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index a51a2d70..17ecf582 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -11,8 +11,8 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase; /** * @author michal.polkorab @@ -26,24 +26,24 @@ public class InstructionSerializerKeyTest { @Test public void test() { InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L); InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L); Assert.assertTrue("Wrong equals", key1.equals(key2)); Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActionsCase.class, 42L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 55L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActionsCase.class, 42L); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); } @@ -54,14 +54,14 @@ public void test() { @Test public void testEquals(){ InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L); InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null); Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); @@ -75,11 +75,11 @@ public void testEquals(){ @Test public void testToString(){ InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L); - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" - + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" - + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction " + + "instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction" + + ".rev130731.instruction.grouping.instruction.choice.ApplyActionsCase vendorID: 42", key1.toString()); } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index 09ecbda4..c23d4b3c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -53,10 +53,11 @@ public void testEqualsAndHashcodeOfActionDeserializerKeys() { Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey)); Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey)); - InstructionSerializerKey instructionSerializerKey = new InstructionSerializerKey<>( - EncodeConstants.OF13_VERSION_ID, - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class, - 1L); + InstructionSerializerKey instructionSerializerKey = + new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice + .ExperimenterIdCase.class, 1L); ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L); Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey); Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 10ba7c2f..2d17ed63 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -14,46 +14,32 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; /** * @author michal.polkorab * */ -public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer - implements DeserializerRegistryInjector { +public abstract class AbstractActionInstructionDeserializer implements OFDeserializer, + DeserializerRegistryInjector { private DeserializerRegistry registry; - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - int instructionLength = input.readUnsignedShort(); - input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + protected List deserializeActions(ByteBuf input, int instructionLength) { int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH; CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList( EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - return builder.build(); + return actions; } - protected abstract Class getType(); - protected DeserializerRegistry getRegistry() { return registry; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java deleted file mode 100644 index 38a66452..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractInstructionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Instruction deserializeHeader(ByteBuf rawMessage) { - InstructionBuilder builder = processHeader(rawMessage); - rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return builder.build(); - } - - protected InstructionBuilder processHeader(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - int type = input.readUnsignedShort(); - switch (type) { - case 1: - builder.setType(GotoTable.class); - break; - case 2: - builder.setType(WriteMetadata.class); - break; - case 3: - builder.setType(WriteActions.class); - break; - case 4: - builder.setType(ApplyActions.class); - break; - case 5: - builder.setType(ClearActions.class); - break; - case 6: - builder.setType(Meter.class); - break; - default: - throw new IllegalStateException("Unknown instruction type received, type: " + type); - } - return builder; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java index c55aacea..ff5bffce 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java @@ -8,18 +8,43 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; /** * @author michal.polkorab * */ -public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { +public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer + implements HeaderDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + int instructionLength = input.readUnsignedShort(); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ApplyActionsCaseBuilder caseBuilder = new ApplyActionsCaseBuilder(); + ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder(); + actionsBuilder.setAction(deserializeActions(input, instructionLength)); + caseBuilder.setApplyActions(actionsBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); + return builder.build(); + } @Override - protected Class getType() { - return ApplyActions.class; + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new ApplyActionsCaseBuilder().build()); + return builder.build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index b3c29c8d..24fe5cfb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -10,14 +10,11 @@ import io.netty.buffer.ByteBuf; -import java.util.ArrayList; -import java.util.List; - +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; @@ -25,18 +22,23 @@ * @author michal.polkorab * */ -public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer { +public class ClearActionsInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { @Override public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = super.processHeader(input); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = - new ActionsInstructionBuilder(); - List actions = new ArrayList<>(); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + builder.setInstructionChoice(new ClearActionsCaseBuilder().build()); + return builder.build(); + } + + @Override + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new ClearActionsCaseBuilder().build()); return builder.build(); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index 0940aae9..31191b1d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -10,11 +10,12 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; @@ -22,18 +23,27 @@ * @author michal.polkorab * */ -public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer { +public class GoToTableInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { @Override public Instruction deserialize(ByteBuf input) { InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(GotoTable.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); - tableBuilder.setTableId(input.readUnsignedByte()); - builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); + GotoTableCaseBuilder caseBuilder = new GotoTableCaseBuilder(); + GotoTableBuilder instructionBuilder = new GotoTableBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + instructionBuilder.setTableId(input.readUnsignedByte()); + caseBuilder.setGotoTable(instructionBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); return builder.build(); } + + @Override + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new GotoTableCaseBuilder().build()); + return builder.build(); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java index fa6c6bb5..4667a4d8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java @@ -10,10 +10,11 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; @@ -21,17 +22,26 @@ * @author michal.polkorab * */ -public class MeterInstructionDeserializer extends AbstractInstructionDeserializer { +public class MeterInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { @Override public Instruction deserialize(ByteBuf input) { InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Meter.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); - meterBuilder.setMeterId(input.readUnsignedInt()); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + MeterCaseBuilder caseBuilder = new MeterCaseBuilder(); + MeterBuilder instructionBuilder = new MeterBuilder(); + instructionBuilder.setMeterId(input.readUnsignedInt()); + caseBuilder.setMeter(instructionBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); + return builder.build(); + } + + @Override + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new MeterCaseBuilder().build()); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java index c60532b0..4699ef69 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java @@ -8,18 +8,43 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; /** * @author michal.polkorab * */ -public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { +public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer + implements HeaderDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + int instructionLength = input.readUnsignedShort(); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + WriteActionsCaseBuilder caseBuilder = new WriteActionsCaseBuilder(); + WriteActionsBuilder actionsBuilder = new WriteActionsBuilder(); + actionsBuilder.setAction(deserializeActions(input, instructionLength)); + caseBuilder.setWriteActions(actionsBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); + return builder.build(); + } @Override - protected Class getType() { - return WriteActions.class; + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new WriteActionsCaseBuilder().build()); + return builder.build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index 51646b62..919fc50d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -10,11 +10,12 @@ import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; @@ -22,23 +23,32 @@ * @author michal.polkorab * */ -public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer { +public class WriteMetadataInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { @Override public Instruction deserialize(ByteBuf input) { InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(WriteMetadata.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder(); + WriteMetadataCaseBuilder caseBuilder = new WriteMetadataCaseBuilder(); + WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder(); byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadata); metadataBuilder.setMetadata(metadata); byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(metadataMask); metadataBuilder.setMetadataMask(metadataMask); - builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); + caseBuilder.setWriteMetadata(metadataBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); + return builder.build(); + } + + @Override + public Instruction deserializeHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setInstructionChoice(new WriteMetadataCaseBuilder().build()); return builder.build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java index 46674e52..3c9ff80b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java @@ -17,12 +17,12 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase; /** * @author michal.polkorab @@ -42,11 +42,11 @@ public static void registerInstructionSerializers(SerializerRegistry serializerR // register OF v1.3 instruction serializers InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); - helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); - helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); - helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer()); - helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer()); - helper.registerSerializer(Meter.class, new MeterInstructionSerializer()); + helper.registerSerializer(GotoTableCase.class, new GoToTableInstructionSerializer()); + helper.registerSerializer(WriteMetadataCase.class, new WriteMetadataInstructionSerializer()); + helper.registerSerializer(WriteActionsCase.class, new WriteActionsInstructionSerializer()); + helper.registerSerializer(ApplyActionsCase.class, new ApplyActionsInstructionSerializer()); + helper.registerSerializer(ClearActionsCase.class, new ClearActionsInstructionSerializer()); + helper.registerSerializer(MeterCase.class, new MeterInstructionSerializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 5a75e530..c1f3d7bb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -19,9 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab @@ -35,22 +33,13 @@ public abstract class AbstractActionInstructionSerializer extends AbstractInstru private SerializerRegistry registry; - @Override - public void serialize(final Instruction instruction, final ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(getType()); - if (instruction.getAugmentation(ActionsInstruction.class) != null) { - List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); - int instructionLength = outBuffer.writerIndex() - startIndex; - outBuffer.setShort(lengthIndex, instructionLength); - } else { - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - } + protected void writeActions(final List actions, final ByteBuf outBuffer, int startIndex) { + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); + int instructionLength = outBuffer.writerIndex() - startIndex; + outBuffer.setShort(lengthIndex, instructionLength); } protected SerializerRegistry getRegistry() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java index 2aaae19b..4d6f1f53 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java @@ -8,7 +8,14 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; +import io.netty.buffer.ByteBuf; + +import java.util.List; + import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab @@ -16,6 +23,20 @@ */ public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer { + @Override + public void serialize(final Instruction instruction, final ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(getType()); + ApplyActionsCase actionsCase = (ApplyActionsCase) instruction.getInstructionChoice(); + if (actionsCase != null) { + List actions = actionsCase.getApplyActions().getAction(); + writeActions(actions, outBuffer, startIndex); + } else { + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + } + } + @Override protected int getType() { return InstructionConstants.APPLY_ACTIONS_TYPE; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java index 00162502..b8585b05 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java @@ -8,13 +8,23 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; +import io.netty.buffer.ByteBuf; + import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab * */ -public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer { +public class ClearActionsInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(final Instruction instruction, final ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + } @Override protected int getType() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 47c7c43c..4aca403b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -24,7 +24,8 @@ public class GoToTableInstructionSerializer extends AbstractInstructionSerialize public void serialize(Instruction instruction, ByteBuf outBuffer) { outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); + outBuffer.writeByte(((GotoTableCase) instruction.getInstructionChoice()) + .getGotoTable().getTableId()); outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java index 1387d1e2..cd1099fe 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java @@ -11,7 +11,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -24,8 +24,8 @@ public class MeterInstructionSerializer extends AbstractInstructionSerializer { public void serialize(Instruction instruction, ByteBuf outBuffer) { outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeInt(instruction. - getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + outBuffer.writeInt(((MeterCase) instruction.getInstructionChoice()) + .getMeter().getMeterId().intValue()); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java index 10e20504..28393a5e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java @@ -8,7 +8,14 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction; +import io.netty.buffer.ByteBuf; + +import java.util.List; + import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** * @author michal.polkorab @@ -16,6 +23,20 @@ */ public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer { + @Override + public void serialize(final Instruction instruction, final ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(getType()); + WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice(); + if (actionsCase != null) { + List actions = actionsCase.getWriteActions().getAction(); + writeActions(actions, outBuffer, startIndex); + } else { + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + } + } + @Override protected int getType() { return InstructionConstants.WRITE_ACTIONS_TYPE; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 3b407fdc..a9b2a907 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -11,7 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -25,7 +26,8 @@ public void serialize(Instruction instruction, ByteBuf outBuffer) { outBuffer.writeShort(getType()); outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); + WriteMetadata metadata = ((WriteMetadataCase) instruction.getInstructionChoice()) + .getWriteMetadata(); outBuffer.writeBytes(metadata.getMetadata()); outBuffer.writeBytes(metadata.getMetadataMask()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index d85fbbdd..78a36180 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -10,7 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice; /** * @author michal.polkorab @@ -34,7 +34,7 @@ public InstructionSerializerRegistryHelper(short version, SerializerRegistry ser * @param instructionType * @param serializer */ - public void registerSerializer(Class instructionType, + public void registerSerializer(Class instructionType, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, instructionType, null), serializer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index b5a2a4a5..e74ac05f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -14,10 +14,10 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -74,7 +74,8 @@ public MessageTypeKey make(Action entry) { expIdCase.getExperimenter().getExperimenter().getValue(), expIdCase.getExperimenter().getSubType()); } - return new ActionSerializerKey<>(getVersion(), (Class) entry.getActionChoice().getImplementedInterface(), null); + return new ActionSerializerKey<>(getVersion(), + (Class) entry.getActionChoice().getImplementedInterface(), null); } }; } @@ -88,13 +89,15 @@ public static TypeKeyMaker createInstructionKeyMaker(short version) return new AbstractTypeKeyMaker(version) { @Override public MessageTypeKey make(Instruction entry) { - if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common - .instruction.rev130731.Experimenter.class)) { + if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow + .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) { return new ExperimenterInstructionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdInstruction.class) - .getExperimenter().getValue()); + ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction + .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice()) + .getExperimenter().getExperimenterId().getValue()); } - return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); + return new InstructionSerializerKey<>(getVersion(), + (Class) entry.getInstructionChoice().getImplementedInterface(), null); } }; } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java index b7a76b42..1d8c8431 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java @@ -13,12 +13,12 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -31,35 +31,30 @@ public class AbstractInstructionDeserializerTest { * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different * instruction types */ - @Test(expected=IllegalStateException.class) + @Test public void test() { ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); - GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); + Instruction instruction = new GoToTableInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof GotoTableCase); buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); + instruction = new WriteMetadataInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteMetadataCase); buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); + instruction = new WriteActionsInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteActionsCase); buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); + instruction = new ApplyActionsInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ApplyActionsCase); buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); + instruction = new ClearActionsInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ClearActionsCase); buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); - instruction = deserializer.deserializeHeader(buffer); - // exception expected + instruction = new MeterInstructionDeserializer().deserializeHeader(buffer); + Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index 4c3caa4d..edf21a2c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -24,19 +24,16 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; @@ -124,19 +121,22 @@ public void testFlowModInputMessageFactory() throws Exception { builder.setMatch(matchBuilder.build()); List instructions = new ArrayList<>(); InstructionBuilder insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); - TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder(); - idBuilder.setTableId((short) 43); - insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build()); + GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder(); + GotoTableBuilder instructionBuilder = new GotoTableBuilder(); + instructionBuilder.setTableId((short) 43); + goToCaseBuilder.setGotoTable(instructionBuilder.build()); + insBuilder.setInstructionChoice(goToCaseBuilder.build()); instructions.add(insBuilder.build()); - insBuilder.setType(WriteMetadata.class); - MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); - metaBuilder.setMetadata(cookie); - metaBuilder.setMetadataMask(cookieMask); - insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); + WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder(); + WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder(); + metadataBuilder.setMetadata(cookie); + metadataBuilder.setMetadataMask(cookieMask); + metadataCaseBuilder.setWriteMetadata(metadataBuilder.build()); + insBuilder.setInstructionChoice(metadataCaseBuilder.build()); instructions.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(ApplyActions.class); + ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder(); + ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder(); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); @@ -146,9 +146,9 @@ public void testFlowModInputMessageFactory() throws Exception { caseBuilder.setOutputAction(outputBuilder.build()); actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); - ActionsInstructionBuilder actionInstructionBuilder = new ActionsInstructionBuilder(); - actionInstructionBuilder.setAction(actions); - insBuilder.addAugmentation(ActionsInstruction.class, actionInstructionBuilder.build()); + actionsBuilder.setAction(actions); + applyActionsCaseBuilder.setApplyActions(actionsBuilder.build()); + insBuilder.setInstructionChoice(applyActionsCaseBuilder.build()); instructions.add(insBuilder.build()); builder.setInstruction(instructions); FlowModInput message = builder.build(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index 3ad8ced1..48695a8c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -46,12 +46,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; @@ -147,10 +147,10 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { new InstructionRelatedTableFeaturePropertyBuilder(); List insIds = new ArrayList<>(); InstructionBuilder insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteActions.class); + insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); + insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); insIds.add(insBuilder.build()); insPropBuilder.setInstruction(insIds); propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); @@ -160,19 +160,19 @@ public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); insIds = new ArrayList<>(); insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteMetadata.class); + insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(ApplyActions.class); + insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(Meter.class); + insBuilder.setInstructionChoice(new MeterCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(ClearActions.class); + insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build()); insIds.add(insBuilder.build()); insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); + insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); insIds.add(insBuilder.build()); insPropBuilder.setInstruction(insIds); propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 909918a6..60f18761 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -18,15 +18,17 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; /** @@ -63,46 +65,43 @@ public void test() { List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, message.readableBytes(), message, keyMaker, registry); Instruction i1 = instructions.get(0); - Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName()); - Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue()); + Assert.assertTrue("Wrong type - i1", i1.getInstructionChoice() instanceof GotoTableCase); + Assert.assertEquals("Wrong table-id - i1", 10, ((GotoTableCase) i1.getInstructionChoice()) + .getGotoTable().getTableId().intValue()); Instruction i2 = instructions.get(1); - Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName()); + Assert.assertTrue("Wrong type - i2", i2.getInstructionChoice() instanceof WriteMetadataCase); Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), - i2.getAugmentation(MetadataInstruction.class).getMetadata()); + ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadata()); Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), - i2.getAugmentation(MetadataInstruction.class).getMetadataMask()); + ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadataMask()); Instruction i3 = instructions.get(2); - Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName()); - Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size()); + Assert.assertTrue("Wrong type - i3", i3.getInstructionChoice() instanceof ClearActionsCase); Instruction i4 = instructions.get(3); - Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName()); - Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + Assert.assertTrue("Wrong type - i4", i4.getInstructionChoice() instanceof MeterCase); + Assert.assertEquals("Wrong meterId - i4", 66051, ((MeterCase) i4.getInstructionChoice()) + .getMeter().getMeterId().intValue()); Instruction i5 = instructions.get(4); - Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); - Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); - Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertTrue("Wrong type - i5", i5.getInstructionChoice() instanceof WriteActionsCase); + Assert.assertEquals("Wrong instructions - i5", 2, ((WriteActionsCase) i5.getInstructionChoice()) + .getWriteActions().getAction().size()); + Action action1 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(0); Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof OutputActionCase); Assert.assertEquals("Wrong action", 37, ((OutputActionCase) action1.getActionChoice()).getOutputAction() .getPort().getValue().intValue()); Assert.assertEquals("Wrong action", 53, ((OutputActionCase) action1.getActionChoice()).getOutputAction() .getMaxLength().intValue()); - Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); + Action action2 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(1); Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof GroupCase); Assert.assertEquals("Wrong action", 80, ((GroupCase) action2.getActionChoice()).getGroupAction().getGroupId().intValue()); Instruction i6 = instructions.get(5); - Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); - Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); - action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertTrue("Wrong type - i6", i6.getInstructionChoice() instanceof ApplyActionsCase); + Assert.assertEquals("Wrong instructions - i6", 2, ((ApplyActionsCase) i6.getInstructionChoice()) + .getApplyActions().getAction().size()); + action1 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(0); Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof SetQueueCase); Assert.assertEquals("Wrong action", 37, ((SetQueueCase) action1.getActionChoice()).getSetQueueAction() .getQueueId().intValue()); - action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); + action2 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(1); Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof SetMplsTtlCase); Assert.assertEquals("Wrong action", 5, ((SetMplsTtlCase) action2.getActionChoice()).getSetMplsTtlAction() .getMplsTtl().shortValue()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 99290012..251c4c94 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -20,14 +20,6 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; @@ -37,12 +29,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; @@ -73,34 +70,37 @@ public void test() { List instructions = new ArrayList<>(); // Goto_table instruction InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); - TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); - tableIdBuilder.setTableId((short) 5); - builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); + GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder(); + GotoTableBuilder instructionBuilder = new GotoTableBuilder(); + instructionBuilder.setTableId((short) 5); + gotoCaseBuilder.setGotoTable(instructionBuilder.build()); + builder.setInstructionChoice(gotoCaseBuilder.build()); instructions.add(builder.build()); - builder = new InstructionBuilder(); // Write_metadata instruction - builder.setType(WriteMetadata.class); - MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); - metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); - metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); - builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); + builder = new InstructionBuilder(); + WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder(); + WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder(); + metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); + metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); + metadataCaseBuilder.setWriteMetadata(metadataBuilder.build()); + builder.setInstructionChoice(metadataCaseBuilder.build()); instructions.add(builder.build()); // Clear_actions instruction builder = new InstructionBuilder(); - builder.setType(ClearActions.class); + builder.setInstructionChoice(new ClearActionsCaseBuilder().build()); instructions.add(builder.build()); // Meter instruction builder = new InstructionBuilder(); - builder.setType(Meter.class); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); + MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder(); + MeterBuilder meterBuilder = new MeterBuilder(); meterBuilder.setMeterId(42L); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + meterCaseBuilder.setMeter(meterBuilder.build()); + builder.setInstructionChoice(meterCaseBuilder.build()); instructions.add(builder.build()); // Write_actions instruction builder = new InstructionBuilder(); - builder.setType(WriteActions.class); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder(); + WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder(); List actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); @@ -117,13 +117,14 @@ public void test() { ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build()); actionBuilder.setActionChoice(ttlCaseBuilder.build()); actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + writeActionsBuilder.setAction(actions); + writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build()); + builder.setInstructionChoice(writeActionsCaseBuilder.build()); instructions.add(builder.build()); // Apply_actions instruction builder = new InstructionBuilder(); - builder.setType(ApplyActions.class); - actionsBuilder = new ActionsInstructionBuilder(); + ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder(); + ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder(); actions = new ArrayList<>(); actionBuilder = new ActionBuilder(); PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder(); @@ -135,8 +136,9 @@ public void test() { actionBuilder = new ActionBuilder(); actionBuilder.setActionChoice(new PopPbbCaseBuilder().build()); actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + applyActionsBuilder.setAction(actions); + applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build()); + builder.setInstructionChoice(applyActionsCaseBuilder.build()); instructions.add(builder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index 629e2490..dd766389 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -17,8 +17,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; @@ -26,7 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; @@ -97,13 +96,13 @@ public void testInstructionKeyMaker() { Assert.assertNotNull("Null keyMaker", keyMaker); InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); + builder.setInstructionChoice(new GotoTableCaseBuilder().build()); Instruction instruction = builder.build(); MessageTypeKey key = keyMaker.make(instruction); Assert.assertNotNull("Null key", key); Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - GotoTable.class, null), key); + GotoTableCase.class, null), key); } /** @@ -115,11 +114,16 @@ public void testExperimenterInstructionKeyMaker() { Assert.assertNotNull("Null keyMaker", keyMaker); InstructionBuilder builder = new InstructionBuilder(); - builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .common.instruction.rev130731.Experimenter.class); - ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container + .instruction.choice.ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCaseBuilder(); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container + .instruction.choice.experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen + .v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.experimenter.id + ._case.ExperimenterBuilder(); + expIdBuilder.setExperimenterId(new ExperimenterId(42L)); + caseBuilder.setExperimenter(expIdBuilder.build()); + builder.setInstructionChoice(caseBuilder.build()); Instruction instruction = builder.build(); MessageTypeKey key = keyMaker.make(instruction); From 4bbf62e417e19583f616823c81ba25c925963b93 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 19 Mar 2015 10:50:26 +0100 Subject: [PATCH 143/285] Bug 2866 - Fixed ipv6 address parsing - added unit test with uncovered cases Change-Id: Id3ad9263428e6d6cb10c8799d031a1d75b05c98d Signed-off-by: Michal Polkorab --- .../AbstractOxmIpv6AddressSerializer.java | 56 +-------- .../match/OxmIpv6SrcSerializerTest.java | 112 ++++++++++++++++++ .../impl/util/OF13MatchSerializerTest.java | 2 +- 3 files changed, 118 insertions(+), 52 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index 9fa730bd..b84d81cf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -9,14 +9,9 @@ import io.netty.buffer.ByteBuf; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import com.google.common.collect.Lists; +import com.google.common.net.InetAddresses; /** * Parent for Ipv6 address based match entry serializers @@ -25,53 +20,12 @@ public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { protected void writeIpv6Address(String textAddress, final ByteBuf outBuffer) { - List address; - if (textAddress.equals("::")) { - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - address = Arrays.asList(tmp); + if (InetAddresses.isInetAddress(textAddress)) { + byte[] binaryAddress = InetAddresses.forString(textAddress).getAddress(); + outBuffer.writeBytes(binaryAddress); } else { - address = parseIpv6Address(Lists.newArrayList(ByteBufUtils.COLON_SPLITTER.split(textAddress))); - } - for (String group : address) { - outBuffer.writeShort(Integer.parseInt(group, 16)); + throw new IllegalArgumentException("Invalid ipv6 address received: " + textAddress); } } - private static List parseIpv6Address(final List addressGroups) { - int countEmpty = 0; - for (String group : addressGroups) { - if (group.equals("")) { - countEmpty++; - } - } - List ready = new ArrayList<>(EncodeConstants.GROUPS_IN_IPV6_ADDRESS); - switch (countEmpty) { - case 0: - ready = addressGroups; - break; - case 1: - int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.size() + 1; - for (String group : addressGroups) { - if (group.equals("")) { - for (int j = 0; j < zerosToBePushed; j++) { - ready.add("0"); - } - } else { - ready.add(group); - } - } - break; - case 2: - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - tmp[EncodeConstants.GROUPS_IN_IPV6_ADDRESS - 1] = - addressGroups.get(addressGroups.size() - 1); - ready = Arrays.asList(tmp); - break; - default: - throw new IllegalStateException("Incorrect ipv6 address"); - } - return ready; - } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java new file mode 100644 index 00000000..38ca6dc7 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6SrcSerializerTest { + + OxmIpv6SrcSerializer serializer = new OxmIpv6SrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntryBuilder builder = prepareMatchEntry(false, "aaaa:bbbb:1111:2222::"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + Assert.assertEquals("Wrong ipv6 address", 43690, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 48059, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 4369, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 8738, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntryBuilder builder = prepareMatchEntry(false, "::aaaa:bbbb:1111:2222"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 43690, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 48059, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 4369, buffer.readUnsignedShort()); + Assert.assertEquals("Wrong ipv6 address", 8738, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + private static MatchEntryBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntryBuilder builder = prepareHeader(hasMask); + Ipv6SrcCaseBuilder caseBuilder = new Ipv6SrcCaseBuilder(); + Ipv6SrcBuilder srcBuilder = new Ipv6SrcBuilder(); + srcBuilder.setIpv6Address(new Ipv6Address(value)); + if (hasMask) { + srcBuilder.setMask(new byte[]{15, 15, 0, 0}); + } + caseBuilder.setIpv6Src(srcBuilder.build()); + builder.setMatchEntryValue(caseBuilder.build()); + return builder; + } + + private static MatchEntryBuilder prepareHeader(boolean hasMask) { + MatchEntryBuilder builder = new MatchEntryBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6Src.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES, + buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES, buffer.readUnsignedByte()); + } + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index fe1812c9..999607d2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -243,7 +243,7 @@ public void testIpv6Various() { /** * Test for correct serialization of incorrect Ipv6Address match entry */ - @Test(expected=IllegalStateException.class) + @Test(expected=IllegalArgumentException.class) public void testIpv6Incorrect() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); From da1055c5e5262ae8513d23e0bd8bee553debb814 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 26 Mar 2015 15:02:43 -0400 Subject: [PATCH 144/285] Revert "Add odlparent relativepath relative to autorelease" Per discussion on mailing list thread we have decided to revert this change and achieve relative path updating via scripting in autorelease. https://lists.opendaylight.org/pipermail/release/2015-March/001754.html This reverts commit 435f3e8a95843a6e9a326ab56663c31ff6d7cdb7. Change-Id: I2bca2e9309cf8a751a81e11b47f2c01ff6786184 Signed-off-by: Thanh Ha --- features/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 03d34620..4edae6b3 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent features-parent 1.5.0-SNAPSHOT - ../../odlparent/features-parent + org.opendaylight.openflowjava diff --git a/pom.xml b/pom.xml index 226050e9..1b20bbdf 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent 1.5.0-SNAPSHOT - ../odlparent/odlparent + org.opendaylight.openflowjava From fa4138ed29b61d30b529639c646016d7ce864de2 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 26 Mar 2015 15:07:24 +0100 Subject: [PATCH 145/285] Action experimenterId fix Change-Id: Idebe6abbaf24977209857c5d47efe67717e6a027 Signed-off-by: Michal Polkorab --- .../src/main/yang/openflow-action.yang | 3 +++ .../impl/util/TypeKeyMakerFactory.java | 14 ++++---------- .../impl/util/TypeKeyMakerFactoryTest.java | 19 ++++++------------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 4655d15a..576a7f45 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -31,6 +31,9 @@ grouping actions-grouping { list action { uses action-grouping; + leaf experimenter-id { + type oft:experimenter-id; + } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index e74ac05f..e954a436 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -64,15 +63,10 @@ public static TypeKeyMaker createActionKeyMaker(short version) { return new AbstractTypeKeyMaker(version) { @Override public MessageTypeKey make(Action entry) { - if (entry.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .augments.rev150225.action.container.action.choice.ExperimenterIdCase) { - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action - .container.action.choice.ExperimenterIdCase expIdCase = (org.opendaylight.yang.gen.v1.urn - .opendaylight.openflow.augments.rev150225.action.container.action.choice - .ExperimenterIdCase) entry.getActionChoice(); - return new ExperimenterActionSerializerKey(getVersion(), - expIdCase.getExperimenter().getExperimenter().getValue(), - expIdCase.getExperimenter().getSubType()); + if (entry.getExperimenterId() != null) { + return new ActionSerializerKey<>(getVersion(), + (Class) entry.getActionChoice().getImplementedInterface(), + entry.getExperimenterId().getValue()); } return new ActionSerializerKey<>(getVersion(), (Class) entry.getActionChoice().getImplementedInterface(), null); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index dd766389..c6278285 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -11,7 +11,6 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -20,6 +19,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -69,22 +70,14 @@ public void testExperimenterActionKeyMaker() { Assert.assertNotNull("Null keyMaker", keyMaker); org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice - .ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments - .rev150225.action.container.action.choice.ExperimenterIdCaseBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice - .experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight - .openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expIdBuilder.setSubType(ActionSubtypeClass.class); - caseBuilder.setExperimenter(expIdBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + builder.setExperimenterId(new ExperimenterId(42L)); + builder.setActionChoice(new CopyTtlInCaseBuilder().build()); Action action = builder.build(); MessageTypeKey key = keyMaker.make(action); Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, - ActionSubtypeClass.class), key); + Assert.assertEquals("Wrong key", new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, + CopyTtlInCase.class, 42L), key); } /** From 2b5094b8ffd0e06dfaad372437e01ff1bd194623 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 26 Mar 2015 15:27:24 +0100 Subject: [PATCH 146/285] Instruction experimenterId fix Change-Id: I19dde700890e9211b37cfef70b35d764391831f0 Signed-off-by: Michal Polkorab --- .../SerializerExtensionProvider.java | 8 ++++---- .../api/keys/ActionSerializerKey.java | 3 ++- .../api/keys/InstructionSerializerKey.java | 2 +- .../src/main/yang/openflow-instruction.yang | 3 +++ .../core/SwitchConnectionProviderImpl.java | 8 ++++---- .../impl/util/TypeKeyMakerFactory.java | 11 ++++------- .../impl/util/TypeKeyMakerFactoryTest.java | 19 ++++++------------- 7 files changed, 24 insertions(+), 30 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 8729f874..9e73e951 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -8,10 +8,10 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; @@ -47,7 +47,7 @@ public interface SerializerExtensionProvider { * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerActionSerializer(ExperimenterActionSerializerKey key, + void registerActionSerializer(ActionSerializerKey key, OFGeneralSerializer serializer); /** @@ -55,7 +55,7 @@ void registerActionSerializer(ExperimenterActionSerializerKey key, * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + void registerInstructionSerializer(InstructionSerializerKey key, OFGeneralSerializer serializer); /** diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index f23c01c6..7d096f84 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -15,7 +15,8 @@ * @author michal.polkorab * @param action type */ -public class ActionSerializerKey extends MessageTypeKey { +public class ActionSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { private Class actionType; private Long experimenterId; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 6f9a299b..89f5cbfe 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -16,7 +16,7 @@ * @param instruction type */ public class InstructionSerializerKey - extends MessageTypeKey{ + extends MessageTypeKey implements ExperimenterSerializerKey { private Class instructionType; private Long experimenterId; diff --git a/openflow-protocol-api/src/main/yang/openflow-instruction.yang b/openflow-protocol-api/src/main/yang/openflow-instruction.yang index 293e3803..a58fc349 100644 --- a/openflow-protocol-api/src/main/yang/openflow-instruction.yang +++ b/openflow-protocol-api/src/main/yang/openflow-instruction.yang @@ -25,6 +25,9 @@ list instruction { config false; uses instruction-grouping; + leaf experimenter-id { + type oft:experimenter-id; + } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 852ce64f..51b802e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -19,14 +19,14 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; @@ -181,7 +181,7 @@ public boolean unregisterDeserializer(ExperimenterDeserializerKey key) { } @Override - public void registerActionSerializer(ExperimenterActionSerializerKey key, + public void registerActionSerializer(ActionSerializerKey key, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @@ -193,7 +193,7 @@ public void registerActionDeserializer(ExperimenterActionDeserializerKey key, } @Override - public void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + public void registerInstructionSerializer(InstructionSerializerKey key, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index e954a436..7fef029c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.util; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; @@ -83,12 +82,10 @@ public static TypeKeyMaker createInstructionKeyMaker(short version) return new AbstractTypeKeyMaker(version) { @Override public MessageTypeKey make(Instruction entry) { - if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) { - return new ExperimenterInstructionSerializerKey(getVersion(), - ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction - .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice()) - .getExperimenter().getExperimenterId().getValue()); + if (entry.getExperimenterId() != null) { + return new InstructionSerializerKey<>(getVersion(), + (Class) entry.getInstructionChoice().getImplementedInterface(), + entry.getExperimenterId().getValue()); } return new InstructionSerializerKey<>(getVersion(), (Class) entry.getInstructionChoice().getImplementedInterface(), null); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index c6278285..0cfb0940 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -11,7 +11,6 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; @@ -25,6 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; @@ -107,22 +108,14 @@ public void testExperimenterInstructionKeyMaker() { Assert.assertNotNull("Null keyMaker", keyMaker); InstructionBuilder builder = new InstructionBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container - .instruction.choice.ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn - .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCaseBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container - .instruction.choice.experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen - .v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.experimenter.id - ._case.ExperimenterBuilder(); - expIdBuilder.setExperimenterId(new ExperimenterId(42L)); - caseBuilder.setExperimenter(expIdBuilder.build()); - builder.setInstructionChoice(caseBuilder.build()); + builder.setExperimenterId(new ExperimenterId(42L)); + builder.setInstructionChoice(new ClearActionsCaseBuilder().build()); Instruction instruction = builder.build(); MessageTypeKey key = keyMaker.make(instruction); Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, - 42L), key); + Assert.assertEquals("Wrong key", new InstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, + ClearActionsCase.class, 42L), key); } /** From 45b551b9ca2ef8da9b67a0a877711798f1780355 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 28 Mar 2015 17:42:59 +0100 Subject: [PATCH 147/285] Fix checkstyle Wrong indent, trailing whitespace, unused imports, tabs. Change-Id: I34d1673fc61d8de31bc0a79509e8317b5622c958 Signed-off-by: Robert Varga --- .../api/connection/ConnectionAdapter.java | 9 +- .../connection/ConnectionConfiguration.java | 13 +- .../protocol/api/keys/MessageTypeKey.java | 8 +- .../protocol/api/util/BinContent.java | 2 +- .../protocol/api/util/OxmMatchConstants.java | 2 +- .../EnhancedMessageCodeKeyTest.java | 8 +- .../EnhancedMessageTypeKeyTest.java | 10 +- .../api/extensibility/MessageTypeKeyTest.java | 28 ++-- .../api/keys/ActionSerializerKeyTest.java | 24 +-- .../keys/MatchEntryDeserializerKeyTest.java | 26 ++-- .../ExperimenterIdDeserializerKeyTest.java | 18 +-- .../connection/ConnectionAdapterImpl.java | 2 +- .../factories/OF10ErrorMessageFactory.java | 146 +++++++++--------- .../protocol/impl/util/ListSerializer.java | 2 +- .../protocol/impl/util/OpenflowUtils.java | 2 +- .../impl/util/TypeKeyMakerFactory.java | 2 +- .../impl/core/OFVersionDetectorTest.java | 13 +- .../ConnectionAdapterImpl02Test.java | 2 +- .../OF10ErrorMessageFactoryTest.java | 84 +++++----- .../OF10HelloMessageFactoryTest.java | 2 +- .../statistics/StatisticsCountersTest.java | 2 +- .../protocol/it/integration/MockPlugin.java | 2 +- .../openflowjava/util/ByteBufUtils.java | 4 +- .../ExperimenterDeserializerKeyFactory.java | 2 +- 24 files changed, 199 insertions(+), 214 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 6d61a217..a205e5e6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -65,13 +65,12 @@ public interface ConnectionAdapter extends OpenflowProtocolService { /** * sets option for automatic channel reading; - * if set to false, incoming messages won't be read + * if set to false, incoming messages won't be read */ - void setAutoRead(boolean autoRead); + void setAutoRead(boolean autoRead); - /** + /** * @return true, if channel is configured to autoread */ - boolean isAutoRead(); - + boolean isAutoRead(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index cfb04293..310e0a5a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -5,17 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.api.connection; import java.net.InetAddress; -import javax.net.ssl.SSLEngine; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; - /** * @author mirehak - * */ public interface ConnectionConfiguration { @@ -40,12 +35,14 @@ public interface ConnectionConfiguration { TlsConfiguration getTlsConfiguration(); /** - * @return silence time (in milliseconds) - after this time {@link SwitchIdleEvent} message is sent upstream + * @return silence time (in milliseconds) - after this time + * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent} + * message is sent upstream */ long getSwitchIdleTimeout(); /** - * @return seed for {@link SSLEngine} + * @return seed for {@link javax.net.ssl.SSLEngine} */ Object getSslContext(); @@ -53,4 +50,4 @@ public interface ConnectionConfiguration { * @return thread numbers for TcpHandler's eventloopGroups */ ThreadConfiguration getThreadConfiguration(); -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java index 507a466f..5a130cb1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageTypeKey.java @@ -5,14 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; - - /** - * Class used as a key in {@link SerializerRegistry} + * Class used as a key in {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry} * @author michal.polkorab * @author timotej.kubas * @param message type (class) @@ -69,4 +65,4 @@ public boolean equals(Object obj) { } return true; } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java index 428b5004..700fdf4d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java @@ -17,7 +17,7 @@ public abstract class BinContent { private BinContent() { //not called } - + /** * @param value * @return int part wrapped in long diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 78a5871c..3768f2f5 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -114,7 +114,7 @@ public abstract class OxmMatchConstants { public static final int NXM_NX_TUN_IPV4_DST = 32; /** NXM TCP_Flag value */ public static final int NXM_NX_TCP_FLAG = 34; - + private OxmMatchConstants() { //not called } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index edfa5721..6e08c1e4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -53,11 +53,11 @@ public void test() { */ @Test public void testEquals() { - EnhancedMessageCodeKey key1 = + EnhancedMessageCodeKey key1 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); } /** @@ -71,4 +71,4 @@ public void testToString() { Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index 20233893..eb19e7ff 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -78,9 +78,9 @@ public void testToString() { EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, OutputActionCase.class); - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action msgType2:" - + " org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action" - + ".grouping.action.choice.OutputActionCase", key1.toString()); + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action msgType2:" + + " org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action" + + ".grouping.action.choice.OutputActionCase", key1.toString()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 4788ddf3..7a45015a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -48,20 +48,20 @@ public void test() { */ @Test public void testEquals() { - MessageTypeKey key1; - MessageTypeKey key2; - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key1; + MessageTypeKey key2; + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to null.", key1.equals(null)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); } /** @@ -69,9 +69,9 @@ public void testEquals() { */ @Test public void testToString() { - MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index caade81e..9fdde0ae 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -53,19 +53,19 @@ public void test() { */ @Test public void testEquals(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - CopyTtlInCase.class, 42L); + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + CopyTtlInCase.class, 42L); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlInCase.class, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); } /** @@ -81,4 +81,4 @@ public void testToString(){ + " org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action" + ".grouping.action.choice.CopyTtlInCase experimenterID: 42", key1.toString()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index c9c84688..ceefbc1b 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -52,21 +52,21 @@ public void test() { */ @Test public void testEquals() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Long expId1=123456L; - Long expId2=654321L; - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Long expId1=123456L; + Long expId2=654321L; + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); } /** @@ -80,4 +80,4 @@ public void testToString(){ + ".opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry" + " msgType: 32768 oxm_field: 42 experimenterID: null", key1.toString()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index fba55191..eb71029a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -55,14 +55,14 @@ public void test() { */ @Test public void testEquals() { - ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); - ExperimenterIdDeserializerKey key2 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index d81363c7..a38e1700 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -474,7 +474,7 @@ public void setResponseCache(Cache Date: Sat, 28 Mar 2015 18:15:06 +0100 Subject: [PATCH 148/285] Fix Java 8 javadoc compatibility Java 8 is more picky about javadocs -- make sure we can pass compilation. Change-Id: I816b25cc439cc7eadd8e073205611cb15ab95e9b Signed-off-by: Robert Varga --- .../extensibility/DeserializerExtensionProvider.java | 4 ++-- .../api/extensibility/DeserializerRegistry.java | 1 - .../extensibility/SerializerExtensionProvider.java | 4 ++-- .../api/extensibility/SerializerRegistry.java | 11 +++-------- .../protocol/api/keys/InstructionSerializerKey.java | 3 +-- .../protocol/api/keys/MatchEntrySerializerKey.java | 3 +-- .../impl/core/SwitchConnectionProviderImpl.java | 4 ++-- .../impl/serialization/SerializerRegistryImpl.java | 4 ++-- .../protocol/impl/util/AbstractCodeKeyMaker.java | 3 --- .../protocol/impl/util/ActionConstants.java | 4 ++-- .../impl/util/ActionDeserializerRegistryHelper.java | 2 -- .../impl/util/ActionSerializerRegistryHelper.java | 3 +-- .../util/InstructionDeserializerRegistryHelper.java | 2 -- .../protocol/impl/util/ListSerializer.java | 1 - .../protocol/impl/util/TypeToClassInitHelper.java | 2 +- .../openflowjava/statistics/StatisticsCounters.java | 6 +++--- .../protocol/impl/clients/ListeningSimpleClient.java | 10 ++++++++-- .../protocol/impl/clients/ScenarioFactory.java | 8 ++++---- .../opendaylight/openflowjava/util/ByteBufUtils.java | 10 ++++++---- 19 files changed, 38 insertions(+), 47 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index abd85ba5..b38b5cfa 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -24,7 +24,7 @@ * In case of handling multiple multiple structures of same type (actions, * instructions, match entries, ... ) which are differentiated by * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
+ * these subtypes.
* * This has to be done in this way because of experimenter headers, which * provide only vendor / experimenter ID. Subtype position may be different @@ -113,4 +113,4 @@ void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, */ void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, OFDeserializer deserializer); -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 04291b8f..6970a1dc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -45,7 +45,6 @@ void registerDeserializer(MessageCodeKey key, /** * Unregisters deserializer * @param key used for deserializer lookup - * @param deserializer deserializer instance * @return true if deserializer was removed, * false if no deserializer was found under specified key */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 9e73e951..7d83cd82 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -26,7 +26,7 @@ * In case of handling multiple structures of same type (actions, * instructions, match entries, ... ) which are differentiated by * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
+ * these subtypes.
* * This has to be done in this way because of unknown augmentations * - that's why vendor has to handle it in his own implementations. @@ -97,4 +97,4 @@ void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, OFSerializer serializer); -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 716281c4..7fb39bbd 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -9,22 +9,18 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; - - - /** - * Stores and handles serializers
- * K - {@link MessageTypeKey} parameter type,
+ * Stores and handles serializers
+ * K - {@link MessageTypeKey} parameter type,
* S - returned serializer type * @author michal.polkorab - * */ public interface SerializerRegistry { /** * Serializer registry provisioning */ - public void init(); + void init(); /** * @param msgTypeKey lookup key @@ -49,7 +45,6 @@ void registerSerializer(MessageTypeKey key, /** * Unregisters serializer * @param key used for serializer lookup - * @param serializer serializer implementation * @return true if serializer was removed, * false if no serializer was found under specified key */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 89f5cbfe..213b22db 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -23,7 +23,6 @@ public class InstructionSerializerKey /** * @param msgVersion protocol wire version - * @param objectType class of serialized object (Instruction.class) * @param instructionType type of instruction * @param experimenterId experimenter / vendor ID */ @@ -77,4 +76,4 @@ public String toString() { return super.toString() + " instructionType type: " + instructionType.getName() + " vendorID: " + experimenterId; } -} \ No newline at end of file +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index a0867ceb..75fcd3e6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -26,7 +26,6 @@ public final class MatchEntrySerializerKey - * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)
+ * Exposed class for server handling
+ * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)
* F - {@link MatchEntrySerializerKey} parameter representing oxm_field (see specification) * @author mirehak * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 26cdda1a..9a4c2085 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -24,8 +24,8 @@ import org.slf4j.LoggerFactory; /** - * Stores and handles serializers
- * K - {@link MessageTypeKey} type
+ * Stores and handles serializers
+ * K - {@link MessageTypeKey} type
* S - returned serializer type * @author michal.polkorab * @author timotej.kubas diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java index 45f521e1..7aff0aa7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java @@ -5,13 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.protocol.impl.util; - /** * @author michal.polkorab - * @param type the key maker is based on */ public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java index d05b8cd8..41791780 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java @@ -14,7 +14,7 @@ */ public final class ActionConstants { - /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ + /** Openflow v1.0 and v1.3 OFPAT_OUTPUT code */ public static final byte OUTPUT_CODE = 0; /** Openflow v1.0 OFPAT_SET_VLAN_VID code */ public static final byte SET_VLAN_VID_CODE = 1; @@ -96,7 +96,7 @@ public final class ActionConstants { /** Most common action length */ public static final byte GENERAL_ACTION_LENGTH = 8; /** Action larger than GENERAL_ACTION_LENGTH - currently - * only 16 bytes long actions for both OF v1.0 & v1.3*/ + * only 16 bytes long actions for both OF v1.0 and v1.3*/ public static final byte LARGER_ACTION_LENGTH = 16; /** Action header size */ public static final byte ACTION_IDS_LENGTH = 4; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java index 2f48763a..49c1b6fc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java @@ -32,8 +32,6 @@ public ActionDeserializerRegistryHelper(short version, DeserializerRegistry dese /** * @param code code / value to distinguish between deserializers * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer */ public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { registry.registerDeserializer(new ActionDeserializerKey(version, code, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index 32b6ac0e..b622dd17 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -22,7 +22,6 @@ public class ActionSerializerRegistryHelper { /** * @param version Openflow wire version - * @param objectType * @param serializerRegistry */ public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { @@ -40,4 +39,4 @@ public void registerSerializer(Class actionType, serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, actionType, null), serializer); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java index 44a6a884..19149e10 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java @@ -32,8 +32,6 @@ public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry /** * @param code code / value to distinguish between deserializers * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer */ public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { registry.registerDeserializer(new InstructionDeserializerKey(version, code, diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index 7925281b..7392be76 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -20,7 +20,6 @@ /** * Serializes list items and their headers * @author michal.polkorab - * @param */ public abstract class ListSerializer { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index 672cdea6..339edd18 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -32,7 +32,7 @@ public TypeToClassInitHelper(short version, Map class + * @param clazz class corresponding to the code */ public void registerTypeToClass(short type, Class clazz) { messageClassMap.put(new TypeToClassKey(version, type), clazz); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 89eeff92..f3566a09 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -186,8 +186,8 @@ public boolean isCounterEnabled(CounterEventTypes counterEventKey){ /** * Get counter by CounterEventType * @param counterEventKey key to identify counter (can not be null) - * @return - Counter object or null if counter has not been enabled - * @exception - IllegalArgumentException if counterEventKey is null + * @return Counter object or null if counter has not been enabled + * @throws IllegalArgumentException if counterEventKey is null */ public Counter getCounter(CounterEventTypes counterEventKey) { if (counterEventKey == null) { @@ -245,4 +245,4 @@ public void run() { } } } -} \ No newline at end of file +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java index 0288745f..559c2279 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.openflowjava.protocol.impl.clients; import io.netty.bootstrap.ServerBootstrap; @@ -33,7 +40,6 @@ public class ListeningSimpleClient implements OFClient { /** * Constructor of the class * - * @param host address of host * @param port host listening port */ public ListeningSimpleClient(int port) { @@ -121,4 +127,4 @@ public void setScenarioHandler(ScenarioHandler scenario) { public int getPort() { return this.port; } -} \ No newline at end of file +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index f0e5b9cf..5b4e669a 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -25,8 +25,8 @@ private ScenarioFactory() { } /** - * Creates stack with handshake needed messages. - *
    XID of messages: + * Creates stack with handshake needed messages. XID of messages: + *
      *
    1. hello sent - 00000001 *
    2. hello waiting - 00000002 *
    3. featuresrequest waiting - 00000003 @@ -45,8 +45,8 @@ public static Deque createHandshakeScenario() { } /** - * Creates stack with handshake needed messages. - *
        XID of messages: + * Creates stack with handshake needed messages. XID of messages: + *
          *
        1. hello sent - 00000001 *
        2. hello waiting - 00000002 *
        3. featuresrequest waiting - 00000003 diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 43ced124..61344291 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -224,10 +224,11 @@ private static int hexValue(final char c) { } /** - * Converts macAddress to byte array + * Converts macAddress to byte array. + * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress}. + * * @param macAddress * @return byte representation of mac address - * @see {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress} */ public static byte[] macAddressToBytes(final String macAddress) { final byte[] result = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; @@ -279,10 +280,11 @@ private static void appendHexUnsignedShort(final StringBuilder sb, final int val } /** - * Converts a MAC address represented in bytes to String + * Converts a MAC address represented in bytes to String. + * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress}. + * * @param address * @return String representation of a MAC address - * @see {@link MacAddress} */ public static String macAddressToString(final byte[] address) { Preconditions.checkArgument(address.length == EncodeConstants.MAC_ADDRESS_LENGTH); From 0d5298ca05c0a877dd0c6885bc93b2d3fdf396aa Mon Sep 17 00:00:00 2001 From: Anton Ivanov Date: Fri, 27 Mar 2015 08:09:08 +0000 Subject: [PATCH 149/285] BUG 2905 TCP Options incorrect OpenFlow requires latency related optimizations, not throughput ones (in the TCP sense of this word). Signed-off-by: Anton Ivanov --- .../opendaylight/openflowjava/protocol/impl/core/TcpHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 48d5aa14..ff4bc6a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -102,6 +102,7 @@ public void run() { .option(ChannelOption.SO_BACKLOG, 128) .option(ChannelOption.SO_REUSEADDR, true) .childOption(ChannelOption.SO_KEEPALIVE, true) + .childOption(ChannelOption.TCP_NODELAY , true) .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT) .childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, DEFAULT_WRITE_HIGH_WATERMARK * 1024) .childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, DEFAULT_WRITE_LOW_WATERMARK * 1024) From 93508e494455287d9d9489c47cce2eae87de1ff9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 31 Mar 2015 11:22:05 +0200 Subject: [PATCH 150/285] Remove mention on enunciate It is not used anywhere in the project, so let's not mention it. Change-Id: I7c2aa4c9f476c8c127d5a4b3c6ec4a8ceb04b5d8 Signed-off-by: Robert Varga --- pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pom.xml b/pom.xml index 1b20bbdf..25f35759 100644 --- a/pom.xml +++ b/pom.xml @@ -265,19 +265,6 @@ - - - org.codehaus.enunciate - maven-enunciate-plugin - [0.0,) - - docs - - - - - - org.jacoco From e6856ada13f0d5b06e0f6fdf74edd45b512b31fc Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 9 Apr 2015 16:33:48 +0200 Subject: [PATCH 151/285] Bug 2926 - API yangs hidden Change-Id: Icf250c0aab45ccfd0d48361d24828fdb0002ed29 Signed-off-by: Michal Polkorab --- openflow-protocol-api/pom.xml | 50 ++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 1ec8261f..faf463ac 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.opendaylight.openflowjava @@ -9,8 +10,8 @@ bundle Openflow Protocol Library - API - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD @@ -53,10 +54,51 @@ + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + prepare-package + + run + + + + + + + + + + + + + + + + + + + + + + + + - org.eclipse.m2e From d51416320a39973f1cc8fe6de58e6ec769d8ac90 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 29 Apr 2015 19:03:50 +0200 Subject: [PATCH 152/285] Bumped openflowjava versions by minor for next release cycle Change-Id: I4f1f78cc58aa3e81a2196c794f39def2331f49b7 Signed-off-by: Michal Polkorab --- artifacts/pom.xml | 2 +- features/pom.xml | 10 +++++----- openflow-protocol-api/pom.xml | 2 +- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-it/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- openflowjava-config/pom.xml | 2 +- pom.xml | 12 ++++++------ simple-client/pom.xml | 2 +- util/pom.xml | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index d1840736..5b452b21 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -12,7 +12,7 @@ 4.0.0 org.opendaylight.openflowjava openflowjava-artifacts - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT pom diff --git a/features/pom.xml b/features/pom.xml index 4edae6b3..771afeb0 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,19 +4,19 @@ org.opendaylight.odlparent features-parent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT org.opendaylight.openflowjava features-openflowjava - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT jar - 0.3.0-SNAPSHOT - 1.2.0-SNAPSHOT - 0.7.0-SNAPSHOT + 0.4.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index faf463ac..a5b7b4fb 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflow-protocol-api bundle diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 23d0e9fb..7ae85449 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflow-protocol-impl bundle diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 2aafc74e..54f586df 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflow-protocol-it bundle diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index b2e13905..5a7432aa 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflow-protocol-spi bundle diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index deeade0d..ccdb859c 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflowjava-config Configuration files for openflowjava statistics diff --git a/pom.xml b/pom.xml index 25f35759..6ebe3748 100644 --- a/pom.xml +++ b/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent odlparent - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT openflowjava pom @@ -36,12 +36,12 @@ dav:http://nexus.opendaylight.org/content/sites/site UTF-8 ${project.build.directory}/yang-gen-config - 1.5.0-SNAPSHOT + 1.6.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - 0.3.0-SNAPSHOT - 1.2.0-SNAPSHOT - 0.7.0-SNAPSHOT + 0.4.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT 2.4 diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 1df035ea..567cdaae 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT simple-client bundle diff --git a/util/pom.xml b/util/pom.xml index 2dc05398..a05f694a 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.openflowjava openflow-protocol-parent - 0.6.0-SNAPSHOT + 0.7.0-SNAPSHOT bundle util From 291ee196f45bd603979c10ecacae117b41c60881 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 12 May 2015 17:34:05 +0200 Subject: [PATCH 153/285] Speedup ChannelOutboundQueue flush end At the end of a flush we report statistics at debug, but that requires System.nanoTime(). Make that call conditional on debug being enabled. Change-Id: Ibdf02b93ca12d8930227de059d107aa3c4ccb88d Signed-off-by: Robert Varga (cherry picked from commit d25d4e071936d072cd4a847f4414bfe560bfd8a4) --- .../impl/core/connection/ChannelOutboundQueue.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index 73812930..a3ce3d5e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.base.Preconditions; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; @@ -15,19 +16,15 @@ import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; - import java.net.InetSocketAddress; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; - /** * Channel handler which bypasses wraps on top of normal Netty pipeline, allowing * writes to be enqueued from any thread, it then schedules a task pipeline task, @@ -215,9 +212,11 @@ private synchronized void flush() { channel.flush(); } - final long stop = System.nanoTime(); - LOG.debug("Flushed {} messages in {}us to channel {}", + if (LOG.isDebugEnabled()) { + final long stop = System.nanoTime(); + LOG.debug("Flushed {} messages in {}us to channel {}", messages, TimeUnit.NANOSECONDS.toMicros(stop - start), channel); + } /* * We are almost ready to terminate. This is a bit tricky, because From d64cf79c05e8e8d9fcf840971b58a991e95563bf Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 13 May 2015 03:08:56 +0200 Subject: [PATCH 154/285] Cache pattern splitters Splitters are reusable, so make sure we cache them in a constant and reuse as needed. Change-Id: I87b50b790b758ad275e6095c1e820385c535968d Signed-off-by: Robert Varga (cherry picked from commit 2cf784ba8553237e6c6714a2ca0ee2414f0b029e) --- .../openflowjava/util/ByteBufUtils.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 61344291..d68f6f9c 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -9,21 +9,18 @@ package org.opendaylight.openflowjava.util; +import com.google.common.base.Preconditions; +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; +import com.google.common.primitives.UnsignedBytes; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - import java.util.List; import java.util.Map; import java.util.Map.Entry; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import com.google.common.base.Preconditions; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.common.primitives.UnsignedBytes; - /** Class for common operations on ByteBuf * @author michal.polkorab * @author timotej.kubas @@ -32,6 +29,8 @@ public abstract class ByteBufUtils { public static final Splitter DOT_SPLITTER = Splitter.on('.'); public static final Splitter COLON_SPLITTER = Splitter.on(':'); private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray(); + private static final Splitter HEXSTRING_SPLITTER = Splitter.onPattern("\\s+").omitEmptyStrings(); + private static final Splitter HEXSTRING_NOSPACE_SPLITTER = Splitter.onPattern("(?<=\\G.{2})").omitEmptyStrings(); private ByteBufUtils() { //not called @@ -65,14 +64,9 @@ public static byte[] hexStringToBytes(final String hexSrc) { * @param withSpaces if there are spaces in string * @return byte[] filled with input data */ - public static byte[] hexStringToBytes(final String hexSrc, final boolean withSpaces ) { - String splitPattern = "\\s+"; - if (!withSpaces) { - splitPattern = "(?<=\\G.{2})"; - } - Iterable tmp = Splitter.onPattern(splitPattern) - .omitEmptyStrings().split(hexSrc); - List byteChips = Lists.newArrayList(tmp); + public static byte[] hexStringToBytes(final String hexSrc, final boolean withSpaces) { + final Splitter splitter = withSpaces ? HEXSTRING_SPLITTER : HEXSTRING_NOSPACE_SPLITTER; + List byteChips = Lists.newArrayList(splitter.split(hexSrc)); byte[] result = new byte[byteChips.size()]; int i = 0; for (String chip : byteChips) { From 5f09789d3ccd1b102e1d3f9ffe24db3da8b9e9c1 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 13 May 2015 15:18:04 +0200 Subject: [PATCH 155/285] Bug 3178 - Statistics collection turned on by default Change-Id: I75c540f22db1f79dafe61a80278cd0181ba1e551 Signed-off-by: Michal Polkorab (cherry picked from commit 350839172904ad939f0c6de03445e456c37ad86b) --- features/src/main/features/features.xml | 3 --- .../src/main/resources/45-openflowjava-stats.xml | 8 -------- 2 files changed, 11 deletions(-) diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index e43bada6..1db95530 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -24,9 +24,6 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} mvn:org.opendaylight.openflowjava/util/{{VERSION}} - - - odl-openflowjava-protocol mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats diff --git a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml index 882d7e18..d3b96e51 100644 --- a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml +++ b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml @@ -25,14 +25,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html true 10000 - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-default - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-legacy - From 95b103939343f1fc851c67899f707fffade70ef1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 11 May 2015 21:18:29 +0200 Subject: [PATCH 156/285] BUG-3219: Introduce OutboundQueueHandler and related interfaces This patch introduces a barrier-enabled outbound queue. The queue works in reserve/commit manner and notifies users with the result of the requests. XID allocation occurs as an offset in a particular queue. Change-Id: Icd3ceda34746be0346ac59b8ed46352db3be9a2f Signed-off-by: Robert Varga (cherry picked from commit 0d3ddb408c6a37ff48f98c7e7d9dd00808b4c486) --- .../api/connection/ConnectionAdapter.java | 15 +- .../api/connection/OutboundQueue.java | 40 ++ .../api/connection/OutboundQueueHandler.java | 37 ++ .../OutboundQueueHandlerRegistration.java | 23 + .../connection/ConnectionAdapterImpl.java | 70 ++- .../core/connection/OutboundQueueEntry.java | 90 ++++ .../OutboundQueueHandlerRegistrationImpl.java | 18 + .../core/connection/OutboundQueueImpl.java | 239 ++++++++++ .../core/connection/OutboundQueueManager.java | 424 ++++++++++++++++++ 9 files changed, 934 insertions(+), 22 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandler.java create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandlerRegistration.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueHandlerRegistrationImpl.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index a205e5e6..02679f05 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -5,13 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - - package org.opendaylight.openflowjava.protocol.api.connection; +import com.google.common.annotations.Beta; import java.net.InetSocketAddress; import java.util.concurrent.Future; - import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; @@ -73,4 +71,15 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * @return true, if channel is configured to autoread */ boolean isAutoRead(); + + /** + * Registers a new bypass outbound queue + * @param handler + * @param maxQueueDepth + * @param maxBarrierNanos + * @return An {@link OutboundQueueHandlerRegistration} + */ + @Beta + OutboundQueueHandlerRegistration registerOutboundQueueHandler(T handler, + int maxQueueDepth, long maxBarrierNanos); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java new file mode 100644 index 00000000..1291c22c --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +import com.google.common.annotations.Beta; +import com.google.common.util.concurrent.FutureCallback; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +@Beta +public interface OutboundQueue { + /** + * Reserve an entry in the outbound queue. + * @return XID for the new message, or null if the queue is full + */ + Long reserveEntry(); + + /** + * Commit the specified offset using a message. Specified callback will + * be invoked once we know how it has resolved, either with a normal response, + * implied completion via a barrier, or failure (such as connection drop). For + * multipart responses, {@link FutureCallback#onSuccess(Object)} will be invoked + * multiple times as the corresponding responses arrive. If the request is completed + * with a response, the object reported will be non-null. If the request's completion + * is implied by a barrier, the object reported will be null. + * + * @param xid Previously-reserved XID + * @param message Message which should be sent out, or null if the reservation + * should be cancelled. + * @param callback Callback to be invoked, or null if no callback should be invoked. + * @throws IllegalArgumentException if the slot is already committed or was never reserved. + */ + void commitEntry(@Nonnull Long xid, @Nullable OfHeader message, @Nullable FutureCallback callback); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandler.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandler.java new file mode 100644 index 00000000..08007985 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandler.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +import com.google.common.annotations.Beta; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; + +/** + * Handler of the outbound queue. The queue has a maximum depth assigned when the + * handler is registered. + */ +@Beta +public interface OutboundQueueHandler { + /** + * Create a new {@link BarrierInput barrier} message. This callback is invoked + * when the queue is being flushed to the switch. The barrier ensures that any + * outstanding requests are detected as either completed or failed. + * + * @param xid XID for the barrier message + * @return New barrier message. + */ + @Nonnull BarrierInput createBarrierRequest(@Nonnull Long xid); + + /** + * Invoked whenever the underlying queue is refreshed. Implementations should + * ensure they are talking to the latest queue + * @param queue New queue instance, null indicates a shutdown, e.g. the queue + * is no longer available. + */ + void onConnectionQueueChanged(OutboundQueue queue); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandlerRegistration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandlerRegistration.java new file mode 100644 index 00000000..d31d1abb --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueHandlerRegistration.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +import com.google.common.annotations.Beta; +import org.opendaylight.yangtools.concepts.ObjectRegistration; + +/** + * An {@link ObjectRegistration} of a {@link OutboundQueueHandler}. Registration can be cancelled + * by invoking {@link #close()}. + * + * @param Handler type + */ +@Beta +public interface OutboundQueueHandlerRegistration extends ObjectRegistration { + @Override + void close(); +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index a38e1700..20e4c2a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -9,16 +9,24 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.base.Preconditions; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalCause; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.util.concurrent.GenericFutureListener; - import java.net.InetSocketAddress; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; import org.opendaylight.openflowjava.statistics.CounterEventTypes; import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; @@ -66,15 +74,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalCause; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - /** * Handles messages (notifications + rpcs) and connections * @author mirehak @@ -115,8 +114,10 @@ public void onRemoval( private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; private SystemNotificationsListener systemListener; + private OutboundQueueManager outputManager; private boolean disconnectOccured = false; - private StatisticsCounters statisticsCounters; + private final StatisticsCounters statisticsCounters; + private final InetSocketAddress address; /** * default ctor @@ -131,6 +132,7 @@ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress addr .removalListener(REMOVAL_LISTENER).build(); this.channel = Preconditions.checkNotNull(channel); this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); + this.address = address; channel.pipeline().addLast(output); statisticsCounters = StatisticsCounters.getInstance(); LOG.debug("ConnectionAdapter created"); @@ -285,6 +287,9 @@ public void consume(final DataObject message) { statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ExperimenterMessage) { messageListener.onExperimenterMessage((ExperimenterMessage) message); + if (outputManager != null) { + outputManager.onMessage((OfHeader) message); + } statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof FlowRemovedMessage) { messageListener.onFlowRemovedMessage((FlowRemovedMessage) message); @@ -295,6 +300,9 @@ public void consume(final DataObject message) { statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof MultipartReplyMessage) { messageListener.onMultipartReplyMessage((MultipartReplyMessage) message); + if (outputManager != null) { + outputManager.onMessage((OfHeader) message); + } statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PacketInMessage) { messageListener.onPacketInMessage((PacketInMessage) message); @@ -305,9 +313,10 @@ public void consume(final DataObject message) { } else { LOG.warn("message listening not supported for type: {}", message.getClass()); } - } else { - if (message instanceof OfHeader) { - LOG.debug("OFheader msg received"); + } else if (message instanceof OfHeader) { + LOG.debug("OFheader msg received"); + + if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { RpcResponseKey key = createRpcResponseKey((OfHeader) message); final ResponseExpectedRpcListener listener = findRpcResponse(key); if (listener != null) { @@ -319,9 +328,9 @@ public void consume(final DataObject message) { } else { LOG.warn("received unexpected rpc response: {}", key); } - } else { - LOG.warn("message listening not supported for type: {}", message.getClass()); } + } else { + LOG.warn("message listening not supported for type: {}", message.getClass()); } } @@ -466,7 +475,7 @@ public InetSocketAddress getRemoteAddress() { * Used only for testing purposes * @param cache */ - public void setResponseCache(Cache> cache) { + public void setResponseCache(final Cache> cache) { this.responseCache = cache; } @@ -476,7 +485,30 @@ public boolean isAutoRead() { } @Override - public void setAutoRead(boolean autoRead) { + public void setAutoRead(final boolean autoRead) { channel.config().setAutoRead(autoRead); } + + @Override + public OutboundQueueHandlerRegistration registerOutboundQueueHandler( + final T handler, final int maxQueueDepth, final long maxBarrierNanos) { + Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager); + + final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); + outputManager = ret; + channel.pipeline().addLast(outputManager); + + return new OutboundQueueHandlerRegistrationImpl(handler) { + @Override + protected void removeRegistration() { + outputManager.close(); + channel.pipeline().remove(outputManager); + outputManager = null; + } + }; + } + + Channel getChannel() { + return channel; + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java new file mode 100644 index 00000000..c0c2f764 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FutureCallback; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class OutboundQueueEntry { + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueEntry.class); + private FutureCallback callback; + private OfHeader message; + private boolean completed; + private volatile boolean committed; + + void commit(final OfHeader message, final FutureCallback callback) { + this.message = message; + this.callback = callback; + + // Volatile write, needs to be last + committed = true; + } + + void reset() { + callback = null; + message = null; + completed = false; + + // Volatile write, needs to be last + committed = false; + } + + boolean isBarrier() { + return message instanceof BarrierInput; + } + + boolean isCommitted() { + return committed; + } + + boolean isCompleted() { + return completed; + } + + OfHeader getMessage() { + return message; + } + + boolean complete(final OfHeader response) { + Preconditions.checkState(!completed, "Attempted to complete a completed message %s with response %s", message, response); + + // Multipart requests are special, we have to look at them to see + // if there is something outstanding and adjust ourselves accordingly + final boolean reallyComplete; + if (response instanceof MultipartReplyMessage) { + reallyComplete = !((MultipartReplyMessage) response).getFlags().isOFPMPFREQMORE(); + LOG.debug("Multipart reply {}", response); + } else { + reallyComplete = true; + } + + completed = reallyComplete; + if (callback != null) { + callback.onSuccess(response); + } + LOG.debug("Entry {} completed {} with response {}", this, completed, response); + return reallyComplete; + } + + void fail(final Throwable cause) { + if (!completed) { + completed = true; + if (callback != null) { + callback.onFailure(cause); + } + } else { + LOG.warn("Ignoring failure {} for completed message {}", cause, message); + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueHandlerRegistrationImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueHandlerRegistrationImpl.java new file mode 100644 index 00000000..697d2ddd --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueHandlerRegistrationImpl.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; +import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; + +abstract class OutboundQueueHandlerRegistrationImpl extends AbstractObjectRegistration implements OutboundQueueHandlerRegistration { + protected OutboundQueueHandlerRegistrationImpl(final T instance) { + super(instance); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java new file mode 100644 index 00000000..1bb9ec4b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FutureCallback; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.locks.LockSupport; +import javax.annotation.Nonnull; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class OutboundQueueImpl implements OutboundQueue { + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueImpl.class); + private static final AtomicIntegerFieldUpdater CURRENT_OFFSET_UPDATER = + AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "reserveOffset"); + private static final long FLUSH_RETRY_NANOS = 1L; + private final OutboundQueueManager manager; + private final OutboundQueueEntry[] queue; + private final long baseXid; + private final long endXid; + private final int reserve; + + // Updated concurrently + private volatile int reserveOffset; + + // Updated from Netty only + private int flushOffset; + private int completeCount; + + OutboundQueueImpl(final OutboundQueueManager manager, final long baseXid, final int maxQueue) { + /* + * We use the last entry as an emergency should a timeout-triggered + * flush request race with normal users for the last entry in this + * queue. In that case the flush request will take the last entry and + * schedule a flush, which means that we will get around sending the + * message as soon as the user finishes the reservation. + */ + Preconditions.checkArgument(maxQueue > 1); + this.baseXid = baseXid; + this.endXid = baseXid + maxQueue; + this.reserve = maxQueue - 1; + this.manager = Preconditions.checkNotNull(manager); + queue = new OutboundQueueEntry[maxQueue]; + for (int i = 0; i < maxQueue; ++i) { + queue[i] = new OutboundQueueEntry(); + } + } + + private OutboundQueueImpl(final OutboundQueueManager manager, final long baseXid, final OutboundQueueEntry[] queue) { + this.manager = Preconditions.checkNotNull(manager); + this.queue = Preconditions.checkNotNull(queue); + this.baseXid = baseXid; + this.endXid = baseXid + queue.length; + this.reserve = queue.length - 1; + for (OutboundQueueEntry element : queue) { + element.reset(); + } + } + + OutboundQueueImpl reuse(final long baseXid) { + return new OutboundQueueImpl(manager, baseXid, queue); + } + + Long reserveEntry(final boolean forBarrier) { + final int offset = CURRENT_OFFSET_UPDATER.getAndIncrement(this); + if (offset >= reserve) { + if (forBarrier) { + LOG.debug("Queue {} offset {}/{}, using emergency slot", this, offset, queue.length); + return endXid; + } else { + LOG.debug("Queue {} offset {}/{}, not allowing reservation", this, offset, queue.length); + return null; + } + } + + final Long xid = baseXid + offset; + LOG.debug("Queue {} allocated XID {} at offset {}", this, xid, offset); + return xid; + } + + @Override + public Long reserveEntry() { + return reserveEntry(false); + } + + @Override + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + final int offset = (int)(xid - baseXid); + if (message != null) { + Preconditions.checkArgument(xid.equals(message.getXid()), "Message %s has wrong XID %s, expected %s", message, message.getXid(), xid); + } + + queue[offset].commit(message, callback); + LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, reserveOffset); + + manager.ensureFlushing(this); + } + + /** + * An empty queue is a queue which has no further unflushed entries. + * + * @return True if this queue does not have unprocessed entries. + */ + boolean isEmpty() { + int ro = reserveOffset; + if (ro >= reserve) { + if (queue[reserve].isCommitted()) { + ro = reserve + 1; + } else { + ro = reserve; + } + } + + LOG.debug("Effective flush/reserve offset {}/{}", flushOffset, ro); + return ro <= flushOffset; + } + + /** + * A queue is finished when all of its entries have been completed. + * + * @return False if there are any uncompleted requests. + */ + boolean isFinished() { + if (completeCount < reserve) { + return false; + } + + // We need to check if the last entry was used + final OutboundQueueEntry last = queue[reserve]; + return !last.isCommitted() || last.isCompleted(); + } + + boolean isFlushed() { + LOG.debug("Check queue {} for completeness (offset {}, reserve {})", flushOffset, reserve); + if (flushOffset < reserve) { + return false; + } + + // flushOffset implied == reserve + return flushOffset >= queue.length || !queue[reserve].isCommitted(); + } + + OfHeader flushEntry() { + for (;;) { + // No message ready + if (isEmpty()) { + LOG.debug("Flush offset {} is uptodate with reserved", flushOffset); + return null; + } + + boolean retry = true; + while (!queue[flushOffset].isCommitted()) { + if (!retry) { + LOG.debug("Offset {} not ready yet, giving up", flushOffset); + return null; + } + + LOG.debug("Offset {} not ready yet, retrying", flushOffset); + LockSupport.parkNanos(FLUSH_RETRY_NANOS); + retry = false; + } + + final OfHeader msg = queue[flushOffset++].getMessage(); + if (msg != null) { + return msg; + } + } + } + + private boolean xidInRance(final long xid) { + return xid < endXid && (xid >= baseXid || baseXid > endXid); + } + + /** + * Return the request entry corresponding to a response. Returns null + * if there is no request matching the response. + * + * @param response Response message + * @return Matching request entry, or null if no match is found. + */ + OutboundQueueEntry pairRequest(@Nonnull final OfHeader response) { + final Long xid = response.getXid(); + if (!xidInRance(xid)) { + LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, queue.length, xid); + return null; + } + + final int offset = (int)(xid - baseXid); + final OutboundQueueEntry entry = queue[offset]; + if (entry.isCompleted()) { + LOG.debug("Entry {} already is completed, not accepting response {}", entry, response); + return null; + } + + if (entry.complete(response)) { + completeCount++; + + // This has been a barrier -- make sure we complete all preceding requests + if (entry.isBarrier()) { + LOG.debug("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid, xid - 1); + for (int i = 0; i < offset; ++i) { + final OutboundQueueEntry e = queue[i]; + if (!e.isCompleted() && e.complete(null)) { + completeCount++; + } + } + } + } + return entry; + } + + void completeAll() { + for (OutboundQueueEntry entry : queue) { + if (!entry.isCompleted() && entry.complete(null)) { + completeCount++; + } + } + } + + int failAll(final Throwable cause) { + int ret = 0; + for (OutboundQueueEntry entry : queue) { + if (!entry.isCompleted()) { + entry.fail(cause); + ret++; + } + } + + return ret; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java new file mode 100644 index 00000000..b7c2c8f9 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import com.google.common.base.Verify; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import java.net.InetSocketAddress; +import java.util.ArrayDeque; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class OutboundQueueManager extends ChannelInboundHandlerAdapter implements AutoCloseable { + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueManager.class); + + /** + * This is the default upper bound we place on the flush task running + * a single iteration. We relinquish control after about this amount + * of time. + */ + private static final long DEFAULT_WORKTIME_MICROS = TimeUnit.MILLISECONDS.toMicros(100); + + /** + * We re-check the time spent flushing every this many messages. We do this because + * checking after each message may prove to be CPU-intensive. Set to Integer.MAX_VALUE + * or similar to disable the feature. + */ + private static final int WORKTIME_RECHECK_MSGS = 64; + + /** + * We maintain a cache of this many previous queues for later reuse. + */ + private static final int QUEUE_CACHE_SIZE = 4; + + private final Queue queueCache = new ArrayDeque<>(QUEUE_CACHE_SIZE); + private final Queue activeQueues = new LinkedList<>(); + private final ConnectionAdapterImpl parent; + private final InetSocketAddress address; + private final long maxBarrierNanos; + private final long maxWorkTime; + private final int queueSize; + private final T handler; + + /* + * Instead of using an AtomicBoolean object, we use these two. It saves us + * from allocating an extra object. + */ + @SuppressWarnings("rawtypes") + private static final AtomicIntegerFieldUpdater FLUSH_SCHEDULED_UPDATER = + AtomicIntegerFieldUpdater.newUpdater(OutboundQueueManager.class, "flushScheduled"); + private volatile int flushScheduled = 0; + + // Updated from netty only + private long lastBarrierNanos = System.nanoTime(); + private OutboundQueueImpl currentQueue; + private int nonBarrierMessages; + private long lastXid = 0; + + // Passed to executor to request triggering of flush + private final Runnable flushRunnable = new Runnable() { + @Override + public void run() { + flush(); + } + }; + private final Runnable barrierRunnable = new Runnable() { + @Override + public void run() { + barrier(); + } + }; + + OutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler, + final int queueSize, final long maxBarrierNanos) { + this.parent = Preconditions.checkNotNull(parent); + this.handler = Preconditions.checkNotNull(handler); + Preconditions.checkArgument(queueSize > 0); + this.queueSize = queueSize; + Preconditions.checkArgument(maxBarrierNanos > 0); + this.maxBarrierNanos = maxBarrierNanos; + this.address = address; + this.maxWorkTime = TimeUnit.MICROSECONDS.toNanos(DEFAULT_WORKTIME_MICROS); + + LOG.debug("Queue manager instantiated with queue size {}", queueSize); + createQueue(); + scheduleBarrierTimer(lastBarrierNanos); + } + + T getHandler() { + return handler; + } + + @Override + public void close() { + handler.onConnectionQueueChanged(null); + } + + private void retireQueue(final OutboundQueueImpl queue) { + if (queueCache.offer(queue)) { + LOG.debug("Saving queue {} for later reuse", queue); + } else { + LOG.debug("Queue {} thrown away", queue); + } + } + + private void createQueue() { + final long baseXid = lastXid; + lastXid += queueSize + 1; + + final OutboundQueueImpl cached = queueCache.poll(); + final OutboundQueueImpl queue; + if (cached != null) { + queue = cached.reuse(baseXid); + LOG.debug("Reusing queue {} as {} on channel {}", cached, queue, parent.getChannel()); + } else { + queue = new OutboundQueueImpl(this, baseXid, queueSize + 1); + LOG.debug("Allocated new queue {} on channel {}", queue, parent.getChannel()); + } + + activeQueues.add(queue); + currentQueue = queue; + handler.onConnectionQueueChanged(queue); + } + + private void scheduleBarrierTimer(final long now) { + long next = lastBarrierNanos + maxBarrierNanos; + if (next < now) { + LOG.debug("Attempted to schedule barrier in the past, reset maximum)"); + next = now + maxBarrierNanos; + } + + final long delay = next - now; + LOG.debug("Scheduling barrier timer {}us from now", TimeUnit.NANOSECONDS.toMicros(delay)); + parent.getChannel().eventLoop().schedule(barrierRunnable, next - now, TimeUnit.NANOSECONDS); + } + + private void scheduleBarrierMessage() { + final Long xid = currentQueue.reserveEntry(true); + Verify.verifyNotNull(xid); + + currentQueue.commitEntry(xid, handler.createBarrierRequest(xid), null); + LOG.debug("Barrier XID {} scheduled", xid); + + // We can see into the future when compared to flushEntry(), as that + // codepath may be lagging behind on messages. Resetting the counter + // here ensures that flushEntry() will not attempt to issue a flush + // request. Note that we do not reset current time, as that should + // reflect when we sent the message for real. + nonBarrierMessages = 0; + } + + /** + * Flush an entry from the queue. + * + * @param now Time reference for 'now'. We take this as an argument, as + * we need a timestamp to mark barrier messages we see swinging + * by. That timestamp does not need to be completely accurate, + * hence we use the flush start time. Alternative would be to + * measure System.nanoTime() for each barrier -- needlessly + * adding overhead. + * + * @return Entry which was flushed, null if no entry is ready. + */ + OfHeader flushEntry(final long now) { + final OfHeader message = currentQueue.flushEntry(); + if (currentQueue.isFlushed()) { + LOG.debug("Queue {} is fully flushed", currentQueue); + createQueue(); + } + + if (message == null) { + return null; + } + + if (message instanceof BarrierInput) { + LOG.debug("Barrier message seen, resetting counters"); + nonBarrierMessages = 0; + lastBarrierNanos = now; + } else { + nonBarrierMessages++; + if (nonBarrierMessages >= queueSize) { + LOG.debug("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); + scheduleBarrierMessage(); + } + } + + return message; + } + + /** + * Invoked whenever a message comes in from the switch. Runs matching + * on all active queues in an attempt to complete a previous request. + * + * @param message Potential response message + * @return True if the message matched a previous request, false otherwise. + */ + boolean onMessage(final OfHeader message) { + LOG.debug("Attempting to pair message {} to a request", message); + + Iterator it = activeQueues.iterator(); + while (it.hasNext()) { + final OutboundQueueImpl queue = it.next(); + final OutboundQueueEntry entry = queue.pairRequest(message); + + if (entry == null) { + continue; + } + + LOG.debug("Queue {} accepted response {}", queue, message); + + // This has been a barrier request, we need to flush all + // previous queues + if (entry.isBarrier() && activeQueues.size() > 1) { + LOG.debug("Queue {} indicated request was a barrier", queue); + + it = activeQueues.iterator(); + while (it.hasNext()) { + final OutboundQueueImpl q = it.next(); + + // We want to complete all queues before the current one, we will + // complete the current queue below + if (!queue.equals(q)) { + LOG.debug("Queue {} is implied finished", q); + q.completeAll(); + it.remove(); + retireQueue(q); + } else { + break; + } + } + } + + if (queue.isFinished()) { + LOG.debug("Queue {} is finished", queue); + it.remove(); + retireQueue(queue); + } + + return true; + } + + LOG.debug("Failed to find completion for message {}", message); + return false; + } + + private void scheduleFlush() { + if (parent.getChannel().isWritable()) { + if (FLUSH_SCHEDULED_UPDATER.compareAndSet(this, 0, 1)) { + LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); + parent.getChannel().eventLoop().execute(flushRunnable); + } else { + LOG.trace("Flush task is already present on channel {}", parent.getChannel()); + } + } else { + LOG.trace("Channel {} is not writable, not issuing a flush", parent.getChannel()); + } + } + + void ensureFlushing(final OutboundQueueImpl queue) { + Preconditions.checkState(currentQueue.equals(queue)); + scheduleFlush(); + } + + /** + * Periodic barrier check. + */ + protected void barrier() { + LOG.debug("Channel {} barrier timer expired", parent.getChannel()); + if (currentQueue == null) { + LOG.debug("Channel shut down, not processing barrier"); + return; + } + + final long now = System.nanoTime(); + final long sinceLast = now - lastBarrierNanos; + if (sinceLast >= maxBarrierNanos) { + LOG.debug("Last barrier at {} now {}, elapsed {}", lastBarrierNanos, now, sinceLast); + // FIXME: we should be tracking requests/responses instead of this + if (nonBarrierMessages == 0) { + LOG.debug("No messages written since last barrier, not issuing one"); + } else { + scheduleBarrierMessage(); + } + } + + scheduleBarrierTimer(now); + } + + /** + * Perform a single flush operation. + */ + protected void flush() { + final long start = System.nanoTime(); + final long deadline = start + maxWorkTime; + + LOG.debug("Dequeuing messages to channel {}", parent.getChannel()); + + long messages = 0; + for (;; ++messages) { + if (!parent.getChannel().isWritable()) { + LOG.trace("Channel is no longer writable"); + break; + } + + final OfHeader message = flushEntry(start); + if (message == null) { + LOG.trace("The queue is completely drained"); + break; + } + + final Object wrapper; + if (address == null) { + wrapper = new MessageListenerWrapper(message, null); + } else { + wrapper = new UdpMessageListenerWrapper(message, null, address); + } + parent.getChannel().write(wrapper); + + /* + * Check every WORKTIME_RECHECK_MSGS for exceeded time. + * + * XXX: given we already measure our flushing throughput, we + * should be able to perform dynamic adjustments here. + * is that additional complexity needed, though? + */ + if ((messages % WORKTIME_RECHECK_MSGS) == 0 && System.nanoTime() >= deadline) { + LOG.trace("Exceeded allotted work time {}us", + TimeUnit.NANOSECONDS.toMicros(maxWorkTime)); + break; + } + } + + if (messages > 0) { + LOG.debug("Flushing {} message(s) to channel {}", messages, parent.getChannel()); + parent.getChannel().flush(); + } + + final long stop = System.nanoTime(); + LOG.debug("Flushed {} messages in {}us to channel {}", + messages, TimeUnit.NANOSECONDS.toMicros(stop - start), parent.getChannel()); + + /* + * We are almost ready to terminate. This is a bit tricky, because + * we do not want to have a race window where a message would be + * stuck on the queue without a flush being scheduled. + * + * So we mark ourselves as not running and then re-check if a + * flush out is needed. That will re-synchronized with other threads + * such that only one flush is scheduled at any given time. + */ + if (!FLUSH_SCHEDULED_UPDATER.compareAndSet(this, 1, 0)) { + LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); + } + + conditionalFlush(); + } + + + /** + * Schedule a queue flush if it is not empty and the channel is found + * to be writable. May only be called from Netty context. + */ + private void conditionalFlush() { + if (!currentQueue.isEmpty()) { + scheduleFlush(); + } else { + LOG.trace("Queue is empty, no flush needed"); + } + } + + private void conditionalFlush(final ChannelHandlerContext ctx) { + Preconditions.checkState(ctx.channel().equals(parent.getChannel()), "Inconsistent channel %s with context %s", parent.getChannel(), ctx); + conditionalFlush(); + } + + @Override + public void channelActive(final ChannelHandlerContext ctx) throws Exception { + super.channelActive(ctx); + conditionalFlush(ctx); + } + + @Override + public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { + super.channelWritabilityChanged(ctx); + conditionalFlush(ctx); + } + + @Override + public void channelInactive(final ChannelHandlerContext ctx) throws Exception { + super.channelInactive(ctx); + + long entries = 0; + LOG.debug("Channel shutdown, flushing queue..."); + handler.onConnectionQueueChanged(null); + + final Throwable cause = new RejectedExecutionException("Channel disconnected"); + for (OutboundQueueImpl queue : activeQueues) { + entries += queue.failAll(cause); + } + activeQueues.clear(); + + LOG.debug("Flushed {} queue entries", entries); + } + + @Override + public String toString() { + return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled); + } +} From 74523a5ad595c72650e23fc1b708ab43b3025015 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 17:27:38 +0200 Subject: [PATCH 157/285] Do not use string concat Usigng strign concat has performance impact even when the message is not logged. Change-Id: I8d588944028ca984474974f4c042f15ea9029396 Signed-off-by: Robert Varga (cherry picked from commit 8e6748b6570aa25cbfbba6239baf583e77af7cc0) --- .../protocol/impl/core/OFVersionDetector.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 78734fc4..85bb5d55 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -11,9 +11,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; - import java.util.List; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +36,7 @@ public OFVersionDetector() { } @Override - protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) throws Exception { + protected void decode(final ChannelHandlerContext chc, final ByteBuf bb, final List list) throws Exception { if (bb.readableBytes() == 0) { LOGGER.debug("not enough data"); bb.release(); @@ -46,12 +44,12 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) } byte version = bb.readByte(); if ((version == OF13_VERSION_ID) || (version == OF10_VERSION_ID)) { - LOGGER.debug("detected version: " + version); + LOGGER.debug("detected version: {}", version); ByteBuf messageBuffer = bb.slice(); list.add(new VersionMessageWrapper(version, messageBuffer)); messageBuffer.retain(); } else { - LOGGER.warn("detected version: " + version + " - currently not supported"); + LOGGER.warn("detected version: {} - currently not supported", version); } bb.skipBytes(bb.readableBytes()); } From 21d31541ff40f9be4d453b903a533d0c49ce17bc Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 17:26:43 +0200 Subject: [PATCH 158/285] Use an ImmutableMap in DeserializationFactory The contents are not changed once initialized. Take advatage of ImmutableMap's speed. Change-Id: I60d76f85149cf5f757eb224d0a993e7b8d9c3504 Signed-off-by: Robert Varga (cherry picked from commit 32b44f6755e35fbe1ccb429ffc3a03345aff4a1b) --- .../deserialization/DeserializationFactory.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index 09f4fd1d..51e1ff6f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -8,11 +8,10 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; +import com.google.common.collect.ImmutableMap; import io.netty.buffer.ByteBuf; - import java.util.HashMap; import java.util.Map; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; @@ -26,15 +25,16 @@ */ public class DeserializationFactory { + private final Map> messageClassMap; private DeserializerRegistry registry; - private Map> messageClassMap; /** * Constructor */ public DeserializationFactory() { - messageClassMap = new HashMap<>(); - TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); + final Map> temp = new HashMap<>(); + TypeToClassMapInitializer.initializeTypeToClassMap(temp); + messageClassMap = ImmutableMap.copyOf(temp); } /** @@ -43,7 +43,7 @@ public DeserializationFactory() { * @param version version decoded from OpenFlow protocol message * @return correct POJO as DataObject */ - public DataObject deserialize(ByteBuf rawMessage, short version) { + public DataObject deserialize(final ByteBuf rawMessage, final short version) { DataObject dataObject = null; int type = rawMessage.readUnsignedByte(); Class clazz = messageClassMap.get(new TypeToClassKey(version, type)); @@ -57,7 +57,7 @@ public DataObject deserialize(ByteBuf rawMessage, short version) { /** * @param registry */ - public void setRegistry(DeserializerRegistry registry) { + public void setRegistry(final DeserializerRegistry registry) { this.registry = registry; } From 3052e4da5b30c9f8bfe275c591b2fc765253e354 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 14 May 2015 12:04:52 +0200 Subject: [PATCH 159/285] Change Assert import Assert should be imported from org.junit, as that is its new place. Change-Id: I3f3834e529869af8f3165323210b1d4187dcc828 Signed-off-by: Robert Varga (cherry picked from commit 59c03f0f989bff42a888135e48b522a0dd888c4a) --- .../impl/core/connection/ConnectionAdapterImpl02Test.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java index 7da395c4..55c3945d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java @@ -15,9 +15,8 @@ import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; - import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; From f4ac21a3f20b60ef6cbcf322fbd72f225161a2dd Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 17:28:27 +0200 Subject: [PATCH 160/285] Read data directly into a local array Do not instantiate an implied ByteBuf -- just allocate it explicitly and pass it on. Change-Id: Ib76e03dbf154cd7525aa5cd3e75cb9d3c45cd727 Signed-off-by: Robert Varga (cherry picked from commit a706f49c49d16bbb441c8d0a5c85950c28b6c246) --- .../factories/OF10PacketInMessageFactory.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java index 3de0288b..b3819445 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; @@ -25,7 +24,7 @@ public class OF10PacketInMessageFactory implements OFDeserializer 0) { - builder.setData(rawMessage.readBytes(remainingBytes).array()); + final byte[] buf = new byte[remainingBytes]; + rawMessage.readBytes(buf); + builder.setData(buf); } return builder.build(); } From c060d332046d68287d6861d405ea1ddece7421c9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 22:33:45 +0200 Subject: [PATCH 161/285] Fix Logger use Cleanup use of Loggers so we do not concatenate strings, and also check if the logging leve is enabled before embarking on creating large strings. Change-Id: I9f0f513f8cd4857ab7064ed5b824a01b026b831f Signed-off-by: Robert Varga (cherry picked from commit 272138f7081efbd9796a2a661c92c88727935235) --- openflow-protocol-api/pom.xml | 1 - openflow-protocol-impl/pom.xml | 1 - .../impl/core/OFDatagramPacketDecoder.java | 16 ++++---- .../impl/core/OFDatagramPacketHandler.java | 15 ++++--- .../protocol/impl/core/OFDecoder.java | 16 ++++---- .../protocol/impl/core/OFFrameDecoder.java | 9 ++--- .../impl/core/TcpChannelInitializer.java | 8 ++-- .../DeserializerRegistryImpl.java | 5 +-- .../serialization/SerializerRegistryImpl.java | 5 +-- .../AbstractOxmIpv6AddressSerializer.java | 7 +--- .../HelloInputMessageFactoryTest.java | 10 +++-- .../impl/util/ActionsDeserializerTest.java | 2 +- .../it/integration/IntegrationTest.java | 4 +- .../protocol/it/integration/MockPlugin.java | 39 +++++++++---------- .../impl/clients/ScenarioHandler.java | 4 +- .../protocol/impl/clients/SendEvent.java | 7 +++- .../protocol/impl/clients/SimpleClient.java | 5 +-- .../impl/clients/SimpleClientFramer.java | 5 +-- .../impl/clients/SimpleClientHandler.java | 2 +- .../impl/clients/UdpSimpleClient.java | 5 +-- .../impl/clients/UdpSimpleClientFramer.java | 7 ++-- .../impl/clients/WaitForMessageEvent.java | 6 ++- 22 files changed, 87 insertions(+), 92 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index a5b7b4fb..888ed68f 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -65,7 +65,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 prepare-package diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 7ae85449..0a4f2fe8 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -81,7 +81,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.5 diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index 670f552c..3a083eea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -10,7 +10,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; - import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; @@ -28,15 +27,15 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler { private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class); + private final StatisticsCounters statisticsCounter; + + // TODO: make this final? private DeserializationFactory deserializationFactory; - private StatisticsCounters statisticsCounter; + /** * Constructor of class */ public OFDecoder() { LOGGER.trace("Creating OF 1.3 Decoder"); + // TODO: pass as argument statisticsCounter = StatisticsCounters.getInstance(); } @@ -44,12 +48,11 @@ protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA); if (LOGGER.isDebugEnabled()) { LOGGER.debug("VersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); } - DataObject dataObject = null; try { - dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), + final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), msg.getVersion()); if (dataObject == null) { LOGGER.warn("Translated POJO is null"); @@ -58,9 +61,8 @@ protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, out.add(dataObject); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS); } - } catch(Exception e) { - LOGGER.warn("Message deserialization failed"); - LOGGER.warn(e.getMessage(), e); + } catch (Exception e) { + LOGGER.warn("Message deserialization failed", e); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } finally { msg.getMessageBuffer().release(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 5c3b7616..f4ec8825 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -67,8 +67,8 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); - LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); + LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } @@ -78,9 +78,8 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) if (readableBytes < length) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for msg: " + - readableBytes + " < " + length); - LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); + LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); + LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 8282f078..43277eaa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -58,8 +58,8 @@ protected void initChannel(final SocketChannel ch) { InetAddress switchAddress = ch.remoteAddress().getAddress(); int port = ch.localAddress().getPort(); int remotePort = ch.remoteAddress().getPort(); - LOGGER.debug("Incoming connection from (remote address): " + switchAddress.toString() - + ":" + remotePort + " --> :" + port); + LOGGER.debug("Incoming connection from (remote address): {}:{} --> :{}", + switchAddress.toString(), remotePort, port); if (!getSwitchConnectionHandler().accept(switchAddress)) { ch.disconnect(); @@ -72,7 +72,7 @@ protected void initChannel(final SocketChannel ch) { ConnectionFacade connectionFacade = null; connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null); try { - LOGGER.debug("calling plugin: " + getSwitchConnectionHandler()); + LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler()); getSwitchConnectionHandler().onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); @@ -119,4 +119,4 @@ public Iterator getConnectionIterator() { public int size() { return allChannels.size(); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 0ee3fb28..3479bcc0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -75,9 +75,8 @@ public void registerDeserializer(MessageCodeKey key, } OFGeneralDeserializer desInRegistry = registry.put(key, deserializer); if (desInRegistry != null) { - LOGGER.debug("Deserializer for key " + key + " overwritten. Old deserializer: " - + desInRegistry.getClass().getName() + ", new deserializer: " - + deserializer.getClass().getName() ); + LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", + key, desInRegistry.getClass().getName(), deserializer.getClass().getName()); } if (deserializer instanceof DeserializerRegistryInjector) { ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 9a4c2085..5756352c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -81,9 +81,8 @@ public void registerSerializer( } OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer); if (serInRegistry != null) { - LOGGER.debug("Serializer for key " + msgTypeKey + " overwritten. Old serializer: " - + serInRegistry.getClass().getName() + ", new serializer: " - + serializer.getClass().getName() ); + LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", + msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName()); } if (serializer instanceof SerializerRegistryInjector) { ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index b84d81cf..c9646585 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -7,11 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.serialization.match; -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; - import com.google.common.net.InetAddresses; +import io.netty.buffer.ByteBuf; /** * Parent for Ipv6 address based match entry serializers @@ -19,7 +16,7 @@ */ public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { - protected void writeIpv6Address(String textAddress, final ByteBuf outBuffer) { + protected void writeIpv6Address(final String textAddress, final ByteBuf outBuffer) { if (InetAddresses.isInetAddress(textAddress)) { byte[] binaryAddress = InetAddresses.forString(textAddress).getAddress(); outBuffer.writeBytes(binaryAddress); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index c3835324..d947b3fd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -84,7 +84,9 @@ public void testWith4BitVersionBitmap() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); - LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out)); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out)); + } BufferHelper.checkHeaderV13(out, (byte) 0, 16); Elements element = readElement(out).get(0); @@ -108,7 +110,9 @@ public void testWith64BitVersionBitmap() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); - LOGGER.debug("bytebuf: " + ByteBufUtils.byteBufToHexString(out)); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out)); + } BufferHelper.checkHeaderV13(out, (byte) 0, 24); Elements element = readElement(out).get(0); @@ -142,7 +146,7 @@ private static List createComparationElement(int lengthOfBitmap) { booleanList.add(false); } } - LOGGER.debug("boolsize " + booleanList.size()); + LOGGER.debug("boolsize {}", booleanList.size()); elementsBuilder.setType(HelloElementType.forValue(1)); elementsBuilder.setVersionBitmap(booleanList); elementsList.add(elementsBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index 63af2169..76fe9888 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -82,7 +82,7 @@ public void test() { + "00 1B 00 08 00 00 00 00"); message.skipBytes(4); // skip XID - LOGGER.info("bytes: " + message.readableBytes()); + LOGGER.info("bytes: {}", message.readableBytes()); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 3eedff52..54ccb37e 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -69,7 +69,7 @@ public void setUp(TransportProtocol protocol) throws Exception { LOGGER.debug("\n starting test -------------------------------"); String currentDir = System.getProperty("user.dir"); - LOGGER.debug("Current dir using System:" +currentDir); + LOGGER.debug("Current dir using System: {}", currentDir); startupAddress = InetAddress.getLocalHost(); tlsConfiguration = null; if (protocol.equals(TransportProtocol.TLS)) { @@ -221,7 +221,7 @@ private List createAndStartClient(int amountOfCLients, ScenarioHandler TransportProtocol protocol, ClientType clientType) throws ExecutionException { List clientsHorde = new ArrayList<>(); for (int i = 0; i < amountOfCLients; i++) { - LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress()); + LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress()); OFClient sc = null; if (clientType == ClientType.SIMPLE) { if (protocol.equals(TransportProtocol.TCP)) { diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java index f09da22c..dadfa73c 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/MockPlugin.java @@ -61,12 +61,12 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan public MockPlugin() { LOGGER.trace("Creating MockPlugin"); finishedFuture = SettableFuture.create(); - LOGGER.debug("mockPlugin: "+System.identityHashCode(this)); + LOGGER.debug("mockPlugin: {}", System.identityHashCode(this)); } @Override public void onSwitchConnected(ConnectionAdapter connection) { - LOGGER.debug("onSwitchConnected: " + connection); + LOGGER.debug("onSwitchConnected: {}", connection); this.adapter = connection; connection.setMessageListener(this); connection.setSystemListener(this); @@ -75,25 +75,25 @@ public void onSwitchConnected(ConnectionAdapter connection) { @Override public boolean accept(InetAddress switchAddress) { - LOGGER.debug("MockPlugin.accept(): " + switchAddress.toString()); + LOGGER.debug("MockPlugin.accept(): {}", switchAddress.toString()); return true; } @Override public void onEchoRequestMessage(final EchoRequestMessage notification) { - LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: "+adapter); + LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter); new Thread(new Runnable() { @Override public void run() { - LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: "+adapter); + LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter); EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder(); replyBuilder.setVersion((short) 4); replyBuilder.setXid(notification.getXid()); EchoReplyInput echoReplyInput = replyBuilder.build(); adapter.echoReply(echoReplyInput); LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString()); - LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: "+adapter); + LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter); } }).start(); } @@ -151,11 +151,10 @@ protected void getSwitchFeatures() { if (rpcResult.isSuccessful()) { byte[] byteArray = rpcResult.getResult().getDatapathId() .toByteArray(); - LOGGER.debug("DatapathId: " + Arrays.toString(byteArray)); + LOGGER.debug("DatapathId: {}", Arrays.toString(byteArray)); } else { RpcError rpcError = rpcResult.getErrors().iterator().next(); - LOGGER.warn("rpcResult failed: " - + rpcError.getCause().getMessage(), rpcError.getCause()); + LOGGER.warn("rpcResult failed", rpcError.getCause()); } } catch (InterruptedException | ExecutionException | TimeoutException e) { LOGGER.error("getSwitchFeatures() exception caught: ", e.getMessage(), e); @@ -164,7 +163,7 @@ protected void getSwitchFeatures() { protected void shutdown() { try { - LOGGER.debug("MockPlugin.shutdown() sleeping 5... : "+System.identityHashCode(this)); + LOGGER.debug("MockPlugin.shutdown() sleeping 5... : {}", System.identityHashCode(this)); Thread.sleep(500); if (adapter != null) { Future disconnect = adapter.disconnect(); @@ -186,14 +185,14 @@ public void onMultipartReplyMessage(MultipartReplyMessage notification) { @Override public void onPacketInMessage(PacketInMessage notification) { LOGGER.debug("PacketIn message received"); - LOGGER.debug("BufferId: " + notification.getBufferId()); - LOGGER.debug("TotalLength: " + notification.getTotalLen()); - LOGGER.debug("Reason: " + notification.getReason()); - LOGGER.debug("TableId: " + notification.getTableId()); - LOGGER.debug("Cookie: " + notification.getCookie()); - LOGGER.debug("Class: " + notification.getMatch().getMatchEntry().get(0).getOxmClass()); - LOGGER.debug("Field: " + notification.getMatch().getMatchEntry().get(0).getOxmMatchField()); - LOGGER.debug("Datasize: " + notification.getData().length); + LOGGER.debug("BufferId: {}", notification.getBufferId()); + LOGGER.debug("TotalLength: {}", notification.getTotalLen()); + LOGGER.debug("Reason: {}", notification.getReason()); + LOGGER.debug("TableId: {}", notification.getTableId()); + LOGGER.debug("Cookie: {}", notification.getCookie()); + LOGGER.debug("Class: {}", notification.getMatch().getMatchEntry().get(0).getOxmClass()); + LOGGER.debug("Field: {}", notification.getMatch().getMatchEntry().get(0).getOxmMatchField()); + LOGGER.debug("Datasize: {}", notification.getData().length); } @Override @@ -204,7 +203,7 @@ public void onPortStatusMessage(PortStatusMessage notification) { @Override public void onDisconnectEvent(DisconnectEvent notification) { - LOGGER.debug("disconnection occured: "+notification.getInfo()); + LOGGER.debug("disconnection occured: {}", notification.getInfo()); } /** @@ -216,7 +215,7 @@ public SettableFuture getFinishedFuture() { @Override public void onSwitchIdleEvent(SwitchIdleEvent notification) { - LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: "+notification.getInfo()); + LOGGER.debug("MockPlugin.onSwitchIdleEvent() switch status: {}", notification.getInfo()); idleCounter ++; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index b7cf3de0..57865d88 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -45,7 +45,7 @@ public ScenarioHandler(Deque scenario) { public void run() { int freezeCounter = 0; while (!scenario.isEmpty()) { - LOGGER.debug("Running event #" + eventNumber); + LOGGER.debug("Running event #{}", eventNumber); ClientEvent peek = scenario.peekLast(); if (peek instanceof WaitForMessageEvent) { LOGGER.debug("WaitForMessageEvent"); @@ -69,7 +69,7 @@ public void run() { freezeCounter++; } if (freezeCounter > 2) { - LOGGER.warn("Scenario freezed: " + freezeCounter); + LOGGER.warn("Scenario frozen: {}", freezeCounter); break; } try { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index c5765272..3f456d12 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -43,8 +43,11 @@ public boolean eventExecuted() { ByteBuf buffer = ctx.alloc().buffer(); buffer.writeBytes(msgToSend); ctx.writeAndFlush(buffer); - LOGGER.debug(">> " + ByteBufUtils.bytesToHexString(msgToSend)); - LOGGER.debug("message sent"); + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend)); + LOGGER.debug("message sent"); + } return true; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index b097b1d1..5e98e3d6 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -115,8 +115,7 @@ public static void main(String[] args) throws Exception { int port; SimpleClient sc; if (args.length != 3) { - LOGGER.error("Usage: " + SimpleClient.class.getSimpleName() - + " "); + LOGGER.error("Usage: {} ", SimpleClient.class.getSimpleName()); LOGGER.error("Trying to use default setting."); InetAddress ia = InetAddress.getLocalHost(); InetAddress[] all = InetAddress.getAllByName(ia.getHostName()); @@ -147,4 +146,4 @@ public SettableFuture getScenarioDone() { public void setScenarioHandler(ScenarioHandler scenario) { this.scenarioHandler = scenario; } -} \ No newline at end of file +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java index a1ade557..1420ad8d 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java @@ -46,14 +46,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E @Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) throws Exception { if (bb.readableBytes() < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes()); + LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes()); return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { - LOGGER.debug("skipping bb - too few data for msg: " + - bb.readableBytes() + " < " + length); + LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java index 01e114bf..acc53834 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java @@ -43,7 +43,7 @@ public SimpleClientHandler(SettableFuture isOnlineFuture, ScenarioHandl public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf bb = (ByteBuf) msg; if (LOGGER.isDebugEnabled()) { - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(bb)); + LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(bb)); } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); LOGGER.trace("SimpleClientHandler - start of read"); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java index e9d69da1..e9d4644e 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -111,8 +111,7 @@ public static void main(String[] args) throws Exception { int port; UdpSimpleClient sc; if (args.length != 2) { - LOGGER.error("Usage: " + UdpSimpleClient.class.getSimpleName() - + " "); + LOGGER.error("Usage: {} ", UdpSimpleClient.class.getSimpleName()); LOGGER.error("Trying to use default setting."); InetAddress ia = InetAddress.getLocalHost(); InetAddress[] all = InetAddress.getAllByName(ia.getHostName()); @@ -147,4 +146,4 @@ public void setScenarioHandler(ScenarioHandler scenario) { public void setSecuredClient(boolean securedClient) { // TODO: Finish implementation when DTLS is supported } -} \ No newline at end of file +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java index d5f8e7be..be73d27c 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java @@ -48,14 +48,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E protected void decode(ChannelHandlerContext chc, DatagramPacket msg, List list) throws Exception { ByteBuf bb = msg.content(); if (bb.readableBytes() < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bb - too few data for header: " + bb.readableBytes()); + LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes()); return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { - LOGGER.debug("skipping bb - too few data for msg: " + - bb.readableBytes() + " < " + length); + LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); return; } LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); @@ -65,4 +64,4 @@ protected void decode(ChannelHandlerContext chc, DatagramPacket msg, List Date: Sat, 16 May 2015 01:34:26 +0200 Subject: [PATCH 162/285] Migrate away from deprecated methods Objects is going away, as is Rpcs. Change-Id: If4bff97d0f3ec20d7e5a6ed1695bc6ab38213caa Signed-off-by: Robert Varga (cherry picked from commit 96ae2f8565bcf8bbe20eac0370fcc0a20258c5fd) --- .../core/connection/AbstractRpcListener.java | 15 +++------ .../SwitchConnectionProviderModule.java | 32 +++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java index 79708f65..115f9205 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java @@ -7,24 +7,22 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; - import java.util.Collections; - import org.opendaylight.controller.sal.common.util.RpcErrors; import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - /** * This class holds all the context we need for sending a single message down the tube. * A MessageHolder (used in queue) and the actual listener. It is not a thing of beauty, @@ -98,9 +96,6 @@ protected final void failedRpc(final Throwable cause) { } protected final void successfulRpc(final T value) { - result.set(Rpcs.getRpcResult( - true, - value, - Collections.emptyList())); + result.set(RpcResultBuilder.success(value).build()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 68edb2a3..9cbd9c96 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -9,9 +9,9 @@ */ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328; +import com.google.common.base.MoreObjects; import java.net.InetAddress; import java.net.UnknownHostException; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; @@ -22,8 +22,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Objects; - /** * */ @@ -37,7 +35,7 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang. * @param identifier * @param dependencyResolver */ - public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public SwitchConnectionProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } @@ -47,8 +45,8 @@ public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.Mod * @param oldModule * @param oldInstance */ - public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - SwitchConnectionProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + public SwitchConnectionProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final SwitchConnectionProviderModule oldModule, final java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @@ -103,39 +101,39 @@ public TlsConfiguration getTlsConfiguration() { return new TlsConfiguration() { @Override public KeystoreType getTlsTruststoreType() { - return Objects.firstNonNull(tlsConfig.getTruststoreType(), null); + return MoreObjects.firstNonNull(tlsConfig.getTruststoreType(), null); } @Override public String getTlsTruststore() { - return Objects.firstNonNull(tlsConfig.getTruststore(), null); + return MoreObjects.firstNonNull(tlsConfig.getTruststore(), null); } @Override public KeystoreType getTlsKeystoreType() { - return Objects.firstNonNull(tlsConfig.getKeystoreType(), null); + return MoreObjects.firstNonNull(tlsConfig.getKeystoreType(), null); } @Override public String getTlsKeystore() { - return Objects.firstNonNull(tlsConfig.getKeystore(), null); + return MoreObjects.firstNonNull(tlsConfig.getKeystore(), null); } @Override public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() { - return Objects.firstNonNull(tlsConfig.getKeystorePathType(), null); + return MoreObjects.firstNonNull(tlsConfig.getKeystorePathType(), null); } @Override public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() { - return Objects.firstNonNull(tlsConfig.getTruststorePathType(), null); + return MoreObjects.firstNonNull(tlsConfig.getTruststorePathType(), null); } @Override public String getKeystorePassword() { - return Objects.firstNonNull(tlsConfig.getKeystorePassword(), null); + return MoreObjects.firstNonNull(tlsConfig.getKeystorePassword(), null); } @Override public String getCertificatePassword() { - return Objects.firstNonNull(tlsConfig.getCertificatePassword(), null); + return MoreObjects.firstNonNull(tlsConfig.getCertificatePassword(), null); } @Override public String getTruststorePassword() { - return Objects.firstNonNull(tlsConfig.getTruststorePassword(), null); + return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null); } }; } @@ -174,7 +172,7 @@ public int getBossThreadCount() { * @return * @throws UnknownHostException */ - private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException { + private static InetAddress extractIpAddressBin(final IpAddress address) throws UnknownHostException { byte[] addressBin = null; if (address != null) { if (address.getIpv4Address() != null) { @@ -195,7 +193,7 @@ private static InetAddress extractIpAddressBin(IpAddress address) throws Unknown * @param value * @return */ - private static byte[] address2bin(String value) { + private static byte[] address2bin(final String value) { //TODO: translate ipv4 or ipv6 into byte[] return null; } From e55a242f3c5e384a8c2e2c25dfc26ec2d8dae9d5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 14:24:11 +0200 Subject: [PATCH 163/285] Log the incoming channel For debugging purposes it is useful to understand which channel is being processed by a particular thread, especially when it is blasting packets. Change-Id: I4a12ed5350026d554937e818d824f7d63acff5f6 Signed-off-by: Robert Varga (cherry picked from commit 2a2781e63b1d36d1b293519e0bca7d2b292a5584) --- .../protocol/impl/core/connection/ConnectionAdapterImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 20e4c2a8..7dca1965 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -265,7 +265,7 @@ public void setMessageListener(final OpenflowProtocolListener messageListener) { @Override public void consume(final DataObject message) { - LOG.debug("ConsumeIntern msg"); + LOG.debug("ConsumeIntern msg on {}", channel); if (disconnectOccured ) { return; } From 1f50196a10fcf578451417d76629b94d71d33873 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 01:38:12 +0200 Subject: [PATCH 164/285] Enable periodic barrier only when needed Instead of rescheduling the timer, track precisely when we need to have it enabled. This will ensure that idle channels are really idle. Change-Id: I34f7b2fdc5a7abb9d3c2c612adb307bdf097cf10 Signed-off-by: Robert Varga (cherry picked from commit 096d3de0bc39bef5bb0493e721d794e850a5b49d) --- .../core/connection/OutboundQueueImpl.java | 62 ++++++++++++++----- .../core/connection/OutboundQueueManager.java | 41 +++++------- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 1bb9ec4b..2d94b679 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -21,6 +21,8 @@ final class OutboundQueueImpl implements OutboundQueue { private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueImpl.class); private static final AtomicIntegerFieldUpdater CURRENT_OFFSET_UPDATER = AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "reserveOffset"); + private static final AtomicIntegerFieldUpdater BARRIER_OFFSET_UPDATER = + AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "barrierOffset"); private static final long FLUSH_RETRY_NANOS = 1L; private final OutboundQueueManager manager; private final OutboundQueueEntry[] queue; @@ -29,7 +31,8 @@ final class OutboundQueueImpl implements OutboundQueue { private final int reserve; // Updated concurrently - private volatile int reserveOffset; + private volatile int barrierOffset = -1; + private volatile int reserveOffset = 0; // Updated from Netty only private int flushOffset; @@ -69,7 +72,40 @@ OutboundQueueImpl reuse(final long baseXid) { return new OutboundQueueImpl(manager, baseXid, queue); } - Long reserveEntry(final boolean forBarrier) { + @Override + public Long reserveEntry() { + return reserveEntry(false); + } + + @Override + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + final int offset = (int)(xid - baseXid); + if (message != null) { + Preconditions.checkArgument(xid.equals(message.getXid()), "Message %s has wrong XID %s, expected %s", message, message.getXid(), xid); + } + + final OutboundQueueEntry entry = queue[offset]; + entry.commit(message, callback); + LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, reserveOffset); + + if (entry.isBarrier()) { + int my = offset; + for (;;) { + final int prev = BARRIER_OFFSET_UPDATER.getAndSet(this, my); + if (prev < my) { + LOG.debug("Queue {} recorded pending barrier offset {}", this, my); + break; + } + + // We have traveled back, recover + my = prev; + } + } + + manager.ensureFlushing(this); + } + + private Long reserveEntry(final boolean forBarrier) { final int offset = CURRENT_OFFSET_UPDATER.getAndIncrement(this); if (offset >= reserve) { if (forBarrier) { @@ -86,22 +122,14 @@ Long reserveEntry(final boolean forBarrier) { return xid; } - @Override - public Long reserveEntry() { - return reserveEntry(false); - } - - @Override - public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { - final int offset = (int)(xid - baseXid); - if (message != null) { - Preconditions.checkArgument(xid.equals(message.getXid()), "Message %s has wrong XID %s, expected %s", message, message.getXid(), xid); + Long reserveBarrierIfNeeded() { + final int bo = barrierOffset; + if (bo >= flushOffset) { + LOG.debug("Barrier found at offset {} (currently at {})", bo, flushOffset); + return null; + } else { + return reserveEntry(true); } - - queue[offset].commit(message, callback); - LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, reserveOffset); - - manager.ensureFlushing(this); } /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index b7c2c8f9..43cbf027 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import java.net.InetSocketAddress; @@ -18,7 +17,7 @@ import java.util.Queue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicBoolean; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; @@ -49,6 +48,7 @@ final class OutboundQueueManager extends Channel private final Queue queueCache = new ArrayDeque<>(QUEUE_CACHE_SIZE); private final Queue activeQueues = new LinkedList<>(); + private final AtomicBoolean flushScheduled = new AtomicBoolean(); private final ConnectionAdapterImpl parent; private final InetSocketAddress address; private final long maxBarrierNanos; @@ -56,18 +56,10 @@ final class OutboundQueueManager extends Channel private final int queueSize; private final T handler; - /* - * Instead of using an AtomicBoolean object, we use these two. It saves us - * from allocating an extra object. - */ - @SuppressWarnings("rawtypes") - private static final AtomicIntegerFieldUpdater FLUSH_SCHEDULED_UPDATER = - AtomicIntegerFieldUpdater.newUpdater(OutboundQueueManager.class, "flushScheduled"); - private volatile int flushScheduled = 0; - // Updated from netty only private long lastBarrierNanos = System.nanoTime(); private OutboundQueueImpl currentQueue; + private boolean barrierTimerEnabled; private int nonBarrierMessages; private long lastXid = 0; @@ -98,7 +90,6 @@ public void run() { LOG.debug("Queue manager instantiated with queue size {}", queueSize); createQueue(); - scheduleBarrierTimer(lastBarrierNanos); } T getHandler() { @@ -147,21 +138,18 @@ private void scheduleBarrierTimer(final long now) { final long delay = next - now; LOG.debug("Scheduling barrier timer {}us from now", TimeUnit.NANOSECONDS.toMicros(delay)); parent.getChannel().eventLoop().schedule(barrierRunnable, next - now, TimeUnit.NANOSECONDS); + barrierTimerEnabled = true; } private void scheduleBarrierMessage() { - final Long xid = currentQueue.reserveEntry(true); - Verify.verifyNotNull(xid); + final Long xid = currentQueue.reserveBarrierIfNeeded(); + if (xid == null) { + LOG.debug("Queue {} already contains a barrier, not scheduling one", currentQueue); + return; + } currentQueue.commitEntry(xid, handler.createBarrierRequest(xid), null); LOG.debug("Barrier XID {} scheduled", xid); - - // We can see into the future when compared to flushEntry(), as that - // codepath may be lagging behind on messages. Resetting the counter - // here ensures that flushEntry() will not attempt to issue a flush - // request. Note that we do not reset current time, as that should - // reflect when we sent the message for real. - nonBarrierMessages = 0; } /** @@ -196,6 +184,8 @@ OfHeader flushEntry(final long now) { if (nonBarrierMessages >= queueSize) { LOG.debug("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); scheduleBarrierMessage(); + } else if (!barrierTimerEnabled) { + scheduleBarrierTimer(now); } } @@ -260,7 +250,7 @@ boolean onMessage(final OfHeader message) { private void scheduleFlush() { if (parent.getChannel().isWritable()) { - if (FLUSH_SCHEDULED_UPDATER.compareAndSet(this, 0, 1)) { + if (flushScheduled.compareAndSet(false, true)) { LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); parent.getChannel().eventLoop().execute(flushRunnable); } else { @@ -281,6 +271,7 @@ void ensureFlushing(final OutboundQueueImpl queue) { */ protected void barrier() { LOG.debug("Channel {} barrier timer expired", parent.getChannel()); + barrierTimerEnabled = false; if (currentQueue == null) { LOG.debug("Channel shut down, not processing barrier"); return; @@ -297,8 +288,6 @@ protected void barrier() { scheduleBarrierMessage(); } } - - scheduleBarrierTimer(now); } /** @@ -363,7 +352,7 @@ protected void flush() { * flush out is needed. That will re-synchronized with other threads * such that only one flush is scheduled at any given time. */ - if (!FLUSH_SCHEDULED_UPDATER.compareAndSet(this, 1, 0)) { + if (!flushScheduled.compareAndSet(true, false)) { LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); } @@ -419,6 +408,6 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { @Override public String toString() { - return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled); + return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get()); } } From f1f556a90176490a6044dbd76b0d14b9d81520c1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 02:21:19 +0200 Subject: [PATCH 165/285] Optimize barrier-implied flushes Original code did a full queue scan up to the current request. This is inefficient if there are previously-completed barriers, as we end up checking the same slots multiple times. Remember the offset of last completed future and only flush slots from that offset on subsequent barrier completion. Change-Id: I9715f9f7818de611c01d0cd2eaa7637ac5372e91 Signed-off-by: Robert Varga (cherry picked from commit 7da0dcda4b5d9e5c4510ceb8e4d7840696fbdd90) --- .../core/connection/OutboundQueueImpl.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 2d94b679..5d22435d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -37,6 +37,7 @@ final class OutboundQueueImpl implements OutboundQueue { // Updated from Netty only private int flushOffset; private int completeCount; + private int lastBarrierOffset = -1; OutboundQueueImpl(final OutboundQueueManager manager, final long baseXid, final int maxQueue) { /* @@ -233,29 +234,31 @@ OutboundQueueEntry pairRequest(@Nonnull final OfHeader response) { // This has been a barrier -- make sure we complete all preceding requests if (entry.isBarrier()) { - LOG.debug("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid, xid - 1); - for (int i = 0; i < offset; ++i) { - final OutboundQueueEntry e = queue[i]; - if (!e.isCompleted() && e.complete(null)) { - completeCount++; - } - } + LOG.debug("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1); + completeRequests(offset); + lastBarrierOffset = offset; } } return entry; } - void completeAll() { - for (OutboundQueueEntry entry : queue) { + private void completeRequests(final int toOffset) { + for (int i = lastBarrierOffset + 1; i < toOffset; ++i) { + final OutboundQueueEntry entry = queue[i]; if (!entry.isCompleted() && entry.complete(null)) { completeCount++; } } } + void completeAll() { + completeRequests(queue.length); + } + int failAll(final Throwable cause) { int ret = 0; - for (OutboundQueueEntry entry : queue) { + for (int i = lastBarrierOffset + 1; i < queue.length; ++i) { + final OutboundQueueEntry entry = queue[i]; if (!entry.isCompleted()) { entry.fail(cause); ret++; From a1a7f8837508bd5da6a2b4df7faf34ef3db0c913 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 19:21:25 +0200 Subject: [PATCH 166/285] Make sure we route error messages back Error messages need to be routed/paired with requests, too. Change-Id: I265343f2e44d07ce8182fe9d399d594ee549d0fe Signed-off-by: Robert Varga (cherry picked from commit cd8f3f3c6bd1013558f0fdef84ce95cf711b016f) --- .../protocol/impl/core/connection/ConnectionAdapterImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 7dca1965..6d9013ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -284,6 +284,9 @@ public void consume(final DataObject message) { statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ErrorMessage) { messageListener.onErrorMessage((ErrorMessage) message); + if (outputManager != null) { + outputManager.onMessage((OfHeader) message); + } statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ExperimenterMessage) { messageListener.onExperimenterMessage((ExperimenterMessage) message); From 25c14e3534f74fe2c5b2ab854f9d938ed6435594 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 17:25:44 +0200 Subject: [PATCH 167/285] Cleanup queue logging Move messages to trace so debug level does not produce a lot of logs. Change-Id: Id1b361dee3e3b934010e494541b93baf874a48bc Signed-off-by: Robert Varga (cherry picked from commit adbe84ccdff26bc2e58a42a63a023ea8fadff7a9) --- .../core/connection/OutboundQueueManager.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 43cbf027..4864b95d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -103,9 +103,9 @@ public void close() { private void retireQueue(final OutboundQueueImpl queue) { if (queueCache.offer(queue)) { - LOG.debug("Saving queue {} for later reuse", queue); + LOG.trace("Saving queue {} for later reuse", queue); } else { - LOG.debug("Queue {} thrown away", queue); + LOG.trace("Queue {} thrown away", queue); } } @@ -117,10 +117,10 @@ private void createQueue() { final OutboundQueueImpl queue; if (cached != null) { queue = cached.reuse(baseXid); - LOG.debug("Reusing queue {} as {} on channel {}", cached, queue, parent.getChannel()); + LOG.trace("Reusing queue {} as {} on channel {}", cached, queue, parent.getChannel()); } else { queue = new OutboundQueueImpl(this, baseXid, queueSize + 1); - LOG.debug("Allocated new queue {} on channel {}", queue, parent.getChannel()); + LOG.trace("Allocated new queue {} on channel {}", queue, parent.getChannel()); } activeQueues.add(queue); @@ -131,12 +131,12 @@ private void createQueue() { private void scheduleBarrierTimer(final long now) { long next = lastBarrierNanos + maxBarrierNanos; if (next < now) { - LOG.debug("Attempted to schedule barrier in the past, reset maximum)"); + LOG.trace("Attempted to schedule barrier in the past, reset maximum)"); next = now + maxBarrierNanos; } final long delay = next - now; - LOG.debug("Scheduling barrier timer {}us from now", TimeUnit.NANOSECONDS.toMicros(delay)); + LOG.trace("Scheduling barrier timer {}us from now", TimeUnit.NANOSECONDS.toMicros(delay)); parent.getChannel().eventLoop().schedule(barrierRunnable, next - now, TimeUnit.NANOSECONDS); barrierTimerEnabled = true; } @@ -144,12 +144,12 @@ private void scheduleBarrierTimer(final long now) { private void scheduleBarrierMessage() { final Long xid = currentQueue.reserveBarrierIfNeeded(); if (xid == null) { - LOG.debug("Queue {} already contains a barrier, not scheduling one", currentQueue); + LOG.trace("Queue {} already contains a barrier, not scheduling one", currentQueue); return; } currentQueue.commitEntry(xid, handler.createBarrierRequest(xid), null); - LOG.debug("Barrier XID {} scheduled", xid); + LOG.trace("Barrier XID {} scheduled", xid); } /** @@ -176,13 +176,13 @@ OfHeader flushEntry(final long now) { } if (message instanceof BarrierInput) { - LOG.debug("Barrier message seen, resetting counters"); + LOG.trace("Barrier message seen, resetting counters"); nonBarrierMessages = 0; lastBarrierNanos = now; } else { nonBarrierMessages++; if (nonBarrierMessages >= queueSize) { - LOG.debug("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); + LOG.trace("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); scheduleBarrierMessage(); } else if (!barrierTimerEnabled) { scheduleBarrierTimer(now); @@ -200,7 +200,7 @@ OfHeader flushEntry(final long now) { * @return True if the message matched a previous request, false otherwise. */ boolean onMessage(final OfHeader message) { - LOG.debug("Attempting to pair message {} to a request", message); + LOG.trace("Attempting to pair message {} to a request", message); Iterator it = activeQueues.iterator(); while (it.hasNext()) { @@ -211,12 +211,12 @@ boolean onMessage(final OfHeader message) { continue; } - LOG.debug("Queue {} accepted response {}", queue, message); + LOG.trace("Queue {} accepted response {}", queue, message); // This has been a barrier request, we need to flush all // previous queues if (entry.isBarrier() && activeQueues.size() > 1) { - LOG.debug("Queue {} indicated request was a barrier", queue); + LOG.trace("Queue {} indicated request was a barrier", queue); it = activeQueues.iterator(); while (it.hasNext()) { @@ -225,7 +225,7 @@ boolean onMessage(final OfHeader message) { // We want to complete all queues before the current one, we will // complete the current queue below if (!queue.equals(q)) { - LOG.debug("Queue {} is implied finished", q); + LOG.trace("Queue {} is implied finished", q); q.completeAll(); it.remove(); retireQueue(q); @@ -236,7 +236,7 @@ boolean onMessage(final OfHeader message) { } if (queue.isFinished()) { - LOG.debug("Queue {} is finished", queue); + LOG.trace("Queue {} is finished", queue); it.remove(); retireQueue(queue); } @@ -273,7 +273,7 @@ protected void barrier() { LOG.debug("Channel {} barrier timer expired", parent.getChannel()); barrierTimerEnabled = false; if (currentQueue == null) { - LOG.debug("Channel shut down, not processing barrier"); + LOG.trace("Channel shut down, not processing barrier"); return; } @@ -283,7 +283,7 @@ protected void barrier() { LOG.debug("Last barrier at {} now {}, elapsed {}", lastBarrierNanos, now, sinceLast); // FIXME: we should be tracking requests/responses instead of this if (nonBarrierMessages == 0) { - LOG.debug("No messages written since last barrier, not issuing one"); + LOG.trace("No messages written since last barrier, not issuing one"); } else { scheduleBarrierMessage(); } From a791a47b220782b60d25b5b32bc655ca583ff4f6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 17 May 2015 02:48:42 +0200 Subject: [PATCH 168/285] BUG-3219: do to park thread in flush If we encounter an entry which has been reserved but not committed during flush operation, do not wait for it to get committed, but bail immediately. Change-Id: I04a3ca1de4447bba9b513d85601c83fd31d115a9 Signed-off-by: Robert Varga (cherry picked from commit eea277b72dc9337bb06bb6f2ff470830cc98e74c) --- .../core/connection/OutboundQueueImpl.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 5d22435d..f133082f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -10,7 +10,6 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import java.util.concurrent.locks.LockSupport; import javax.annotation.Nonnull; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; @@ -23,7 +22,6 @@ final class OutboundQueueImpl implements OutboundQueue { AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "reserveOffset"); private static final AtomicIntegerFieldUpdater BARRIER_OFFSET_UPDATER = AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "barrierOffset"); - private static final long FLUSH_RETRY_NANOS = 1L; private final OutboundQueueManager manager; private final OutboundQueueEntry[] queue; private final long baseXid; @@ -181,26 +179,23 @@ OfHeader flushEntry() { for (;;) { // No message ready if (isEmpty()) { - LOG.debug("Flush offset {} is uptodate with reserved", flushOffset); + LOG.trace("Flushed all reserved entries up to ", flushOffset); return null; } - boolean retry = true; - while (!queue[flushOffset].isCommitted()) { - if (!retry) { - LOG.debug("Offset {} not ready yet, giving up", flushOffset); - return null; - } - - LOG.debug("Offset {} not ready yet, retrying", flushOffset); - LockSupport.parkNanos(FLUSH_RETRY_NANOS); - retry = false; + final OutboundQueueEntry entry = queue[flushOffset]; + if (!entry.isCommitted()) { + LOG.trace("Request at offset {} not ready yet, giving up", flushOffset); + return null; } - final OfHeader msg = queue[flushOffset++].getMessage(); + final OfHeader msg = entry.getMessage(); + flushOffset++; if (msg != null) { return msg; } + + LOG.trace("Null message, skipping to offset {}", flushOffset); } } From fb9acb169ef0a012490d8c6e122a24517e8624d3 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 16 May 2015 18:59:50 +0200 Subject: [PATCH 169/285] Migrate to RpcResultBuilder Removes the use of Rpcs and RpcErrors in favor of RpcResultBuilder. Change-Id: I9bd5f710321ab70098e79bbab463c7b5447ffa17 Signed-off-by: Robert Varga (cherry picked from commit 8e5473613cc8f6b0d9558edd170b93e238b87d57) --- .../core/connection/AbstractRpcListener.java | 19 +++---------- .../ResponseExpectedRpcListenerTest.java | 28 +++++++------------ .../connection/SimpleRpcListenerTest.java | 12 ++------ .../impl/util/TypeKeyMakerFactoryTest.java | 4 +-- 4 files changed, 19 insertions(+), 44 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java index 115f9205..7579cbd6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java @@ -12,11 +12,7 @@ import com.google.common.util.concurrent.SettableFuture; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.GenericFutureListener; -import java.util.Collections; -import org.opendaylight.controller.sal.common.util.RpcErrors; -import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -44,11 +40,8 @@ abstract class AbstractRpcListener implements GenericFutureListener> takeListener() { protected abstract void operationSuccessful(); protected final void failedRpc(final Throwable cause) { - final RpcError rpcError = buildRpcError( - failureInfo, ErrorSeverity.ERROR, "check switch connection", cause); - result.set(Rpcs.getRpcResult( - false, - (T)null, - Collections.singletonList(rpcError))); + final RpcError rpcError = buildRpcError(failureInfo, "check switch connection", cause); + result.set(RpcResultBuilder.failed().withRpcError(rpcError).build()); } protected final void successfulRpc(final T value) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java index ec57cb8f..e6d1fff2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java @@ -9,31 +9,23 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.junit.Assert.fail; - -import java.util.Collections; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.SettableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.junit.Assert; import org.junit.Test; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.util.concurrent.SettableFuture; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; /** * @author michal.polkorab @@ -50,7 +42,7 @@ public void onRemoval( } }; private static final int RPC_RESPONSE_EXPIRATION = 1; - private Cache> responseCache = CacheBuilder.newBuilder() + private final Cache> responseCache = CacheBuilder.newBuilder() .concurrencyLevel(1) .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); @@ -82,9 +74,9 @@ public void testDiscard() { new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); listener.discard(); RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", - ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); + "check switch connection", new TimeoutException("Request timed out")); SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); + result.set(RpcResultBuilder.failed().withRpcError(rpcError).build()); try { Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), listener.getResult().get().getErrors().iterator().next().getMessage()); @@ -107,7 +99,7 @@ public void testCompleted() { BarrierInput barrierInput = barrierBuilder.build(); listener.completed(barrierInput); SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); + result.set(RpcResultBuilder.success(barrierInput).build()); try { Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java index fff2ea02..77260005 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java @@ -12,22 +12,16 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import com.google.common.util.concurrent.SettableFuture; import io.netty.util.concurrent.Future; - -import java.util.Collections; import java.util.concurrent.ExecutionException; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; -import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.util.concurrent.SettableFuture; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; /** * @author michal.polkorab @@ -63,7 +57,7 @@ public void testSuccessfulRpc() { SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); listener.operationSuccessful(); SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); + result.set(RpcResultBuilder.success((Void)null).build()); try { Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index 0cfb0940..c95541c9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -77,7 +77,7 @@ public void testExperimenterActionKeyMaker() { MessageTypeKey key = keyMaker.make(action); Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, + Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlInCase.class, 42L), key); } @@ -114,7 +114,7 @@ public void testExperimenterInstructionKeyMaker() { MessageTypeKey key = keyMaker.make(instruction); Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new InstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, + Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ClearActionsCase.class, 42L), key); } From ab55df73c5fc08aa365af5ed9c1b0b0395b9211e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 17 May 2015 00:34:50 +0200 Subject: [PATCH 170/285] BUG-3219: Fix OutboundQueue request error reporting Original patch failed to describe how errors are reported when they arrive in an ErrorMessage or are generated by the local system. The only error path interface is the onFailure() method in the callback the user specifies. This fits naturally, as we now define DeviceRequestFailedException to carry the encapsulated message and pass it to the callback. Change-Id: Ie8eb62558991ceb7f6d5eb8d7cd547aecaf63f19 Signed-off-by: Robert Varga (cherry picked from commit ccb7e5bda0598185f98d52ddd16e49ae4d48e5aa) --- .../DeviceRequestFailedException.java | 35 ++++++++++++++++ .../api/connection/OutboundQueue.java | 3 ++ .../connection/ConnectionAdapterImpl.java | 10 ++--- .../core/connection/OutboundQueueImpl.java | 42 ++++++++++++++----- 4 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java new file mode 100644 index 00000000..a353886d --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +import com.google.common.base.Preconditions; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; + +/** + * Exception which is used to report that a particular request failed on the + * remote device (switch). + */ +public class DeviceRequestFailedException extends Exception { + private static final long serialVersionUID = 1L; + private final Error error; + + public DeviceRequestFailedException(final String message, @Nonnull final Error error) { + super(message); + this.error = Preconditions.checkNotNull(error); + } + + public DeviceRequestFailedException(final String message, @Nonnull final Error error, final Throwable cause) { + super(message, cause); + this.error = Preconditions.checkNotNull(error); + } + + @Nonnull public Error getError() { + return error; + } +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java index 1291c22c..06b66c5e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java @@ -30,6 +30,9 @@ public interface OutboundQueue { * with a response, the object reported will be non-null. If the request's completion * is implied by a barrier, the object reported will be null. * + * If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable) + * will be called with an instance of {@link DeviceRequestFailedException}. + * * @param xid Previously-reserved XID * @param message Message which should be sent out, or null if the reservation * should be cancelled. diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 6d9013ec..91f4ceb1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -283,16 +283,16 @@ public void consume(final DataObject message) { messageListener.onEchoRequestMessage((EchoRequestMessage) message); statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ErrorMessage) { - messageListener.onErrorMessage((ErrorMessage) message); - if (outputManager != null) { - outputManager.onMessage((OfHeader) message); + // Send only unmatched errors + if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { + messageListener.onErrorMessage((ErrorMessage) message); } statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ExperimenterMessage) { - messageListener.onExperimenterMessage((ExperimenterMessage) message); if (outputManager != null) { outputManager.onMessage((OfHeader) message); } + messageListener.onExperimenterMessage((ExperimenterMessage) message); statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof FlowRemovedMessage) { messageListener.onFlowRemovedMessage((FlowRemovedMessage) message); @@ -302,10 +302,10 @@ public void consume(final DataObject message) { messageListener.onHelloMessage((HelloMessage) message); statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof MultipartReplyMessage) { - messageListener.onMultipartReplyMessage((MultipartReplyMessage) message); if (outputManager != null) { outputManager.onMessage((OfHeader) message); } + messageListener.onMultipartReplyMessage((MultipartReplyMessage) message); statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PacketInMessage) { messageListener.onPacketInMessage((PacketInMessage) message); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index f133082f..e8e2307c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -8,10 +8,13 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; +import com.google.common.base.Verify; import com.google.common.util.concurrent.FutureCallback; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import javax.annotation.Nonnull; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; +import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -199,10 +202,22 @@ OfHeader flushEntry() { } } - private boolean xidInRance(final long xid) { + // Argument is 'long' to explicitly convert before performing operations + private boolean xidInRange(final long xid) { return xid < endXid && (xid >= baseXid || baseXid > endXid); } + private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) { + if (response instanceof Error) { + final Error err = (Error)response; + LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString()); + entry.fail(new DeviceRequestFailedException("Device-side failure", err)); + return true; + } else { + return entry.complete(response); + } + } + /** * Return the request entry corresponding to a response. Returns null * if there is no request matching the response. @@ -212,7 +227,7 @@ private boolean xidInRance(final long xid) { */ OutboundQueueEntry pairRequest(@Nonnull final OfHeader response) { final Long xid = response.getXid(); - if (!xidInRance(xid)) { + if (!xidInRange(xid)) { LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, queue.length, xid); return null; } @@ -224,16 +239,23 @@ OutboundQueueEntry pairRequest(@Nonnull final OfHeader response) { return null; } - if (entry.complete(response)) { + if (entry.isBarrier()) { + // This has been a barrier -- make sure we complete all preceding requests. + // XXX: Barriers are expected to complete in one message. + // If this assumption is changed, this logic will need to be expanded + // to ensure that the requests implied by the barrier are reported as + // completed *after* the barrier. + LOG.trace("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1); + completeRequests(offset); + lastBarrierOffset = offset; + + final boolean success = completeEntry(entry, response); + Verify.verify(success, "Barrier request failed to complete"); + completeCount++; + } else if (completeEntry(entry, response)) { completeCount++; - - // This has been a barrier -- make sure we complete all preceding requests - if (entry.isBarrier()) { - LOG.debug("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1); - completeRequests(offset); - lastBarrierOffset = offset; - } } + return entry; } From 20ac1113a590c3067f755a9508f915898b0185c7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 17 May 2015 00:46:48 +0200 Subject: [PATCH 171/285] BUG-3219: introduce OutboundQueueException Original API has not specified an encapsulation exception for errors incurred during local processing. This patch fixes that by introducing OutboundQueueException. Change-Id: I01197710c9d60bd778009c098ec640511eea23c6 Signed-off-by: Robert Varga (cherry picked from commit 763e430f61196740c5ea1c7356022396adf55065) --- .../DeviceRequestFailedException.java | 2 +- .../api/connection/OutboundQueue.java | 5 ++++ .../connection/OutboundQueueException.java | 29 +++++++++++++++++++ .../core/connection/OutboundQueueImpl.java | 5 ++-- .../core/connection/OutboundQueueManager.java | 5 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueException.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java index a353886d..347d73d0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/DeviceRequestFailedException.java @@ -15,7 +15,7 @@ * Exception which is used to report that a particular request failed on the * remote device (switch). */ -public class DeviceRequestFailedException extends Exception { +public class DeviceRequestFailedException extends OutboundQueueException { private static final long serialVersionUID = 1L; private final Error error; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java index 06b66c5e..afe5b056 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java @@ -33,6 +33,11 @@ public interface OutboundQueue { * If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable) * will be called with an instance of {@link DeviceRequestFailedException}. * + * If the request fails due to local reasons, {@link FutureCallback#onFailure(Throwable) + * will be called with an instance of {@link OutboundQueueException}. In particular, if + * this request failed because the device disconnected, {@link OutboundQueueException#DEVICE_DISCONNECTED} + * will be reported. + * * @param xid Previously-reserved XID * @param message Message which should be sent out, or null if the reservation * should be cancelled. diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueException.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueException.java new file mode 100644 index 00000000..497c7a25 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueueException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.connection; + +/** + * Exception reported when an exceptional event occurs on an {@link OutboundQueue}, + * which the {@link OutboundQueueHandler} needs to be aware of. + */ +public class OutboundQueueException extends Exception { + /** + * Exception reported when the device disconnects. + */ + public static final OutboundQueueException DEVICE_DISCONNECTED = new OutboundQueueException("Device disconnected"); + + private static final long serialVersionUID = 1L; + + public OutboundQueueException(final String message) { + super(message); + } + + public OutboundQueueException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index e8e2307c..f61e8fff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -12,8 +12,9 @@ import com.google.common.util.concurrent.FutureCallback; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import javax.annotation.Nonnull; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; @@ -272,7 +273,7 @@ void completeAll() { completeRequests(queue.length); } - int failAll(final Throwable cause) { + int failAll(final OutboundQueueException cause) { int ret = 0; for (int i = lastBarrierOffset + 1; i < queue.length; ++i) { final OutboundQueueEntry entry = queue[i]; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 4864b95d..5c9a3515 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -15,9 +15,9 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; -import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; @@ -397,9 +397,8 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { LOG.debug("Channel shutdown, flushing queue..."); handler.onConnectionQueueChanged(null); - final Throwable cause = new RejectedExecutionException("Channel disconnected"); for (OutboundQueueImpl queue : activeQueues) { - entries += queue.failAll(cause); + entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); } activeQueues.clear(); From aa13d46568a13f9d73f9ea90b2c14211b473dde6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 17 May 2015 03:11:00 +0200 Subject: [PATCH 172/285] BUG-3219: Fix OutboundQueue cleanup on channel failure When the channel goes inactive, we still need to make sure that any entries that were reserved and not committed get flushed. Instead of perfoming a one-shot cleanup in channelInactive(), perform cleanup whenever flush() runs. When channel goes inactive, we just cleanup the obviously-freeable resources and ensure that a flush is scheduled. Change-Id: I48e1ceb51dcfafedb7352db5d952e9749cdfa50d Signed-off-by: Robert Varga (cherry picked from commit 44b028491689d8d89c2ffea2e7bc6bb2d80209fe) --- .../core/connection/OutboundQueueEntry.java | 3 +- .../core/connection/OutboundQueueImpl.java | 4 ++ .../core/connection/OutboundQueueManager.java | 45 ++++++++++++------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index c0c2f764..8b498579 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -9,6 +9,7 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; @@ -76,7 +77,7 @@ boolean complete(final OfHeader response) { return reallyComplete; } - void fail(final Throwable cause) { + void fail(final OutboundQueueException cause) { if (!completed) { completed = true; if (callback != null) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index f61e8fff..6713d5ce 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -277,6 +277,10 @@ int failAll(final OutboundQueueException cause) { int ret = 0; for (int i = lastBarrierOffset + 1; i < queue.length; ++i) { final OutboundQueueEntry entry = queue[i]; + if (!entry.isCommitted()) { + break; + } + if (!entry.isCompleted()) { entry.fail(cause); ret++; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 5c9a3515..5d36859d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -70,6 +70,8 @@ public void run() { flush(); } }; + + // Passed to executor to request a periodic barrier check private final Runnable barrierRunnable = new Runnable() { @Override public void run() { @@ -249,15 +251,11 @@ boolean onMessage(final OfHeader message) { } private void scheduleFlush() { - if (parent.getChannel().isWritable()) { - if (flushScheduled.compareAndSet(false, true)) { - LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); - parent.getChannel().eventLoop().execute(flushRunnable); - } else { - LOG.trace("Flush task is already present on channel {}", parent.getChannel()); - } + if (flushScheduled.compareAndSet(false, true)) { + LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); + parent.getChannel().eventLoop().execute(flushRunnable); } else { - LOG.trace("Channel {} is not writable, not issuing a flush", parent.getChannel()); + LOG.trace("Flush task is already present on channel {}", parent.getChannel()); } } @@ -294,6 +292,24 @@ protected void barrier() { * Perform a single flush operation. */ protected void flush() { + // If the channel is gone, just flush whatever is not completed + if (currentQueue == null) { + long entries = 0; + + final Iterator it = activeQueues.iterator(); + while (it.hasNext()) { + final OutboundQueueImpl queue = it.next(); + entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); + if (queue.isFinished()) { + LOG.trace("Cleared queue {}", queue); + it.remove(); + } + } + + LOG.debug("Cleared {} queue entries from channel {}", entries, parent.getChannel()); + return; + } + final long start = System.nanoTime(); final long deadline = start + maxWorkTime; @@ -359,7 +375,6 @@ protected void flush() { conditionalFlush(); } - /** * Schedule a queue flush if it is not empty and the channel is found * to be writable. May only be called from Netty context. @@ -393,16 +408,12 @@ public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Ex public void channelInactive(final ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); - long entries = 0; - LOG.debug("Channel shutdown, flushing queue..."); + LOG.debug("Channel {} shutdown, flushing queue...", parent.getChannel()); handler.onConnectionQueueChanged(null); + currentQueue = null; + queueCache.clear(); - for (OutboundQueueImpl queue : activeQueues) { - entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); - } - activeQueues.clear(); - - LOG.debug("Flushed {} queue entries", entries); + scheduleFlush(); } @Override From 0c09ae4a352cccbd7dbaa1058bfb5ac370b9310a Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 20:35:50 +0200 Subject: [PATCH 173/285] BUG-3229: Add support for PacketIn filtering When we are facing an overload situation, we may need to suppress PacketIns while still processing other messages. This patch adds the interface for ConnectionAdapter users which they can use to enable filtering of such packets. The implementation ensures that we filter these packets as efficiently as possible. Change-Id: I431631922437af7a08eb8ece647904d487634bd9 Signed-off-by: Robert Varga (cherry picked from commit 1f1a00d6c132e58a4d8f549f836323ecfe003e77) --- .../api/connection/ConnectionAdapter.java | 7 +++++ .../protocol/impl/core/OFVersionDetector.java | 30 ++++++++++++------- .../connection/ConnectionAdapterImpl.java | 13 ++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 02679f05..443dea57 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -82,4 +82,11 @@ public interface ConnectionAdapter extends OpenflowProtocolService { @Beta OutboundQueueHandlerRegistration registerOutboundQueueHandler(T handler, int maxQueueDepth, long maxBarrierNanos); + + /** + * Set filtering of PacketIn messages. By default these messages are not filtered. + * @param enabled True if PacketIn messages should be filtered, false if they should be reported. + */ + @Beta + void setPacketInFiltering(boolean enabled); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 85bb5d55..083cf0ec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -26,7 +26,9 @@ public class OFVersionDetector extends ByteToMessageDecoder { private static final byte OF10_VERSION_ID = EncodeConstants.OF10_VERSION_ID; /** Version number of OpenFlow 1.3 protocol */ private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID; + private static final short OF_PACKETIN = 10; private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class); + private volatile boolean filterPacketIns; /** * Constructor of class. @@ -35,23 +37,31 @@ public OFVersionDetector() { LOGGER.trace("Creating OFVersionDetector"); } + public void setFilterPacketIns(final boolean enabled) { + filterPacketIns = enabled; + } + @Override - protected void decode(final ChannelHandlerContext chc, final ByteBuf bb, final List list) throws Exception { - if (bb.readableBytes() == 0) { + protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List out) { + if (!in.isReadable()) { LOGGER.debug("not enough data"); - bb.release(); + in.release(); return; } - byte version = bb.readByte(); - if ((version == OF13_VERSION_ID) || (version == OF10_VERSION_ID)) { + + final byte version = in.readByte(); + if (version == OF13_VERSION_ID || version == OF10_VERSION_ID) { LOGGER.debug("detected version: {}", version); - ByteBuf messageBuffer = bb.slice(); - list.add(new VersionMessageWrapper(version, messageBuffer)); - messageBuffer.retain(); + if (!filterPacketIns || OF_PACKETIN != in.getUnsignedByte(in.readerIndex())) { + ByteBuf messageBuffer = in.slice(); + out.add(new VersionMessageWrapper(version, messageBuffer)); + messageBuffer.retain(); + } else { + LOGGER.debug("dropped packetin"); + } } else { LOGGER.warn("detected version: {} - currently not supported", version); } - bb.skipBytes(bb.readableBytes()); + in.skipBytes(in.readableBytes()); } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 91f4ceb1..464527c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -27,6 +27,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; +import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector; +import org.opendaylight.openflowjava.protocol.impl.core.PipelineHandlers; import org.opendaylight.openflowjava.statistics.CounterEventTypes; import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; @@ -117,6 +119,7 @@ public void onRemoval( private OutboundQueueManager outputManager; private boolean disconnectOccured = false; private final StatisticsCounters statisticsCounters; + private OFVersionDetector versionDetector; private final InetSocketAddress address; /** @@ -135,6 +138,7 @@ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress addr this.address = address; channel.pipeline().addLast(output); statisticsCounters = StatisticsCounters.getInstance(); + LOG.debug("ConnectionAdapter created"); } @@ -455,6 +459,9 @@ public void checkListeners() { @Override public void fireConnectionReadyNotification() { + versionDetector = (OFVersionDetector) channel.pipeline().get(PipelineHandlers.OF_VERSION_DETECTOR.name()); + Preconditions.checkState(versionDetector != null); + new Thread(new Runnable() { @Override public void run() { @@ -514,4 +521,10 @@ protected void removeRegistration() { Channel getChannel() { return channel; } + + @Override + public void setPacketInFiltering(final boolean enabled) { + versionDetector.setFilterPacketIns(enabled); + LOG.debug("PacketIn filtering {}abled", enabled ? "en" : "dis"); + } } From cd1b82fde7dff45104d970f8655c07ec2f5286ee Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 18 May 2015 18:11:04 +0200 Subject: [PATCH 174/285] BUG-3219: Fix flush task scheduling The flush task should be conditionally scheduled if we have any outstanding requests. We also cannot directly report the channel shutdown until we have ensured that all requests have been completed by the user. Change-Id: Ic8d266d6167eed15f3a51bf8476bbd1db3071dd4 Signed-off-by: Robert Varga (cherry picked from commit 752e794406bc31ea5412f780b01d5db5c5b80e33) --- .../core/connection/OutboundQueueImpl.java | 37 ++++++- .../core/connection/OutboundQueueManager.java | 98 ++++++++++++------- 2 files changed, 100 insertions(+), 35 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 6713d5ce..4f708004 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -135,12 +135,30 @@ Long reserveBarrierIfNeeded() { } } + int startShutdown() { + // Increment the offset by the queue size, hence preventing any normal + // allocations. We should not be seeing a barrier reservation after this + // and if there is one issued, we can disregard it. + final int offset = CURRENT_OFFSET_UPDATER.getAndAdd(this, queue.length); + + // If this offset is larger than reserve, trim it. That is not an accurate + // view of which slot was actually "reserved", but it indicates at which + // entry we can declare the queue flushed (e.g. at the emergency slot). + return offset > reserve ? reserve : offset; + } + + boolean isShutdown(final int offset) { + // This queue is shutdown if the flushOffset (e.g. the next entry to + // be flushed) points to the offset 'reserved' in startShutdown() + return flushOffset >= offset; + } + /** * An empty queue is a queue which has no further unflushed entries. * * @return True if this queue does not have unprocessed entries. */ - boolean isEmpty() { + private boolean isEmpty() { int ro = reserveOffset; if (ro >= reserve) { if (queue[reserve].isCommitted()) { @@ -179,6 +197,23 @@ boolean isFlushed() { return flushOffset >= queue.length || !queue[reserve].isCommitted(); } + boolean needsFlush() { + if (flushOffset < reserve) { + return queue[flushOffset].isCommitted(); + } + + if (isFlushed()) { + LOG.trace("Queue {} is flushed, schedule a replace", this); + return true; + } + if (isFinished()) { + LOG.trace("Queue {} is finished, schedule a cleanup", this); + return true; + } + + return false; + } + OfHeader flushEntry() { for (;;) { // No message ready diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 5d36859d..a4d3f974 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -62,6 +62,7 @@ final class OutboundQueueManager extends Channel private boolean barrierTimerEnabled; private int nonBarrierMessages; private long lastXid = 0; + private Integer shutdownOffset; // Passed to executor to request triggering of flush private final Runnable flushRunnable = new Runnable() { @@ -270,7 +271,7 @@ void ensureFlushing(final OutboundQueueImpl queue) { protected void barrier() { LOG.debug("Channel {} barrier timer expired", parent.getChannel()); barrierTimerEnabled = false; - if (currentQueue == null) { + if (shutdownOffset != null) { LOG.trace("Channel shut down, not processing barrier"); return; } @@ -288,25 +289,58 @@ protected void barrier() { } } + private void rescheduleFlush() { + /* + * We are almost ready to terminate. This is a bit tricky, because + * we do not want to have a race window where a message would be + * stuck on the queue without a flush being scheduled. + * + * So we mark ourselves as not running and then re-check if a + * flush out is needed. That will re-synchronized with other threads + * such that only one flush is scheduled at any given time. + */ + if (!flushScheduled.compareAndSet(true, false)) { + LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); + } + + conditionalFlush(); + } + + private void shutdownFlush() { + long entries = 0; + + // Fail all queues + final Iterator it = activeQueues.iterator(); + while (it.hasNext()) { + final OutboundQueueImpl queue = it.next(); + + entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); + if (queue.isFinished()) { + LOG.trace("Cleared queue {}", queue); + it.remove(); + } + } + + LOG.debug("Cleared {} queue entries from channel {}", entries, parent.getChannel()); + + Preconditions.checkNotNull(currentQueue, "Current queue should not be null yet"); + if (currentQueue.isShutdown(shutdownOffset)) { + currentQueue = null; + handler.onConnectionQueueChanged(null); + LOG.debug("Channel {} shutdown complete", parent.getChannel()); + } else { + LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); + rescheduleFlush(); + } + } + /** * Perform a single flush operation. */ protected void flush() { // If the channel is gone, just flush whatever is not completed - if (currentQueue == null) { - long entries = 0; - - final Iterator it = activeQueues.iterator(); - while (it.hasNext()) { - final OutboundQueueImpl queue = it.next(); - entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); - if (queue.isFinished()) { - LOG.trace("Cleared queue {}", queue); - it.remove(); - } - } - - LOG.debug("Cleared {} queue entries from channel {}", entries, parent.getChannel()); + if (shutdownOffset != null) { + shutdownFlush(); return; } @@ -359,20 +393,7 @@ protected void flush() { LOG.debug("Flushed {} messages in {}us to channel {}", messages, TimeUnit.NANOSECONDS.toMicros(stop - start), parent.getChannel()); - /* - * We are almost ready to terminate. This is a bit tricky, because - * we do not want to have a race window where a message would be - * stuck on the queue without a flush being scheduled. - * - * So we mark ourselves as not running and then re-check if a - * flush out is needed. That will re-synchronized with other threads - * such that only one flush is scheduled at any given time. - */ - if (!flushScheduled.compareAndSet(true, false)) { - LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); - } - - conditionalFlush(); + rescheduleFlush(); } /** @@ -380,7 +401,7 @@ protected void flush() { * to be writable. May only be called from Netty context. */ private void conditionalFlush() { - if (!currentQueue.isEmpty()) { + if (currentQueue.needsFlush()) { scheduleFlush(); } else { LOG.trace("Queue is empty, no flush needed"); @@ -408,11 +429,20 @@ public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Ex public void channelInactive(final ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); - LOG.debug("Channel {} shutdown, flushing queue...", parent.getChannel()); - handler.onConnectionQueueChanged(null); - currentQueue = null; - queueCache.clear(); + LOG.debug("Channel {} initiating shutdown...", parent.getChannel()); + /* + * We are dealing with a multi-threaded shutdown, as the user may still + * be reserving entries in the queue. We are executing in a netty thread, + * so neither flush nor barrier can be running, which is good news. + * + * We will eat up all the slots in the queue here and mark the offset first + * reserved offset and free up all the cached queues. We then schedule + * the flush task, which will deal with the rest of the shutdown process. + */ + shutdownOffset = currentQueue.startShutdown(); + queueCache.clear(); + LOG.trace("Channel {} reserved all entries at offset {}", parent.getChannel(), shutdownOffset); scheduleFlush(); } From 4afe2340c1ef1a818cd5553855bd6e7a2a302ab1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 18 May 2015 18:11:04 +0200 Subject: [PATCH 175/285] BUG-3219: Fix debug arguments The LOG.debug() message specifies the first argument should be 'this', but that argument is missing. Fix the inconsistency. Change-Id: Ie9bbed4fa6974430457cb32fc6f0481948351e20 Signed-off-by: Robert Varga (cherry picked from commit 964fe07ec797b78a5390c9f9088eb468967b4906) --- .../protocol/impl/core/connection/OutboundQueueImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 4f708004..921b4290 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -188,7 +188,7 @@ boolean isFinished() { } boolean isFlushed() { - LOG.debug("Check queue {} for completeness (offset {}, reserve {})", flushOffset, reserve); + LOG.debug("Check queue {} for completeness (offset {}, reserve {})", this, flushOffset, reserve); if (flushOffset < reserve) { return false; } From e64e16ac5eb15db5c7a97ab1f684bb78d580a7b1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 18 May 2015 17:18:41 +0200 Subject: [PATCH 176/285] BUG-3219: Handle EchoRequests directly in ConnectionAdapter If we have an OutboundQueueManager, we should short-cut handling of echo request messages in the plugin itself. Perform exectly that. Change-Id: If4090d02e521c2da5914545bf3e887bd265c54a0 Signed-off-by: Robert Varga (cherry picked from commit 464718c39f203539d7285c172d29027484c88fc9) --- .../impl/core/connection/ConnectionAdapterImpl.java | 6 +++++- .../impl/core/connection/OutboundQueueManager.java | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 464527c7..cf2693c8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -284,7 +284,11 @@ public void consume(final DataObject message) { systemListener.onSwitchIdleEvent((SwitchIdleEvent) message); // OpenFlow messages } else if (message instanceof EchoRequestMessage) { - messageListener.onEchoRequestMessage((EchoRequestMessage) message); + if (outputManager != null) { + outputManager.onEchoRequest((EchoRequestMessage) message); + } else { + messageListener.onEchoRequestMessage((EchoRequestMessage) message); + } statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ErrorMessage) { // Send only unmatched errors diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index a4d3f974..766abe6a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -20,6 +20,9 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -450,4 +453,9 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { public String toString() { return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get()); } + + void onEchoRequest(final EchoRequestMessage message) { + final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()).setVersion(message.getVersion()).setXid(message.getXid()).build(); + parent.getChannel().writeAndFlush(reply); + } } From c36521263ffcaf6a65ede1c45a487adcf40818d0 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 19 May 2015 11:32:34 +0200 Subject: [PATCH 177/285] BUG-3219: guard from wron-use entry commit Debugging has revealed that OFP may be crossing channels and ends up committing an unreserved offset. Add a guard to check for that. Change-Id: I445e07df6e628a4abccd4a6daa347e1de12e8eba Signed-off-by: Robert Varga (cherry picked from commit 5430767b0b533d1db017b2c4fce88150ac25f50c) --- .../protocol/impl/core/connection/OutboundQueueImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 921b4290..ebf2a94d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -87,9 +87,12 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall Preconditions.checkArgument(xid.equals(message.getXid()), "Message %s has wrong XID %s, expected %s", message, message.getXid(), xid); } + final int ro = reserveOffset; + Preconditions.checkArgument(offset < ro, "Unexpected commit to offset {} reserved {} message {}", offset, ro, message); + final OutboundQueueEntry entry = queue[offset]; entry.commit(message, callback); - LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, reserveOffset); + LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, ro); if (entry.isBarrier()) { int my = offset; @@ -218,7 +221,7 @@ OfHeader flushEntry() { for (;;) { // No message ready if (isEmpty()) { - LOG.trace("Flushed all reserved entries up to ", flushOffset); + LOG.trace("Flushed all reserved entries up to {}", flushOffset); return null; } From 27e5a44787810cf0663f70c38f63d8ad0cdf74d9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 19 May 2015 13:45:09 +0200 Subject: [PATCH 178/285] Do not reschedule flush when channel is up and not writable Shutdown logic checks removed a ciritical check for channel writability during reschedule. The problem is that an inactive channel is not writable, hence we need to check for two conditions. Change-Id: I2c0a79d5f7b8d9cbaec0eaeb553a6f4ecc74f391 Signed-off-by: Robert Varga (cherry picked from commit 491faf19aef765281f32ac787f9fab9a3b459b7d) --- .../protocol/impl/core/connection/OutboundQueueManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 766abe6a..609e23c1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -404,7 +404,7 @@ protected void flush() { * to be writable. May only be called from Netty context. */ private void conditionalFlush() { - if (currentQueue.needsFlush()) { + if (currentQueue.needsFlush() && (shutdownOffset != null || parent.getChannel().isWritable())) { scheduleFlush(); } else { LOG.trace("Queue is empty, no flush needed"); From c3c505024150f1c6acf2c1db42f0b5479ad78e0a Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Wed, 20 May 2015 10:58:07 +0200 Subject: [PATCH 179/285] added packetIn filter counts to statistics Change-Id: Ifce135548ad1d2ecb9c4bc6ff15e922af771368f Signed-off-by: Michal Polkorab Signed-off-by: Michal Rehak (cherry picked from commit 25d95eb2be97152d7a459a12caa5e51a79556f58) --- .../openflowjava/protocol/impl/core/OFVersionDetector.java | 5 +++++ .../openflowjava/statistics/CounterEventTypes.java | 4 ++++ .../openflowjava/statistics/StatisticsCounters.java | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 083cf0ec..0142ebfd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -13,6 +13,8 @@ import io.netty.handler.codec.ByteToMessageDecoder; import java.util.List; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +30,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID; private static final short OF_PACKETIN = 10; private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class); + private final StatisticsCounters statisticsCounters; private volatile boolean filterPacketIns; /** @@ -35,6 +38,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { */ public OFVersionDetector() { LOGGER.trace("Creating OFVersionDetector"); + statisticsCounters = StatisticsCounters.getInstance(); } public void setFilterPacketIns(final boolean enabled) { @@ -58,6 +62,7 @@ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final L messageBuffer.retain(); } else { LOGGER.debug("dropped packetin"); + statisticsCounters.incrementCounter(CounterEventTypes.US_DROPPED_PACKET_IN); } } else { LOGGER.warn("detected version: {} - currently not supported", version); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java index b021745d..60b1c6da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -34,6 +34,10 @@ public enum CounterEventTypes { * flow-mod encoded and sent to downstream */ DS_FLOW_MODS_SENT, + /** + * packetIn message got dropped -filtering is active + */ + US_DROPPED_PACKET_IN, /** * receive message and pass to upstream */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index f3566a09..3f900d80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -11,7 +11,6 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; - import org.opendaylight.openflowjava.protocol.spi.statistics.StatisticsHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +45,7 @@ public final class StatisticsCounters implements StatisticsHandler { CounterEventTypes.DS_ENTERED_OFJAVA, CounterEventTypes.DS_FLOW_MODS_ENTERED, CounterEventTypes.DS_FLOW_MODS_SENT, + CounterEventTypes.US_DROPPED_PACKET_IN, CounterEventTypes.US_DECODE_FAIL, CounterEventTypes.US_DECODE_SUCCESS, CounterEventTypes.US_MESSAGE_PASS, From 701b8103d011a8d5139165cf62c2deab36864a1a Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 21 May 2015 11:07:01 +0200 Subject: [PATCH 180/285] Fix precondition format string Instead of logging-style placeholders, use String.format() ones. Change-Id: I2cfde7eef0dcf4b906d4760dcedc3fd2f1a14df9 Signed-off-by: Robert Varga (cherry picked from commit 1ef77ad63ab66eed7dd5404301964db8291004b1) --- .../protocol/impl/core/connection/OutboundQueueImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index ebf2a94d..c9c28c16 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -88,7 +88,7 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall } final int ro = reserveOffset; - Preconditions.checkArgument(offset < ro, "Unexpected commit to offset {} reserved {} message {}", offset, ro, message); + Preconditions.checkArgument(offset < ro, "Unexpected commit to offset %s reserved %s message %s", offset, ro, message); final OutboundQueueEntry entry = queue[offset]; entry.commit(message, callback); From fb53aa09a2412caccf65731f5868b70915567ec2 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 21 May 2015 13:05:15 +0200 Subject: [PATCH 181/285] BUG-3219: clear queue array before stashing The queue should be cleared before stashing so as to not take the take up memory. Change-Id: I71c9a90e1ed9e4b7c7d47bb3e0785f67a8daf932 Signed-off-by: Robert Varga (cherry picked from commit f84d1445e610bf985caa1c4e41c35954ea664b2c) --- .../protocol/impl/core/connection/OutboundQueueImpl.java | 3 +++ .../protocol/impl/core/connection/OutboundQueueManager.java | 1 + 2 files changed, 4 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index c9c28c16..ab3340bf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -66,6 +66,9 @@ private OutboundQueueImpl(final OutboundQueueManager manager, final long base this.baseXid = baseXid; this.endXid = baseXid + queue.length; this.reserve = queue.length - 1; + } + + void retire() { for (OutboundQueueEntry element : queue) { element.reset(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 609e23c1..f2a4b0e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -109,6 +109,7 @@ public void close() { private void retireQueue(final OutboundQueueImpl queue) { if (queueCache.offer(queue)) { + queue.retire(); LOG.trace("Saving queue {} for later reuse", queue); } else { LOG.trace("Queue {} thrown away", queue); From 354c77b535184f0743baa30304d53bf2eea9c936 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 21 May 2015 14:57:48 +0200 Subject: [PATCH 182/285] BUG-3219: Throw away message as soon as we send it out In order to relieve pressure on memory, do not wait until the entire buffer is acknowledged, but clear the message as soon as we send it to the network. Change-Id: Ie64c1e0a011e1d1a1a0a98a21d9cc90642f81e6c Signed-off-by: Robert Varga (cherry picked from commit be5f0cac1babcfccc7209657f2541dd0818c5cb0) --- .../core/connection/OutboundQueueEntry.java | 17 +++++++++++------ .../impl/core/connection/OutboundQueueImpl.java | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 8b498579..48722dbb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -21,27 +21,30 @@ final class OutboundQueueEntry { private FutureCallback callback; private OfHeader message; private boolean completed; + private boolean barrier; private volatile boolean committed; void commit(final OfHeader message, final FutureCallback callback) { this.message = message; this.callback = callback; + this.barrier = message instanceof BarrierInput; // Volatile write, needs to be last committed = true; } void reset() { + barrier = false; callback = null; - message = null; completed = false; + message = null; // Volatile write, needs to be last committed = false; } boolean isBarrier() { - return message instanceof BarrierInput; + return barrier; } boolean isCommitted() { @@ -52,12 +55,14 @@ boolean isCompleted() { return completed; } - OfHeader getMessage() { - return message; + OfHeader takeMessage() { + final OfHeader ret = message; + message = null; + return ret; } boolean complete(final OfHeader response) { - Preconditions.checkState(!completed, "Attempted to complete a completed message %s with response %s", message, response); + Preconditions.checkState(!completed, "Attempted to complete a completed message with response %s", response); // Multipart requests are special, we have to look at them to see // if there is something outstanding and adjust ourselves accordingly @@ -84,7 +89,7 @@ void fail(final OutboundQueueException cause) { callback.onFailure(cause); } } else { - LOG.warn("Ignoring failure {} for completed message {}", cause, message); + LOG.warn("Ignoring failure {} for completed message", cause); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index ab3340bf..2433637f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -234,7 +234,7 @@ OfHeader flushEntry() { return null; } - final OfHeader msg = entry.getMessage(); + final OfHeader msg = entry.takeMessage(); flushOffset++; if (msg != null) { return msg; From a302a0cc64ab45e0dd3d504a6b0248c3f1f9e3df Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 19 May 2015 17:14:06 +0200 Subject: [PATCH 183/285] BUG-3219: implement a shared stash for queue reuse This introduces a global per-size stash for reuse of OutbountQueueImpl objects. This allows for efficient reuse across multiple sessions, which means we minimize stale memory use when some channels are idle. The stash is implemented in terms of a ConcurrentLinkedDeque, which is flushed from the tail and has soft references. We rely on FinalizableReference to notify us when a particular queue is finished. Change-Id: I78e654a0c3470bbd1c9274237b2be04f50459809 Signed-off-by: Robert Varga (cherry picked from commit b95f82e5129f22e7b22352d028b0d32d744e924d) --- .../connection/ConnectionAdapterImpl.java | 2 +- .../core/connection/OutboundQueueCache.java | 43 ++++++++ .../connection/OutboundQueueCacheSlice.java | 97 +++++++++++++++++++ .../core/connection/OutboundQueueImpl.java | 2 +- .../core/connection/OutboundQueueManager.java | 52 ++++------ 5 files changed, 159 insertions(+), 37 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index cf2693c8..ded62f57 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -508,7 +508,7 @@ public OutboundQueueHandlerRegistration regi final T handler, final int maxQueueDepth, final long maxBarrierNanos) { Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager); - final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); + final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, OutboundQueueCache.getInstance().getSlice(maxQueueDepth), maxBarrierNanos); outputManager = ret; channel.pipeline().addLast(outputManager); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java new file mode 100644 index 00000000..f65c5a86 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import java.util.HashMap; +import java.util.Map; + +final class OutboundQueueCache { + private static final OutboundQueueCache INSTANCE = new OutboundQueueCache(); + + private final Map slices = new HashMap<>(); + + private OutboundQueueCache() { + + } + + static OutboundQueueCache getInstance() { + return INSTANCE; + } + + synchronized OutboundQueueCacheSlice getSlice(final int queueSize) { + final OutboundQueueCacheSlice oldSlice = slices.get(queueSize); + if (oldSlice != null) { + oldSlice.incRef(); + return oldSlice; + } + + final OutboundQueueCacheSlice newSlice = new OutboundQueueCacheSlice(queueSize); + slices.put(queueSize, newSlice); + return newSlice; + } + + synchronized void putSlice(final OutboundQueueCacheSlice slice) { + if (slice.decRef()) { + slices.remove(slice.getQueueSize()); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java new file mode 100644 index 00000000..a5145890 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.FinalizableReferenceQueue; +import com.google.common.base.FinalizableSoftReference; +import com.google.common.base.Preconditions; +import java.lang.ref.Reference; +import java.util.Collection; +import java.util.concurrent.ConcurrentLinkedDeque; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class OutboundQueueCacheSlice { + private static final class QueueRef extends FinalizableSoftReference { + private final Collection cache; + + protected QueueRef(final FinalizableReferenceQueue queue, final Collection cache, final OutboundQueueImpl referent) { + super(referent, queue); + this.cache = Preconditions.checkNotNull(cache); + } + + @Override + public void finalizeReferent() { + cache.remove(this); + } + } + + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueCacheSlice.class); + private final FinalizableReferenceQueue refQueue = new FinalizableReferenceQueue(); + + private final ConcurrentLinkedDeque cache = new ConcurrentLinkedDeque<>(); + private final int queueSize; + private int refCount = 1; + + OutboundQueueCacheSlice(final int queueSize) { + Preconditions.checkArgument(queueSize >= 1); + this.queueSize = queueSize; + } + + void remove(final QueueRef queueRef) { + cache.remove(queueRef); + } + + boolean decRef() { + if (--refCount == 0) { + refQueue.close(); + return true; + } else { + return false; + } + } + + void incRef() { + refCount++; + } + + int getQueueSize() { + return queueSize; + } + + OutboundQueueImpl getQueue(final OutboundQueueManager manager, final long baseXid) { + final OutboundQueueImpl ret; + OutboundQueueImpl cached = null; + for (;;) { + final Reference item = cache.pollLast(); + if (item == null) { + break; + } + + cached = item.get(); + if (cached != null) { + ret = cached.reuse(manager, baseXid); + LOG.trace("Reusing queue {} as {} on manager {}", cached, ret, manager); + return ret; + } + } + + ret = new OutboundQueueImpl(manager, baseXid, queueSize + 1); + LOG.trace("Allocated new queue {} on manager {}", ret, manager); + return ret; + } + + void putQueue(final OutboundQueueImpl queue) { + queue.retire(); + if (cache.offer(new QueueRef(refQueue, cache, queue))) { + LOG.trace("Saving queue {} for later reuse", queue); + } else { + LOG.trace("Queue {} thrown away", queue); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 2433637f..5698eeec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -74,7 +74,7 @@ void retire() { } } - OutboundQueueImpl reuse(final long baseXid) { + OutboundQueueImpl reuse(final OutboundQueueManager manager, final long baseXid) { return new OutboundQueueImpl(manager, baseXid, queue); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index f2a4b0e5..948424f9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -11,7 +11,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import java.net.InetSocketAddress; -import java.util.ArrayDeque; import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; @@ -44,23 +43,17 @@ final class OutboundQueueManager extends Channel */ private static final int WORKTIME_RECHECK_MSGS = 64; - /** - * We maintain a cache of this many previous queues for later reuse. - */ - private static final int QUEUE_CACHE_SIZE = 4; - - private final Queue queueCache = new ArrayDeque<>(QUEUE_CACHE_SIZE); private final Queue activeQueues = new LinkedList<>(); private final AtomicBoolean flushScheduled = new AtomicBoolean(); private final ConnectionAdapterImpl parent; private final InetSocketAddress address; private final long maxBarrierNanos; private final long maxWorkTime; - private final int queueSize; private final T handler; // Updated from netty only private long lastBarrierNanos = System.nanoTime(); + private OutboundQueueCacheSlice slice; private OutboundQueueImpl currentQueue; private boolean barrierTimerEnabled; private int nonBarrierMessages; @@ -84,17 +77,16 @@ public void run() { }; OutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler, - final int queueSize, final long maxBarrierNanos) { + final OutboundQueueCacheSlice slice, final long maxBarrierNanos) { this.parent = Preconditions.checkNotNull(parent); this.handler = Preconditions.checkNotNull(handler); - Preconditions.checkArgument(queueSize > 0); - this.queueSize = queueSize; + this.slice = Preconditions.checkNotNull(slice); Preconditions.checkArgument(maxBarrierNanos > 0); this.maxBarrierNanos = maxBarrierNanos; this.address = address; this.maxWorkTime = TimeUnit.MICROSECONDS.toNanos(DEFAULT_WORKTIME_MICROS); - LOG.debug("Queue manager instantiated with queue size {}", queueSize); + LOG.debug("Queue manager instantiated with queue slice {}", slice); createQueue(); } @@ -105,31 +97,17 @@ T getHandler() { @Override public void close() { handler.onConnectionQueueChanged(null); - } - - private void retireQueue(final OutboundQueueImpl queue) { - if (queueCache.offer(queue)) { - queue.retire(); - LOG.trace("Saving queue {} for later reuse", queue); - } else { - LOG.trace("Queue {} thrown away", queue); + if (slice != null) { + slice.decRef(); + slice = null; } } private void createQueue() { final long baseXid = lastXid; - lastXid += queueSize + 1; - - final OutboundQueueImpl cached = queueCache.poll(); - final OutboundQueueImpl queue; - if (cached != null) { - queue = cached.reuse(baseXid); - LOG.trace("Reusing queue {} as {} on channel {}", cached, queue, parent.getChannel()); - } else { - queue = new OutboundQueueImpl(this, baseXid, queueSize + 1); - LOG.trace("Allocated new queue {} on channel {}", queue, parent.getChannel()); - } + lastXid += slice.getQueueSize() + 1; + final OutboundQueueImpl queue = slice.getQueue(this, baseXid); activeQueues.add(queue); currentQueue = queue; handler.onConnectionQueueChanged(queue); @@ -188,7 +166,7 @@ OfHeader flushEntry(final long now) { lastBarrierNanos = now; } else { nonBarrierMessages++; - if (nonBarrierMessages >= queueSize) { + if (nonBarrierMessages >= slice.getQueueSize()) { LOG.trace("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); scheduleBarrierMessage(); } else if (!barrierTimerEnabled) { @@ -235,7 +213,7 @@ boolean onMessage(final OfHeader message) { LOG.trace("Queue {} is implied finished", q); q.completeAll(); it.remove(); - retireQueue(q); + slice.putQueue(q); } else { break; } @@ -245,7 +223,7 @@ boolean onMessage(final OfHeader message) { if (queue.isFinished()) { LOG.trace("Queue {} is finished", queue); it.remove(); - retireQueue(queue); + slice.putQueue(queue); } return true; @@ -445,7 +423,11 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { * the flush task, which will deal with the rest of the shutdown process. */ shutdownOffset = currentQueue.startShutdown(); - queueCache.clear(); + if (slice != null) { + slice.decRef(); + slice = null; + } + LOG.trace("Channel {} reserved all entries at offset {}", parent.getChannel(), shutdownOffset); scheduleFlush(); } From f05d7a5b91980627e3e19ac88352813eb5afec10 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 29 May 2015 00:20:39 +0200 Subject: [PATCH 184/285] Release OutboundQueueEntry callback on completion Memory traces of steady state with mininet have shown we are retaining already-completed callbacks for the duration of the OutboundQueueImpl's generation. For multipart requests that means we end up holding up large chunks of memory for extended time, leading to unacceptable memory pressure which can be easily avoided. Change-Id: I2a980fc454583e8fb5d7fe44e47d7ddf076c650b Signed-off-by: Robert Varga (cherry picked from commit 6b6700b60e2db29fdb23d2044ab254accf86ecc9) --- .../protocol/impl/core/connection/OutboundQueueEntry.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 48722dbb..4b8820bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -77,6 +77,10 @@ boolean complete(final OfHeader response) { completed = reallyComplete; if (callback != null) { callback.onSuccess(response); + if (reallyComplete) { + // We will not need the callback anymore, make sure it can be GC'd + callback = null; + } } LOG.debug("Entry {} completed {} with response {}", this, completed, response); return reallyComplete; @@ -87,10 +91,10 @@ void fail(final OutboundQueueException cause) { completed = true; if (callback != null) { callback.onFailure(cause); + callback = null; } } else { LOG.warn("Ignoring failure {} for completed message", cause); } } - } From 159def5396cbeee7336b4fab971fd0104977ad98 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 1 Jun 2015 22:52:14 +0200 Subject: [PATCH 185/285] Run flush immediately when channel becomes writable Instead of scheduling it on the executor, make sure we run the flush task immediately. Change-Id: Ic0cf9d031127d8e744a5cd79cfe440d52b3c3f0b Signed-off-by: Robert Varga (cherry picked from commit cefbc1e206effcc6d7dc39d860ab2829d3c3cf2a) --- .../core/connection/OutboundQueueImpl.java | 1 + .../core/connection/OutboundQueueManager.java | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java index 5698eeec..c4feb26a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java @@ -107,6 +107,7 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall } // We have traveled back, recover + LOG.debug("Queue {} retry pending barrier {} >= {}", this, prev, my); my = prev; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 948424f9..b3b7b8c3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -334,7 +334,7 @@ protected void flush() { long messages = 0; for (;; ++messages) { if (!parent.getChannel().isWritable()) { - LOG.trace("Channel is no longer writable"); + LOG.debug("Channel {} is no longer writable", parent.getChannel()); break; } @@ -383,8 +383,12 @@ protected void flush() { * to be writable. May only be called from Netty context. */ private void conditionalFlush() { - if (currentQueue.needsFlush() && (shutdownOffset != null || parent.getChannel().isWritable())) { - scheduleFlush(); + if (currentQueue.needsFlush()) { + if (shutdownOffset != null || parent.getChannel().isWritable()) { + scheduleFlush(); + } else { + LOG.debug("Channel {} is not I/O ready, not scheduling a flush", parent.getChannel()); + } } else { LOG.trace("Queue is empty, no flush needed"); } @@ -404,7 +408,13 @@ public void channelActive(final ChannelHandlerContext ctx) throws Exception { @Override public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { super.channelWritabilityChanged(ctx); - conditionalFlush(ctx); + + if (flushScheduled.compareAndSet(false, true)) { + LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); + flush(); + } else { + LOG.debug("Channel {} Writability changed, but task is already scheduled", parent.getChannel()); + } } @Override From 6edfff9e578c0bee8e83f657479ee8b45f154049 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 7 Jun 2015 02:23:41 +0200 Subject: [PATCH 186/285] Tune write low/highwatermark Since we rely on channel writability to throttle message writout, bring it higher up a bit, so we can flush an entire segment in one go. Change-Id: I9394aa795d3e30375f50ffd84efecbe05aa49bf4 Signed-off-by: Robert Varga (cherry picked from commit 754bef597c3b9de84e26bde968e7ab9a502344ff) --- .../core/connection/OutboundQueueManager.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index b3b7b8c3..66fa8a60 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -43,6 +43,19 @@ final class OutboundQueueManager extends Channel */ private static final int WORKTIME_RECHECK_MSGS = 64; + /** + * Default low write watermark. Channel will become writable when number of outstanding + * bytes dips below this value. + */ + private static final int DEFAULT_LOW_WATERMARK = 128 * 1024; + + /** + * Default write high watermark. Channel will become un-writable when number of + * outstanding bytes hits this value. + */ + private static final int DEFAULT_HIGH_WATERMARK = DEFAULT_LOW_WATERMARK * 2; + + private final Queue activeQueues = new LinkedList<>(); private final AtomicBoolean flushScheduled = new AtomicBoolean(); private final ConnectionAdapterImpl parent; @@ -317,7 +330,9 @@ private void shutdownFlush() { } /** - * Perform a single flush operation. + * Perform a single flush operation. We keep it here so we do not generate + * syntetic accessors for private fields. Otherwise it could be moved into + * {@link #flushRunnable}. */ protected void flush() { // If the channel is gone, just flush whatever is not completed @@ -405,6 +420,19 @@ public void channelActive(final ChannelHandlerContext ctx) throws Exception { conditionalFlush(ctx); } + public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { + /* + * Tune channel write buffering. We increase the writability window + * to ensure we can flush an entire queue segment in one go. We definitely + * want to keep the difference above 64k, as that will ensure we use jam-packed + * TCP packets. UDP will fragment as appropriate. + */ + ctx.channel().config().setWriteBufferHighWaterMark(DEFAULT_HIGH_WATERMARK); + ctx.channel().config().setWriteBufferLowWaterMark(DEFAULT_LOW_WATERMARK); + + super.handlerAdded(ctx); + } + @Override public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { super.channelWritabilityChanged(ctx); From adf37207ab942a4742b66304a2ba61d14d71de2a Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 2 Jun 2015 21:19:57 +0200 Subject: [PATCH 187/285] Implement a segmented OutboundQueue Internal lifecycle of a queue segment is disconnected. With this implementation users do not observe queue changes until channel shutdown, when the reported queue changes to null. The reason for that is that the segments are managed internally without the need to synchronize with the Netty thread. That synchronization is performed only when there are multiple segments -- which is typical for crossing the request count barrier. Outbound queue manager is taght to not schedule a flush task it the current state of the channel indicates that scheduling is not needed, such as when the channel is not writable. Change-Id: I037e27c00524e2a6ec218e3e7c1a5d6188b25ae8 Signed-off-by: Robert Varga (cherry picked from commit d7755318c0395f3f74ca580f4e2db963976776aa) --- .../connection/ConnectionAdapterImpl.java | 2 +- .../core/connection/OutboundQueueCache.java | 43 -- .../connection/OutboundQueueCacheSlice.java | 97 ----- .../core/connection/OutboundQueueImpl.java | 334 ---------------- .../core/connection/OutboundQueueManager.java | 368 +++++++----------- .../core/connection/StackedOutboundQueue.java | 351 +++++++++++++++++ .../impl/core/connection/StackedSegment.java | 189 +++++++++ 7 files changed, 676 insertions(+), 708 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index ded62f57..cf2693c8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -508,7 +508,7 @@ public OutboundQueueHandlerRegistration regi final T handler, final int maxQueueDepth, final long maxBarrierNanos) { Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager); - final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, OutboundQueueCache.getInstance().getSlice(maxQueueDepth), maxBarrierNanos); + final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); outputManager = ret; channel.pipeline().addLast(outputManager); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java deleted file mode 100644 index f65c5a86..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCache.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import java.util.HashMap; -import java.util.Map; - -final class OutboundQueueCache { - private static final OutboundQueueCache INSTANCE = new OutboundQueueCache(); - - private final Map slices = new HashMap<>(); - - private OutboundQueueCache() { - - } - - static OutboundQueueCache getInstance() { - return INSTANCE; - } - - synchronized OutboundQueueCacheSlice getSlice(final int queueSize) { - final OutboundQueueCacheSlice oldSlice = slices.get(queueSize); - if (oldSlice != null) { - oldSlice.incRef(); - return oldSlice; - } - - final OutboundQueueCacheSlice newSlice = new OutboundQueueCacheSlice(queueSize); - slices.put(queueSize, newSlice); - return newSlice; - } - - synchronized void putSlice(final OutboundQueueCacheSlice slice) { - if (slice.decRef()) { - slices.remove(slice.getQueueSize()); - } - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java deleted file mode 100644 index a5145890..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueCacheSlice.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import com.google.common.base.FinalizableReferenceQueue; -import com.google.common.base.FinalizableSoftReference; -import com.google.common.base.Preconditions; -import java.lang.ref.Reference; -import java.util.Collection; -import java.util.concurrent.ConcurrentLinkedDeque; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class OutboundQueueCacheSlice { - private static final class QueueRef extends FinalizableSoftReference { - private final Collection cache; - - protected QueueRef(final FinalizableReferenceQueue queue, final Collection cache, final OutboundQueueImpl referent) { - super(referent, queue); - this.cache = Preconditions.checkNotNull(cache); - } - - @Override - public void finalizeReferent() { - cache.remove(this); - } - } - - private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueCacheSlice.class); - private final FinalizableReferenceQueue refQueue = new FinalizableReferenceQueue(); - - private final ConcurrentLinkedDeque cache = new ConcurrentLinkedDeque<>(); - private final int queueSize; - private int refCount = 1; - - OutboundQueueCacheSlice(final int queueSize) { - Preconditions.checkArgument(queueSize >= 1); - this.queueSize = queueSize; - } - - void remove(final QueueRef queueRef) { - cache.remove(queueRef); - } - - boolean decRef() { - if (--refCount == 0) { - refQueue.close(); - return true; - } else { - return false; - } - } - - void incRef() { - refCount++; - } - - int getQueueSize() { - return queueSize; - } - - OutboundQueueImpl getQueue(final OutboundQueueManager manager, final long baseXid) { - final OutboundQueueImpl ret; - OutboundQueueImpl cached = null; - for (;;) { - final Reference item = cache.pollLast(); - if (item == null) { - break; - } - - cached = item.get(); - if (cached != null) { - ret = cached.reuse(manager, baseXid); - LOG.trace("Reusing queue {} as {} on manager {}", cached, ret, manager); - return ret; - } - } - - ret = new OutboundQueueImpl(manager, baseXid, queueSize + 1); - LOG.trace("Allocated new queue {} on manager {}", ret, manager); - return ret; - } - - void putQueue(final OutboundQueueImpl queue) { - queue.retire(); - if (cache.offer(new QueueRef(refQueue, cache, queue))) { - LOG.trace("Saving queue {} for later reuse", queue); - } else { - LOG.trace("Queue {} thrown away", queue); - } - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java deleted file mode 100644 index c4feb26a..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueImpl.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.core.connection; - -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; -import com.google.common.util.concurrent.FutureCallback; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; -import javax.annotation.Nonnull; -import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -final class OutboundQueueImpl implements OutboundQueue { - private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueImpl.class); - private static final AtomicIntegerFieldUpdater CURRENT_OFFSET_UPDATER = - AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "reserveOffset"); - private static final AtomicIntegerFieldUpdater BARRIER_OFFSET_UPDATER = - AtomicIntegerFieldUpdater.newUpdater(OutboundQueueImpl.class, "barrierOffset"); - private final OutboundQueueManager manager; - private final OutboundQueueEntry[] queue; - private final long baseXid; - private final long endXid; - private final int reserve; - - // Updated concurrently - private volatile int barrierOffset = -1; - private volatile int reserveOffset = 0; - - // Updated from Netty only - private int flushOffset; - private int completeCount; - private int lastBarrierOffset = -1; - - OutboundQueueImpl(final OutboundQueueManager manager, final long baseXid, final int maxQueue) { - /* - * We use the last entry as an emergency should a timeout-triggered - * flush request race with normal users for the last entry in this - * queue. In that case the flush request will take the last entry and - * schedule a flush, which means that we will get around sending the - * message as soon as the user finishes the reservation. - */ - Preconditions.checkArgument(maxQueue > 1); - this.baseXid = baseXid; - this.endXid = baseXid + maxQueue; - this.reserve = maxQueue - 1; - this.manager = Preconditions.checkNotNull(manager); - queue = new OutboundQueueEntry[maxQueue]; - for (int i = 0; i < maxQueue; ++i) { - queue[i] = new OutboundQueueEntry(); - } - } - - private OutboundQueueImpl(final OutboundQueueManager manager, final long baseXid, final OutboundQueueEntry[] queue) { - this.manager = Preconditions.checkNotNull(manager); - this.queue = Preconditions.checkNotNull(queue); - this.baseXid = baseXid; - this.endXid = baseXid + queue.length; - this.reserve = queue.length - 1; - } - - void retire() { - for (OutboundQueueEntry element : queue) { - element.reset(); - } - } - - OutboundQueueImpl reuse(final OutboundQueueManager manager, final long baseXid) { - return new OutboundQueueImpl(manager, baseXid, queue); - } - - @Override - public Long reserveEntry() { - return reserveEntry(false); - } - - @Override - public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { - final int offset = (int)(xid - baseXid); - if (message != null) { - Preconditions.checkArgument(xid.equals(message.getXid()), "Message %s has wrong XID %s, expected %s", message, message.getXid(), xid); - } - - final int ro = reserveOffset; - Preconditions.checkArgument(offset < ro, "Unexpected commit to offset %s reserved %s message %s", offset, ro, message); - - final OutboundQueueEntry entry = queue[offset]; - entry.commit(message, callback); - LOG.debug("Queue {} XID {} at offset {} (of {}) committed", this, xid, offset, ro); - - if (entry.isBarrier()) { - int my = offset; - for (;;) { - final int prev = BARRIER_OFFSET_UPDATER.getAndSet(this, my); - if (prev < my) { - LOG.debug("Queue {} recorded pending barrier offset {}", this, my); - break; - } - - // We have traveled back, recover - LOG.debug("Queue {} retry pending barrier {} >= {}", this, prev, my); - my = prev; - } - } - - manager.ensureFlushing(this); - } - - private Long reserveEntry(final boolean forBarrier) { - final int offset = CURRENT_OFFSET_UPDATER.getAndIncrement(this); - if (offset >= reserve) { - if (forBarrier) { - LOG.debug("Queue {} offset {}/{}, using emergency slot", this, offset, queue.length); - return endXid; - } else { - LOG.debug("Queue {} offset {}/{}, not allowing reservation", this, offset, queue.length); - return null; - } - } - - final Long xid = baseXid + offset; - LOG.debug("Queue {} allocated XID {} at offset {}", this, xid, offset); - return xid; - } - - Long reserveBarrierIfNeeded() { - final int bo = barrierOffset; - if (bo >= flushOffset) { - LOG.debug("Barrier found at offset {} (currently at {})", bo, flushOffset); - return null; - } else { - return reserveEntry(true); - } - } - - int startShutdown() { - // Increment the offset by the queue size, hence preventing any normal - // allocations. We should not be seeing a barrier reservation after this - // and if there is one issued, we can disregard it. - final int offset = CURRENT_OFFSET_UPDATER.getAndAdd(this, queue.length); - - // If this offset is larger than reserve, trim it. That is not an accurate - // view of which slot was actually "reserved", but it indicates at which - // entry we can declare the queue flushed (e.g. at the emergency slot). - return offset > reserve ? reserve : offset; - } - - boolean isShutdown(final int offset) { - // This queue is shutdown if the flushOffset (e.g. the next entry to - // be flushed) points to the offset 'reserved' in startShutdown() - return flushOffset >= offset; - } - - /** - * An empty queue is a queue which has no further unflushed entries. - * - * @return True if this queue does not have unprocessed entries. - */ - private boolean isEmpty() { - int ro = reserveOffset; - if (ro >= reserve) { - if (queue[reserve].isCommitted()) { - ro = reserve + 1; - } else { - ro = reserve; - } - } - - LOG.debug("Effective flush/reserve offset {}/{}", flushOffset, ro); - return ro <= flushOffset; - } - - /** - * A queue is finished when all of its entries have been completed. - * - * @return False if there are any uncompleted requests. - */ - boolean isFinished() { - if (completeCount < reserve) { - return false; - } - - // We need to check if the last entry was used - final OutboundQueueEntry last = queue[reserve]; - return !last.isCommitted() || last.isCompleted(); - } - - boolean isFlushed() { - LOG.debug("Check queue {} for completeness (offset {}, reserve {})", this, flushOffset, reserve); - if (flushOffset < reserve) { - return false; - } - - // flushOffset implied == reserve - return flushOffset >= queue.length || !queue[reserve].isCommitted(); - } - - boolean needsFlush() { - if (flushOffset < reserve) { - return queue[flushOffset].isCommitted(); - } - - if (isFlushed()) { - LOG.trace("Queue {} is flushed, schedule a replace", this); - return true; - } - if (isFinished()) { - LOG.trace("Queue {} is finished, schedule a cleanup", this); - return true; - } - - return false; - } - - OfHeader flushEntry() { - for (;;) { - // No message ready - if (isEmpty()) { - LOG.trace("Flushed all reserved entries up to {}", flushOffset); - return null; - } - - final OutboundQueueEntry entry = queue[flushOffset]; - if (!entry.isCommitted()) { - LOG.trace("Request at offset {} not ready yet, giving up", flushOffset); - return null; - } - - final OfHeader msg = entry.takeMessage(); - flushOffset++; - if (msg != null) { - return msg; - } - - LOG.trace("Null message, skipping to offset {}", flushOffset); - } - } - - // Argument is 'long' to explicitly convert before performing operations - private boolean xidInRange(final long xid) { - return xid < endXid && (xid >= baseXid || baseXid > endXid); - } - - private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) { - if (response instanceof Error) { - final Error err = (Error)response; - LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString()); - entry.fail(new DeviceRequestFailedException("Device-side failure", err)); - return true; - } else { - return entry.complete(response); - } - } - - /** - * Return the request entry corresponding to a response. Returns null - * if there is no request matching the response. - * - * @param response Response message - * @return Matching request entry, or null if no match is found. - */ - OutboundQueueEntry pairRequest(@Nonnull final OfHeader response) { - final Long xid = response.getXid(); - if (!xidInRange(xid)) { - LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, queue.length, xid); - return null; - } - - final int offset = (int)(xid - baseXid); - final OutboundQueueEntry entry = queue[offset]; - if (entry.isCompleted()) { - LOG.debug("Entry {} already is completed, not accepting response {}", entry, response); - return null; - } - - if (entry.isBarrier()) { - // This has been a barrier -- make sure we complete all preceding requests. - // XXX: Barriers are expected to complete in one message. - // If this assumption is changed, this logic will need to be expanded - // to ensure that the requests implied by the barrier are reported as - // completed *after* the barrier. - LOG.trace("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1); - completeRequests(offset); - lastBarrierOffset = offset; - - final boolean success = completeEntry(entry, response); - Verify.verify(success, "Barrier request failed to complete"); - completeCount++; - } else if (completeEntry(entry, response)) { - completeCount++; - } - - return entry; - } - - private void completeRequests(final int toOffset) { - for (int i = lastBarrierOffset + 1; i < toOffset; ++i) { - final OutboundQueueEntry entry = queue[i]; - if (!entry.isCompleted() && entry.complete(null)) { - completeCount++; - } - } - } - - void completeAll() { - completeRequests(queue.length); - } - - int failAll(final OutboundQueueException cause) { - int ret = 0; - for (int i = lastBarrierOffset + 1; i < queue.length; ++i) { - final OutboundQueueEntry entry = queue[i]; - if (!entry.isCommitted()) { - break; - } - - if (!entry.isCompleted()) { - entry.fail(cause); - ret++; - } - } - - return ret; - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 66fa8a60..dc378164 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -11,12 +11,8 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import java.net.InetSocketAddress; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Queue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -29,20 +25,6 @@ final class OutboundQueueManager extends ChannelInboundHandlerAdapter implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueManager.class); - /** - * This is the default upper bound we place on the flush task running - * a single iteration. We relinquish control after about this amount - * of time. - */ - private static final long DEFAULT_WORKTIME_MICROS = TimeUnit.MILLISECONDS.toMicros(100); - - /** - * We re-check the time spent flushing every this many messages. We do this because - * checking after each message may prove to be CPU-intensive. Set to Integer.MAX_VALUE - * or similar to disable the feature. - */ - private static final int WORKTIME_RECHECK_MSGS = 64; - /** * Default low write watermark. Channel will become writable when number of outstanding * bytes dips below this value. @@ -55,23 +37,23 @@ final class OutboundQueueManager extends Channel */ private static final int DEFAULT_HIGH_WATERMARK = DEFAULT_LOW_WATERMARK * 2; - - private final Queue activeQueues = new LinkedList<>(); private final AtomicBoolean flushScheduled = new AtomicBoolean(); + private final StackedOutboundQueue currentQueue; private final ConnectionAdapterImpl parent; private final InetSocketAddress address; + private final int maxNonBarrierMessages; private final long maxBarrierNanos; - private final long maxWorkTime; private final T handler; + // Accessed concurrently + private volatile boolean reading; + // Updated from netty only - private long lastBarrierNanos = System.nanoTime(); - private OutboundQueueCacheSlice slice; - private OutboundQueueImpl currentQueue; + private boolean alreadyReading; private boolean barrierTimerEnabled; + private long lastBarrierNanos = System.nanoTime(); private int nonBarrierMessages; - private long lastXid = 0; - private Integer shutdownOffset; + private boolean shuttingDown; // Passed to executor to request triggering of flush private final Runnable flushRunnable = new Runnable() { @@ -90,17 +72,18 @@ public void run() { }; OutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler, - final OutboundQueueCacheSlice slice, final long maxBarrierNanos) { + final int maxNonBarrierMessages, final long maxBarrierNanos) { this.parent = Preconditions.checkNotNull(parent); this.handler = Preconditions.checkNotNull(handler); - this.slice = Preconditions.checkNotNull(slice); + Preconditions.checkArgument(maxNonBarrierMessages > 0); + this.maxNonBarrierMessages = maxNonBarrierMessages; Preconditions.checkArgument(maxBarrierNanos > 0); this.maxBarrierNanos = maxBarrierNanos; this.address = address; - this.maxWorkTime = TimeUnit.MICROSECONDS.toNanos(DEFAULT_WORKTIME_MICROS); - LOG.debug("Queue manager instantiated with queue slice {}", slice); - createQueue(); + currentQueue = new StackedOutboundQueue(this); + LOG.debug("Queue manager instantiated with queue {}", currentQueue); + handler.onConnectionQueueChanged(currentQueue); } T getHandler() { @@ -110,20 +93,6 @@ T getHandler() { @Override public void close() { handler.onConnectionQueueChanged(null); - if (slice != null) { - slice.decRef(); - slice = null; - } - } - - private void createQueue() { - final long baseXid = lastXid; - lastXid += slice.getQueueSize() + 1; - - final OutboundQueueImpl queue = slice.getQueue(this, baseXid); - activeQueues.add(queue); - currentQueue = queue; - handler.onConnectionQueueChanged(queue); } private void scheduleBarrierTimer(final long now) { @@ -150,45 +119,6 @@ private void scheduleBarrierMessage() { LOG.trace("Barrier XID {} scheduled", xid); } - /** - * Flush an entry from the queue. - * - * @param now Time reference for 'now'. We take this as an argument, as - * we need a timestamp to mark barrier messages we see swinging - * by. That timestamp does not need to be completely accurate, - * hence we use the flush start time. Alternative would be to - * measure System.nanoTime() for each barrier -- needlessly - * adding overhead. - * - * @return Entry which was flushed, null if no entry is ready. - */ - OfHeader flushEntry(final long now) { - final OfHeader message = currentQueue.flushEntry(); - if (currentQueue.isFlushed()) { - LOG.debug("Queue {} is fully flushed", currentQueue); - createQueue(); - } - - if (message == null) { - return null; - } - - if (message instanceof BarrierInput) { - LOG.trace("Barrier message seen, resetting counters"); - nonBarrierMessages = 0; - lastBarrierNanos = now; - } else { - nonBarrierMessages++; - if (nonBarrierMessages >= slice.getQueueSize()) { - LOG.trace("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); - scheduleBarrierMessage(); - } else if (!barrierTimerEnabled) { - scheduleBarrierTimer(now); - } - } - - return message; - } /** * Invoked whenever a message comes in from the switch. Runs matching @@ -200,50 +130,7 @@ OfHeader flushEntry(final long now) { boolean onMessage(final OfHeader message) { LOG.trace("Attempting to pair message {} to a request", message); - Iterator it = activeQueues.iterator(); - while (it.hasNext()) { - final OutboundQueueImpl queue = it.next(); - final OutboundQueueEntry entry = queue.pairRequest(message); - - if (entry == null) { - continue; - } - - LOG.trace("Queue {} accepted response {}", queue, message); - - // This has been a barrier request, we need to flush all - // previous queues - if (entry.isBarrier() && activeQueues.size() > 1) { - LOG.trace("Queue {} indicated request was a barrier", queue); - - it = activeQueues.iterator(); - while (it.hasNext()) { - final OutboundQueueImpl q = it.next(); - - // We want to complete all queues before the current one, we will - // complete the current queue below - if (!queue.equals(q)) { - LOG.trace("Queue {} is implied finished", q); - q.completeAll(); - it.remove(); - slice.putQueue(q); - } else { - break; - } - } - } - - if (queue.isFinished()) { - LOG.trace("Queue {} is finished", queue); - it.remove(); - slice.putQueue(queue); - } - - return true; - } - - LOG.debug("Failed to find completion for message {}", message); - return false; + return currentQueue.pairRequest(message); } private void scheduleFlush() { @@ -255,18 +142,13 @@ private void scheduleFlush() { } } - void ensureFlushing(final OutboundQueueImpl queue) { - Preconditions.checkState(currentQueue.equals(queue)); - scheduleFlush(); - } - /** * Periodic barrier check. */ protected void barrier() { LOG.debug("Channel {} barrier timer expired", parent.getChannel()); barrierTimerEnabled = false; - if (shutdownOffset != null) { + if (shuttingDown) { LOG.trace("Channel shut down, not processing barrier"); return; } @@ -301,31 +183,19 @@ private void rescheduleFlush() { conditionalFlush(); } - private void shutdownFlush() { - long entries = 0; - - // Fail all queues - final Iterator it = activeQueues.iterator(); - while (it.hasNext()) { - final OutboundQueueImpl queue = it.next(); + private void writeAndFlush() { + final long start = System.nanoTime(); - entries += queue.failAll(OutboundQueueException.DEVICE_DISCONNECTED); - if (queue.isFinished()) { - LOG.trace("Cleared queue {}", queue); - it.remove(); - } + final int entries = currentQueue.writeEntries(parent.getChannel(), start); + if (entries > 0) { + LOG.debug("Flushing channel {}", parent.getChannel()); + parent.getChannel().flush(); } - LOG.debug("Cleared {} queue entries from channel {}", entries, parent.getChannel()); - - Preconditions.checkNotNull(currentQueue, "Current queue should not be null yet"); - if (currentQueue.isShutdown(shutdownOffset)) { - currentQueue = null; - handler.onConnectionQueueChanged(null); - LOG.debug("Channel {} shutdown complete", parent.getChannel()); - } else { - LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); - rescheduleFlush(); + if (LOG.isDebugEnabled()) { + final long stop = System.nanoTime(); + LOG.debug("Flushed {} messages to channel {} in {}us", entries, + parent.getChannel(), TimeUnit.NANOSECONDS.toMicros(stop - start)); } } @@ -336,61 +206,17 @@ private void shutdownFlush() { */ protected void flush() { // If the channel is gone, just flush whatever is not completed - if (shutdownOffset != null) { - shutdownFlush(); - return; - } - - final long start = System.nanoTime(); - final long deadline = start + maxWorkTime; - - LOG.debug("Dequeuing messages to channel {}", parent.getChannel()); - - long messages = 0; - for (;; ++messages) { - if (!parent.getChannel().isWritable()) { - LOG.debug("Channel {} is no longer writable", parent.getChannel()); - break; - } - - final OfHeader message = flushEntry(start); - if (message == null) { - LOG.trace("The queue is completely drained"); - break; - } - - final Object wrapper; - if (address == null) { - wrapper = new MessageListenerWrapper(message, null); - } else { - wrapper = new UdpMessageListenerWrapper(message, null, address); - } - parent.getChannel().write(wrapper); - - /* - * Check every WORKTIME_RECHECK_MSGS for exceeded time. - * - * XXX: given we already measure our flushing throughput, we - * should be able to perform dynamic adjustments here. - * is that additional complexity needed, though? - */ - if ((messages % WORKTIME_RECHECK_MSGS) == 0 && System.nanoTime() >= deadline) { - LOG.trace("Exceeded allotted work time {}us", - TimeUnit.NANOSECONDS.toMicros(maxWorkTime)); - break; - } - } - - if (messages > 0) { - LOG.debug("Flushing {} message(s) to channel {}", messages, parent.getChannel()); - parent.getChannel().flush(); + if (!shuttingDown) { + LOG.debug("Dequeuing messages to channel {}", parent.getChannel()); + writeAndFlush(); + rescheduleFlush(); + } else if (currentQueue.finishShutdown()) { + handler.onConnectionQueueChanged(null); + LOG.debug("Channel {} shutdown complete", parent.getChannel()); + } else { + LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); + rescheduleFlush(); } - - final long stop = System.nanoTime(); - LOG.debug("Flushed {} messages in {}us to channel {}", - messages, TimeUnit.NANOSECONDS.toMicros(stop - start), parent.getChannel()); - - rescheduleFlush(); } /** @@ -399,7 +225,7 @@ protected void flush() { */ private void conditionalFlush() { if (currentQueue.needsFlush()) { - if (shutdownOffset != null || parent.getChannel().isWritable()) { + if (shuttingDown || parent.getChannel().isWritable()) { scheduleFlush(); } else { LOG.debug("Channel {} is not I/O ready, not scheduling a flush", parent.getChannel()); @@ -409,15 +235,10 @@ private void conditionalFlush() { } } - private void conditionalFlush(final ChannelHandlerContext ctx) { - Preconditions.checkState(ctx.channel().equals(parent.getChannel()), "Inconsistent channel %s with context %s", parent.getChannel(), ctx); - conditionalFlush(); - } - @Override public void channelActive(final ChannelHandlerContext ctx) throws Exception { super.channelActive(ctx); - conditionalFlush(ctx); + conditionalFlush(); } public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { @@ -437,6 +258,8 @@ public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { super.channelWritabilityChanged(ctx); + // A simple trade-off. While we could write things right away, if there is a task + // schedule, let it have the work if (flushScheduled.compareAndSet(false, true)) { LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); flush(); @@ -449,34 +272,113 @@ public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Ex public void channelInactive(final ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); - LOG.debug("Channel {} initiating shutdown...", parent.getChannel()); + LOG.debug("Channel {} initiating shutdown...", ctx.channel()); - /* - * We are dealing with a multi-threaded shutdown, as the user may still - * be reserving entries in the queue. We are executing in a netty thread, - * so neither flush nor barrier can be running, which is good news. - * - * We will eat up all the slots in the queue here and mark the offset first - * reserved offset and free up all the cached queues. We then schedule - * the flush task, which will deal with the rest of the shutdown process. - */ - shutdownOffset = currentQueue.startShutdown(); - if (slice != null) { - slice.decRef(); - slice = null; - } + shuttingDown = true; + final long entries = currentQueue.startShutdown(ctx.channel()); + LOG.debug("Cleared {} queue entries from channel {}", entries, ctx.channel()); - LOG.trace("Channel {} reserved all entries at offset {}", parent.getChannel(), shutdownOffset); scheduleFlush(); } + @Override + public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { + // non-volatile read if we are called multiple times + if (!alreadyReading) { + alreadyReading = true; + reading = true; + } + super.channelRead(ctx, msg); + } + + @Override + public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception { + super.channelReadComplete(ctx); + alreadyReading = false; + reading = false; + + // TODO: model this as an atomic gate. We need to sync on it to make sure + // that ensureFlushing() suppresses scheudling only if this barrier + // has not been crossed. + synchronized (this) { + // Run flush regardless of writability. This is not strictly required, as + // there may be a scheduled flush. Instead of canceling it, which is expensive, + // we'll steal its work. Note that more work may accumulate in the time window + // between now and when the task will run, so it may not be a no-op after all. + // + // The reason for this is to will the output buffer before we go into selection + // phase. This will make sure the pipe is full (in which case our next wake up + // will be the queue becoming writable). + writeAndFlush(); + } + + LOG.debug("Opportunistic write on channel {}", parent.getChannel()); + writeAndFlush(); + } + @Override public String toString() { return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get()); } + void ensureFlushing() { + // If the channel is not writable, there's no point in waking up, + // once we become writable, we will run a full flush + if (!parent.getChannel().isWritable()) { + return; + } + + // We are currently reading something, just a quick sync to ensure we will in fact + // flush state. + if (reading) { + synchronized (this) { + if (reading) { + return; + } + } + } + + // Netty thread is outside our code, we need to schedule a flush + // to re-synchronize. + scheduleFlush(); + } + void onEchoRequest(final EchoRequestMessage message) { final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()).setVersion(message.getVersion()).setXid(message.getXid()).build(); parent.getChannel().writeAndFlush(reply); } + + /** + * Write a message into the underlying channel. + * + * @param now Time reference for 'now'. We take this as an argument, as + * we need a timestamp to mark barrier messages we see swinging + * by. That timestamp does not need to be completely accurate, + * hence we use the flush start time. Alternative would be to + * measure System.nanoTime() for each barrier -- needlessly + * adding overhead. + */ + void writeMessage(final OfHeader message, final long now) { + final Object wrapper; + if (address == null) { + wrapper = new MessageListenerWrapper(message, null); + } else { + wrapper = new UdpMessageListenerWrapper(message, null, address); + } + parent.getChannel().write(wrapper); + + if (message instanceof BarrierInput) { + LOG.trace("Barrier message seen, resetting counters"); + nonBarrierMessages = 0; + lastBarrierNanos = now; + } else { + nonBarrierMessages++; + if (nonBarrierMessages >= maxNonBarrierMessages) { + LOG.trace("Scheduled barrier request after {} non-barrier messages", nonBarrierMessages); + scheduleBarrierMessage(); + } else if (!barrierTimerEnabled) { + scheduleBarrierTimer(now); + } + } + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java new file mode 100644 index 00000000..3c3ceee3 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -0,0 +1,351 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import com.google.common.base.Verify; +import com.google.common.util.concurrent.FutureCallback; +import io.netty.channel.Channel; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import javax.annotation.Nonnull; +import javax.annotation.concurrent.GuardedBy; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class StackedOutboundQueue implements OutboundQueue { + private static final Logger LOG = LoggerFactory.getLogger(StackedOutboundQueue.class); + private static final AtomicLongFieldUpdater BARRIER_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "barrierXid"); + private static final AtomicLongFieldUpdater LAST_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "lastXid"); + + @GuardedBy("unflushedSegments") + private volatile StackedSegment firstSegment; + @GuardedBy("unflushedSegments") + private final List unflushedSegments = new ArrayList<>(2); + @GuardedBy("unflushedSegments") + private final List uncompletedSegments = new ArrayList<>(2); + private final OutboundQueueManager manager; + + private volatile long lastXid = -1; + private volatile long barrierXid = -1; + + @GuardedBy("unflushedSegments") + private Integer shutdownOffset; + + // Accessed from Netty only + private int flushOffset; + + StackedOutboundQueue(final OutboundQueueManager manager) { + this.manager = Preconditions.checkNotNull(manager); + firstSegment = StackedSegment.create(0L); + uncompletedSegments.add(firstSegment); + unflushedSegments.add(firstSegment); + } + + @GuardedBy("unflushedSegments") + private void ensureSegment(final StackedSegment first, final int offset) { + final int segmentOffset = offset / StackedSegment.SEGMENT_SIZE; + LOG.debug("Queue {} slow offset {} maps to {} segments {}", this, offset, segmentOffset, unflushedSegments.size()); + + for (int i = unflushedSegments.size(); i <= segmentOffset; ++i) { + final StackedSegment newSegment = StackedSegment.create(first.getBaseXid() + (StackedSegment.SEGMENT_SIZE * i)); + LOG.debug("Adding segment {}", newSegment); + unflushedSegments.add(newSegment); + } + } + + /* + * This method is expected to be called from multiple threads concurrently. + */ + @Override + public Long reserveEntry() { + final long xid = LAST_XID_UPDATER.incrementAndGet(this); + final StackedSegment fastSegment = firstSegment; + + if (xid >= fastSegment.getBaseXid() + StackedSegment.SEGMENT_SIZE) { + LOG.debug("Queue {} falling back to slow reservation for XID {}", this, xid); + + // Multiple segments, this a slow path + synchronized (unflushedSegments) { + LOG.debug("Queue {} executing slow reservation for XID {}", this, xid); + + // Shutdown was scheduled, need to fail the reservation + if (shutdownOffset != null) { + LOG.debug("Queue {} is being shutdown, failing reservation", this); + return null; + } + + // Ensure we have the appropriate segment for the specified XID + final StackedSegment slowSegment = firstSegment; + final int slowOffset = (int) (xid - slowSegment.getBaseXid()); + Verify.verify(slowOffset >= 0); + + // Now, we let's see if we need to allocate a new segment + ensureSegment(slowSegment, slowOffset); + + LOG.debug("Queue {} slow reservation finished", this); + } + } + + LOG.trace("Queue {} allocated XID {}", this, xid); + return xid; + } + + /* + * This method is expected to be called from multiple threads concurrently + */ + @Override + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + final StackedSegment fastSegment = firstSegment; + final long calcOffset = xid - fastSegment.getBaseXid(); + Preconditions.checkArgument(calcOffset >= 0, "Commit of XID %s does not match up with base XID %s", xid, fastSegment.getBaseXid()); + + Verify.verify(calcOffset <= Integer.MAX_VALUE); + final int fastOffset = (int) calcOffset; + + final OutboundQueueEntry entry; + if (fastOffset >= StackedSegment.SEGMENT_SIZE) { + LOG.debug("Queue {} falling back to slow commit of XID {} at offset {}", this, xid, fastOffset); + + final StackedSegment segment; + final int slowOffset; + synchronized (unflushedSegments) { + final StackedSegment slowSegment = firstSegment; + final long slowCalcOffset = xid - slowSegment.getBaseXid(); + Verify.verify(slowCalcOffset >= 0 && slowCalcOffset <= Integer.MAX_VALUE); + slowOffset = (int) slowCalcOffset; + + LOG.debug("Queue {} recalculated offset of XID {} to {}", this, xid, slowOffset); + segment = unflushedSegments.get(slowOffset / StackedSegment.SEGMENT_SIZE); + } + + final int segOffset = slowOffset % StackedSegment.SEGMENT_SIZE; + entry = segment.getEntry(segOffset); + LOG.debug("Queue {} slow commit of XID {} completed at offset {} (segment {} offset {})", this, xid, slowOffset, segment, segOffset); + } else { + entry = fastSegment.getEntry(fastOffset); + } + + entry.commit(message, callback); + if (entry.isBarrier()) { + long my = xid; + for (;;) { + final long prev = BARRIER_XID_UPDATER.getAndSet(this, my); + if (prev < my) { + LOG.debug("Queue {} recorded pending barrier XID {}", this, my); + break; + } + + // We have traveled back, recover + LOG.debug("Queue {} retry pending barrier {} >= {}", this, prev, my); + my = prev; + } + } + + LOG.trace("Queue {} committed XID {}", this, xid); + manager.ensureFlushing(); + } + + /** + * Write some entries from the queue to the channel. Guaranteed to run + * in the corresponding EventLoop. + * + * @param channel Channel onto which we are writing + * @param now + * @return Number of entries written out + */ + int writeEntries(@Nonnull final Channel channel, final long now) { + // Local cache + StackedSegment segment = firstSegment; + int entries = 0; + + while (channel.isWritable()) { + final OutboundQueueEntry entry = segment.getEntry(flushOffset); + if (!entry.isCommitted()) { + LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset); + break; + } + + LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset); + final OfHeader message = entry.takeMessage(); + flushOffset++; + entries++; + + if (message != null) { + manager.writeMessage(message, now); + } else { + entry.complete(null); + } + + if (flushOffset >= StackedSegment.SEGMENT_SIZE) { + /* + * Slow path: purge the current segment unless it's the last one. + * If it is, we leave it for replacement when a new reservation + * is run on it. + * + * This costs us two slow paths, but hey, this should be very rare, + * so let's keep things simple. + */ + synchronized (unflushedSegments) { + LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size()); + + // We may have raced ahead of reservation code and need to allocate a segment + ensureSegment(segment, flushOffset); + + // Remove the segment, update the firstSegment and reset flushOffset + final StackedSegment oldSegment = unflushedSegments.remove(0); + if (oldSegment.isComplete()) { + uncompletedSegments.remove(oldSegment); + oldSegment.recycle(); + } + + // Reset the first segment and add it to the uncompleted list + segment = unflushedSegments.get(0); + uncompletedSegments.add(segment); + + // Update the shutdown offset + if (shutdownOffset != null) { + shutdownOffset -= StackedSegment.SEGMENT_SIZE; + } + + // Allow reservations back on the fast path by publishing the new first segment + firstSegment = segment; + + flushOffset = 0; + LOG.debug("Queue {} flush moved to segment {}", this, segment); + } + } + } + + return entries; + } + + Long reserveBarrierIfNeeded() { + final long bXid = barrierXid; + final long fXid = firstSegment.getBaseXid() + flushOffset; + if (bXid >= fXid) { + LOG.debug("Barrier found at XID {} (currently at {})", bXid, fXid); + return null; + } else { + return reserveEntry(); + } + } + + boolean pairRequest(final OfHeader message) { + Iterator it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment queue = it.next(); + final OutboundQueueEntry entry = queue.pairRequest(message); + if (entry == null) { + continue; + } + + LOG.trace("Queue {} accepted response {}", queue, message); + + // This has been a barrier request, we need to flush all + // previous queues + if (entry.isBarrier() && uncompletedSegments.size() > 1) { + LOG.trace("Queue {} indicated request was a barrier", queue); + + it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment q = it.next(); + + // We want to complete all queues before the current one, we will + // complete the current queue below + if (!queue.equals(q)) { + LOG.trace("Queue {} is implied finished", q); + q.completeAll(); + it.remove(); + q.recycle(); + } else { + break; + } + } + } + + if (queue.isComplete()) { + LOG.trace("Queue {} is finished", queue); + it.remove(); + queue.recycle(); + } + + return true; + } + + LOG.debug("Failed to find completion for message {}", message); + return false; + } + + long startShutdown(final Channel channel) { + /* + * We are dealing with a multi-threaded shutdown, as the user may still + * be reserving entries in the queue. We are executing in a netty thread, + * so neither flush nor barrier can be running, which is good news. + * + * We will eat up all the slots in the queue here and mark the offset first + * reserved offset and free up all the cached queues. We then schedule + * the flush task, which will deal with the rest of the shutdown process. + */ + synchronized (unflushedSegments) { + // Increment the offset by the segment size, preventing fast path allocations, + // since we are holding the slow path lock, any reservations will see the queue + // in shutdown and fail accordingly. + final long xid = LAST_XID_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); + shutdownOffset = (int) (xid - firstSegment.getBaseXid() - StackedSegment.SEGMENT_SIZE); + + return lockedShutdownFlush(); + } + } + + @GuardedBy("unflushedSegments") + private long lockedShutdownFlush() { + long entries = 0; + + // Fail all queues + final Iterator it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment segment = it.next(); + + entries += segment.failAll(OutboundQueueException.DEVICE_DISCONNECTED); + if (segment.isComplete()) { + LOG.trace("Cleared segment {}", segment); + it.remove(); + } + } + + return entries; + } + + boolean finishShutdown() { + synchronized (unflushedSegments) { + lockedShutdownFlush(); + } + + return !needsFlush(); + } + + boolean needsFlush() { + // flushOffset always points to the first entry, which can be changed only + // from Netty, so we are fine here. + if (firstSegment.getBaseXid() + flushOffset > lastXid) { + return false; + } + + if (shutdownOffset != null && flushOffset >= shutdownOffset) { + return false; + } + + return firstSegment.getEntry(flushOffset).isCommitted(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java new file mode 100644 index 00000000..23bdb0be --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.FinalizableReferenceQueue; +import com.google.common.base.FinalizableSoftReference; +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.base.Verify; +import java.lang.ref.Reference; +import java.util.concurrent.ConcurrentLinkedDeque; +import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class StackedSegment { + private static final class QueueRef extends FinalizableSoftReference { + QueueRef(final FinalizableReferenceQueue queue, final OutboundQueueEntry[] referent) { + super(referent, queue); + } + + @Override + public void finalizeReferent() { + CACHE.remove(this); + } + } + + /** + * Size of each individual segment + */ + static final int SEGMENT_SIZE = 4096; + + private static final Logger LOG = LoggerFactory.getLogger(StackedSegment.class); + private static final FinalizableReferenceQueue REF_QUEUE = new FinalizableReferenceQueue(); + private static final ConcurrentLinkedDeque CACHE = new ConcurrentLinkedDeque<>(); + + private final OutboundQueueEntry[] entries; + private final long baseXid; + private final long endXid; + + // Updated from netty only + private int lastBarrierOffset = -1; + private int completeCount; + + StackedSegment(final long baseXid, final OutboundQueueEntry[] entries) { + this.baseXid = baseXid; + this.endXid = baseXid + SEGMENT_SIZE; + this.entries = Preconditions.checkNotNull(entries); + } + + static StackedSegment create(final long baseXid) { + final StackedSegment ret; + for (;;) { + final Reference item = CACHE.pollLast(); + if (item == null) { + break; + } + + final OutboundQueueEntry[] cached = item.get(); + if (cached != null) { + ret = new StackedSegment(baseXid, cached); + LOG.trace("Reusing array {} in segment {}", cached, ret); + return ret; + } + } + + final OutboundQueueEntry[] entries = new OutboundQueueEntry[SEGMENT_SIZE]; + for (int i = 0; i < SEGMENT_SIZE; ++i) { + entries[i] = new OutboundQueueEntry(); + } + + ret = new StackedSegment(baseXid, entries); + LOG.trace("Allocated new segment {}", ret); + return ret; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("baseXid", baseXid).add("endXid", endXid).add("completeCount", completeCount).toString(); + } + + long getBaseXid() { + return baseXid; + } + + OutboundQueueEntry getEntry(final int offset) { + return entries[offset]; + } + + private boolean xidInRange(final long xid) { + return xid < endXid && (xid >= baseXid || baseXid > endXid); + } + + private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) { + if (response instanceof Error) { + final Error err = (Error)response; + LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString()); + entry.fail(new DeviceRequestFailedException("Device-side failure", err)); + return true; + } else { + return entry.complete(response); + } + } + + OutboundQueueEntry pairRequest(final OfHeader response) { + // Explicitly 'long' to force unboxing before performing operations + final long xid = response.getXid(); + if (!xidInRange(xid)) { + LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, entries.length, xid); + return null; + } + + final int offset = (int)(xid - baseXid); + final OutboundQueueEntry entry = entries[offset]; + if (entry.isCompleted()) { + LOG.debug("Entry {} already is completed, not accepting response {}", entry, response); + return null; + } + + if (entry.isBarrier()) { + // This has been a barrier -- make sure we complete all preceding requests. + // XXX: Barriers are expected to complete in one message. + // If this assumption is changed, this logic will need to be expanded + // to ensure that the requests implied by the barrier are reported as + // completed *after* the barrier. + LOG.trace("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1); + completeRequests(offset); + lastBarrierOffset = offset; + + final boolean success = completeEntry(entry, response); + Verify.verify(success, "Barrier request failed to complete"); + completeCount++; + } else if (completeEntry(entry, response)) { + completeCount++; + } + + return entry; + } + + private void completeRequests(final int toOffset) { + for (int i = lastBarrierOffset + 1; i < toOffset; ++i) { + final OutboundQueueEntry entry = entries[i]; + if (!entry.isCompleted() && entry.complete(null)) { + completeCount++; + } + } + } + + void completeAll() { + completeRequests(entries.length); + } + + int failAll(final OutboundQueueException cause) { + int ret = 0; + for (int i = lastBarrierOffset + 1; i < entries.length; ++i) { + final OutboundQueueEntry entry = entries[i]; + if (!entry.isCommitted()) { + break; + } + + if (!entry.isCompleted()) { + entry.fail(cause); + ret++; + } + } + + return ret; + } + + boolean isComplete() { + return completeCount >= entries.length; + } + + void recycle() { + for (OutboundQueueEntry e : entries) { + e.reset(); + } + + CACHE.offer(new QueueRef(REF_QUEUE, entries)); + } +} From 572484ff9330d12545769f9f14ec6083f94182e7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 6 Jun 2015 04:02:50 +0200 Subject: [PATCH 188/285] Speed up StackedOutboundQueue.reserve() In the case of multiple segments being present, we do not need to completely synchronize if the corresponding segment has already been allocated. Communicate this fact when allocating segments and check this flag before embarking on the entire synchronized affair during reserve(). Change-Id: I10a9ecb141f619b94a20d74152124134d36591b1 Signed-off-by: Robert Varga (cherry picked from commit 45547dc0381407ec537a924447ff9ce0d01890b2) --- .../core/connection/StackedOutboundQueue.java | 41 +++++++++++-------- .../impl/core/connection/StackedSegment.java | 4 ++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index 3c3ceee3..efe71aa7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -36,8 +36,9 @@ final class StackedOutboundQueue implements OutboundQueue { private final List uncompletedSegments = new ArrayList<>(2); private final OutboundQueueManager manager; - private volatile long lastXid = -1; + private volatile long allocatedXid = -1; private volatile long barrierXid = -1; + private volatile long lastXid = -1; @GuardedBy("unflushedSegments") private Integer shutdownOffset; @@ -62,6 +63,8 @@ private void ensureSegment(final StackedSegment first, final int offset) { LOG.debug("Adding segment {}", newSegment); unflushedSegments.add(newSegment); } + + allocatedXid = uncompletedSegments.get(uncompletedSegments.size() - 1).getEndXid(); } /* @@ -73,27 +76,31 @@ public Long reserveEntry() { final StackedSegment fastSegment = firstSegment; if (xid >= fastSegment.getBaseXid() + StackedSegment.SEGMENT_SIZE) { - LOG.debug("Queue {} falling back to slow reservation for XID {}", this, xid); + if (xid >= allocatedXid) { + // Multiple segments, this a slow path + LOG.debug("Queue {} falling back to slow reservation for XID {}", this, xid); - // Multiple segments, this a slow path - synchronized (unflushedSegments) { - LOG.debug("Queue {} executing slow reservation for XID {}", this, xid); + synchronized (unflushedSegments) { + LOG.debug("Queue {} executing slow reservation for XID {}", this, xid); - // Shutdown was scheduled, need to fail the reservation - if (shutdownOffset != null) { - LOG.debug("Queue {} is being shutdown, failing reservation", this); - return null; - } + // Shutdown was scheduled, need to fail the reservation + if (shutdownOffset != null) { + LOG.debug("Queue {} is being shutdown, failing reservation", this); + return null; + } - // Ensure we have the appropriate segment for the specified XID - final StackedSegment slowSegment = firstSegment; - final int slowOffset = (int) (xid - slowSegment.getBaseXid()); - Verify.verify(slowOffset >= 0); + // Ensure we have the appropriate segment for the specified XID + final StackedSegment slowSegment = firstSegment; + final int slowOffset = (int) (xid - slowSegment.getBaseXid()); + Verify.verify(slowOffset >= 0); - // Now, we let's see if we need to allocate a new segment - ensureSegment(slowSegment, slowOffset); + // Now, we let's see if we need to allocate a new segment + ensureSegment(slowSegment, slowOffset); - LOG.debug("Queue {} slow reservation finished", this); + LOG.debug("Queue {} slow reservation finished", this); + } + } else { + LOG.debug("Queue {} XID {} is already backed", this, xid); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java index 23bdb0be..b9030b81 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java @@ -91,6 +91,10 @@ long getBaseXid() { return baseXid; } + long getEndXid() { + return endXid; + } + OutboundQueueEntry getEntry(final int offset) { return entries[offset]; } From b4e36fcd1964dc3d5cb3ff8c7ca32bd4bee9982e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 6 Jun 2015 02:31:01 +0200 Subject: [PATCH 189/285] Improve OutboundQueueManager IO patterns Channel state is tracked internally, which means we can forgo a synchronized block. This is done by introducing three explicit states, READING, WRITING, IDLE, which allow more optimal task scheduling. Change-Id: Ief00abe8aa4e90e85ca0c98bc908e481a7eaab7c Signed-off-by: Robert Varga (cherry picked from commit e1e4d30f9c07a7b7db7a63e9f350bba4e758e564) --- .../core/connection/OutboundQueueManager.java | 96 +++++++++++-------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index dc378164..6e07a6dd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -23,6 +23,24 @@ import org.slf4j.LoggerFactory; final class OutboundQueueManager extends ChannelInboundHandlerAdapter implements AutoCloseable { + private static enum PipelineState { + /** + * Netty thread is potentially idle, no assumptions + * can be made about its state. + */ + IDLE, + /** + * Netty thread is currently reading, once the read completes, + * if will flush the queue in the {@link #FLUSHING} state. + */ + READING, + /** + * Netty thread is currently performing a flush on the queue. + * It will then transition to {@link #IDLE} state. + */ + WRITING, + } + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueManager.class); /** @@ -46,7 +64,7 @@ final class OutboundQueueManager extends Channel private final T handler; // Accessed concurrently - private volatile boolean reading; + private volatile PipelineState state = PipelineState.IDLE; // Updated from netty only private boolean alreadyReading; @@ -184,11 +202,13 @@ private void rescheduleFlush() { } private void writeAndFlush() { + state = PipelineState.WRITING; + final long start = System.nanoTime(); final int entries = currentQueue.writeEntries(parent.getChannel(), start); if (entries > 0) { - LOG.debug("Flushing channel {}", parent.getChannel()); + LOG.trace("Flushing channel {}", parent.getChannel()); parent.getChannel().flush(); } @@ -197,6 +217,8 @@ private void writeAndFlush() { LOG.debug("Flushed {} messages to channel {} in {}us", entries, parent.getChannel(), TimeUnit.NANOSECONDS.toMicros(stop - start)); } + + state = PipelineState.IDLE; } /** @@ -207,7 +229,7 @@ private void writeAndFlush() { protected void flush() { // If the channel is gone, just flush whatever is not completed if (!shuttingDown) { - LOG.debug("Dequeuing messages to channel {}", parent.getChannel()); + LOG.trace("Dequeuing messages to channel {}", parent.getChannel()); writeAndFlush(); rescheduleFlush(); } else if (currentQueue.finishShutdown()) { @@ -258,14 +280,11 @@ public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { super.channelWritabilityChanged(ctx); - // A simple trade-off. While we could write things right away, if there is a task - // schedule, let it have the work - if (flushScheduled.compareAndSet(false, true)) { - LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); - flush(); - } else { - LOG.debug("Channel {} Writability changed, but task is already scheduled", parent.getChannel()); - } + // The channel is writable again. There may be a flush task on the way, but let's + // steal its work, potentially decreasing latency. Since there is a window between + // now and when it will run, it may still pick up some more work to do. + LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); + writeAndFlush(); } @Override @@ -283,10 +302,13 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { @Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { - // non-volatile read if we are called multiple times + // Netty does not provide a 'start reading' callback, so this is our first + // (and repeated) chance to detect reading. Since this callback can be invoked + // multiple times, we keep a boolean we check. That prevents a volatile write + // on repeated invocations. It will be cleared in channelReadComplete(). if (!alreadyReading) { alreadyReading = true; - reading = true; + state = PipelineState.READING; } super.channelRead(ctx, msg); } @@ -294,25 +316,15 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) throw @Override public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception { super.channelReadComplete(ctx); - alreadyReading = false; - reading = false; - - // TODO: model this as an atomic gate. We need to sync on it to make sure - // that ensureFlushing() suppresses scheudling only if this barrier - // has not been crossed. - synchronized (this) { - // Run flush regardless of writability. This is not strictly required, as - // there may be a scheduled flush. Instead of canceling it, which is expensive, - // we'll steal its work. Note that more work may accumulate in the time window - // between now and when the task will run, so it may not be a no-op after all. - // - // The reason for this is to will the output buffer before we go into selection - // phase. This will make sure the pipe is full (in which case our next wake up - // will be the queue becoming writable). - writeAndFlush(); - } - LOG.debug("Opportunistic write on channel {}", parent.getChannel()); + // Run flush regardless of writability. This is not strictly required, as + // there may be a scheduled flush. Instead of canceling it, which is expensive, + // we'll steal its work. Note that more work may accumulate in the time window + // between now and when the task will run, so it may not be a no-op after all. + // + // The reason for this is to will the output buffer before we go into selection + // phase. This will make sure the pipe is full (in which case our next wake up + // will be the queue becoming writable). writeAndFlush(); } @@ -330,17 +342,19 @@ void ensureFlushing() { // We are currently reading something, just a quick sync to ensure we will in fact // flush state. - if (reading) { - synchronized (this) { - if (reading) { - return; - } - } + final PipelineState localState = state; + LOG.debug("Synchronize on pipeline state {}", localState); + switch (localState) { + case READING: + // Netty thread is currently reading, it will flush the pipeline once it + // finishes reading. This is a no-op situation. + break; + case WRITING: + case IDLE: + default: + // We cannot rely on the change being flushed, schedule a request + scheduleFlush(); } - - // Netty thread is outside our code, we need to schedule a flush - // to re-synchronize. - scheduleFlush(); } void onEchoRequest(final EchoRequestMessage message) { From d44b200a734612a3030250b02fa25f6d89cfb915 Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Wed, 1 Jul 2015 09:38:45 +0200 Subject: [PATCH 190/285] BUG-3907: openflow-plugin-api does not build with jdk8 - added missing docs - fixed misformed docs Change-Id: I8eb131e7b0510718a4690b69094bb27907b79c41 Signed-off-by: Michal Rehak (cherry picked from commit 0fe8e47a8d82d19583ebfd5d191367e803b22384) --- .../protocol/api/connection/ConnectionAdapter.java | 11 +++++++---- .../protocol/api/connection/OutboundQueue.java | 4 ++-- .../api/connection/SwitchConnectionHandler.java | 2 +- .../api/extensibility/DeserializerRegistry.java | 1 + .../extensibility/DeserializerRegistryInjector.java | 2 +- .../api/extensibility/EnhancedMessageTypeKey.java | 6 +++--- .../api/extensibility/HeaderDeserializer.java | 3 +-- .../protocol/api/extensibility/HeaderSerializer.java | 5 ++--- .../extensibility/SerializerExtensionProvider.java | 2 ++ .../api/extensibility/SerializerRegistry.java | 4 ++++ .../api/keys/ExperimenterIdDeserializerKey.java | 1 + .../keys/ExperimenterInstructionDeserializerKey.java | 2 +- .../protocol/api/keys/InstructionDeserializerKey.java | 2 +- .../openflowjava/protocol/api/util/BinContent.java | 6 +++--- 14 files changed, 30 insertions(+), 21 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 443dea57..89cd461f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -57,13 +57,15 @@ public interface ConnectionAdapter extends OpenflowProtocolService { /** * set listener for connection became ready-to-use event - * @param connectionReadyListener + * @param connectionReadyListener listens to connection ready event */ void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener); /** * sets option for automatic channel reading; * if set to false, incoming messages won't be read + * + * @param autoRead target value to be switched to */ void setAutoRead(boolean autoRead); @@ -74,9 +76,10 @@ public interface ConnectionAdapter extends OpenflowProtocolService { /** * Registers a new bypass outbound queue - * @param handler - * @param maxQueueDepth - * @param maxBarrierNanos + * @param handler type + * @param handler queue handler + * @param maxQueueDepth max amount of not confirmed messaged in queue (i.e. edge for barrier message) + * @param maxBarrierNanos regular base for barrier message * @return An {@link OutboundQueueHandlerRegistration} */ @Beta diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java index afe5b056..3212078c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java @@ -30,10 +30,10 @@ public interface OutboundQueue { * with a response, the object reported will be non-null. If the request's completion * is implied by a barrier, the object reported will be null. * - * If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable) + * If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable)} * will be called with an instance of {@link DeviceRequestFailedException}. * - * If the request fails due to local reasons, {@link FutureCallback#onFailure(Throwable) + * If the request fails due to local reasons, {@link FutureCallback#onFailure(Throwable)} * will be called with an instance of {@link OutboundQueueException}. In particular, if * this request failed because the device disconnected, {@link OutboundQueueException#DEVICE_DISCONNECTED} * will be reported. diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java index 363e3245..8b4fddf6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/SwitchConnectionHandler.java @@ -24,7 +24,7 @@ public interface SwitchConnectionHandler { void onSwitchConnected(ConnectionAdapter connection); /** - * @param switchAddress + * @param switchAddress address of incoming connection (address + port) * @return true, if connection from switch having given address shell be accepted; false otherwise */ boolean accept(InetAddress switchAddress); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 6970a1dc..27660398 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -22,6 +22,7 @@ public interface DeserializerRegistry { void init(); /** + * @param type of particular deserializer * @param key used for deserializer lookup * @return deserializer found */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java index 0b291af3..98e83633 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java @@ -15,7 +15,7 @@ public interface DeserializerRegistryInjector { /** * Injects deserializer registry into deserializer - * @param deserializerRegistry + * @param deserializerRegistry registry of deserializers */ void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index ec578c6b..3a9fffc2 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -21,9 +21,9 @@ public class EnhancedMessageTypeKey extends MessageTypeKey { private final Class msgType2; /** - * @param msgVersion - * @param msgType - * @param msgType2 + * @param msgVersion protocol version + * @param msgType main type + * @param msgType2 subtype */ public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgType2) { super(msgVersion, msgType); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index 1d105f39..a0fe9391 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -8,12 +8,11 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; import io.netty.buffer.ByteBuf; - import org.opendaylight.yangtools.yang.binding.DataObject; /** * @author michal.polkorab - * @param + * @param output message type */ public interface HeaderDeserializer extends OFGeneralDeserializer { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index 1e047c09..b8b8a029 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -7,14 +7,13 @@ */ package org.opendaylight.openflowjava.protocol.api.extensibility; -import org.opendaylight.yangtools.yang.binding.DataObject; - import io.netty.buffer.ByteBuf; +import org.opendaylight.yangtools.yang.binding.DataObject; /** * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) * @author michal.polkorab - * @param + * @param input message type */ public interface HeaderSerializer extends OFGeneralSerializer { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index 7d83cd82..ebccdad8 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -60,6 +60,8 @@ void registerInstructionSerializer(InstructionSerializerKey key, /** * Registers match entry serializer + * @param oxm type + * @param match field type * @param key used for serializer lookup * @param serializer serializer implementation */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index 7fb39bbd..1ddc4856 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -23,6 +23,8 @@ public interface SerializerRegistry { void init(); /** + * @param input key type + * @param type of resulting serializer * @param msgTypeKey lookup key * @return serializer or NullPointerException if no serializer was found */ @@ -36,6 +38,7 @@ public interface SerializerRegistry { * If the serializer implements {@link SerializerRegistryInjector} interface, * the serializer is injected with SerializerRegistry instance. * + * @param serializer key type * @param key used for serializer lookup * @param serializer serializer implementation */ @@ -44,6 +47,7 @@ void registerSerializer(MessageTypeKey key, /** * Unregisters serializer + * @param serializer key type * @param key used for serializer lookup * @return true if serializer was removed, * false if no serializer was found under specified key diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java index bc16e523..dfc75a8e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java @@ -21,6 +21,7 @@ public final class ExperimenterIdDeserializerKey extends MessageCodeKey private Long experimenterId; /** + * @param type of target experimenter object * @param version protocol wire version * @param experimenterId experimenter / vendor ID * @param objectClass class of created object diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java index 45232a66..eea3e4ef 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionDeserializerKey.java @@ -19,7 +19,7 @@ public final class ExperimenterInstructionDeserializerKey extends InstructionDes /** * @param version protocol wire version - * @param experimenterId + * @param experimenterId experimenter (vendor) identifier */ public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index 3a0bf982..8482f6ef 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -20,7 +20,7 @@ public class InstructionDeserializerKey extends MessageCodeKey { /** * @param version protocol wire version * @param type instruction type - * @param experimenterId + * @param experimenterId experimenter (vendor) identifier */ public InstructionDeserializerKey(short version, int type, Long experimenterId) { diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java index 700fdf4d..995fd350 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/BinContent.java @@ -19,15 +19,15 @@ private BinContent() { } /** - * @param value - * @return int part wrapped in long + * @param value input integer value (might be negative) + * @return int part wrapped in long (always positive) */ public static long intToUnsignedLong(int value) { return value & 0x00000000ffffffffL; } /** - * @param value + * @param value input long value * @return long cut into int */ public static int longToSignedInt(long value) { From eb87025816bac14dec653596ab91c85e4d2a787e Mon Sep 17 00:00:00 2001 From: Matus Marko Date: Thu, 9 Jul 2015 15:25:05 +0200 Subject: [PATCH 191/285] Bug 2875 - fix initiating OFPT_HELLO over SSL from the controller Change-Id: I69a19898c2d4ea916f895d588dc9af20f036e1ef Signed-off-by: Matus Marko --- .gitignore | 3 +++ .../protocol/impl/core/TcpChannelInitializer.java | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1e44f73b..49e9ad86 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ target/ .externalToolBuilders/ maven-eclipse.xml .checkstyle +.idea +*.iws +*.iml diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 43277eaa..3be9f96f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -19,6 +19,8 @@ import javax.net.ssl.SSLEngine; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; @@ -85,7 +87,16 @@ protected void initChannel(final SocketChannel ch) { SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); engine.setNeedClientAuth(true); engine.setUseClientMode(false); - ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), new SslHandler(engine)); + SslHandler ssl = new SslHandler(engine); + Future handshakeFuture = ssl.handshakeFuture(); + final ConnectionFacade finalConnectionFacade = connectionFacade; + handshakeFuture.addListener(new GenericFutureListener>() { + @Override + public void operationComplete(Future future) throws Exception { + finalConnectionFacade.fireConnectionReadyNotification(); + } + }); + ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), ssl); } ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade, tlsPresent)); From 9eaf06441554772d32090e5fc097fd25f353afb5 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Wed, 22 Jul 2015 15:19:15 -0400 Subject: [PATCH 192/285] Explicitly set git-review branch to master Change-Id: I902966c7f4827b152521e95aeacd774c6fe25f9f Signed-off-by: Thanh Ha --- .gitreview | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitreview b/.gitreview index 599a6c42..8968f7fe 100644 --- a/.gitreview +++ b/.gitreview @@ -2,3 +2,4 @@ host=git.opendaylight.org port=29418 project=openflowjava.git +defaultbranch=master From 5a2d3068c20b5063676063c7511256e003cff24a Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Fri, 31 Jul 2015 14:54:36 +0200 Subject: [PATCH 193/285] BUG-4072: Echo reply missing - propper wrapper added at place where OF-message is written into netty channel Change-Id: I4a65cffff946c4f7a1ad8dbc589ab008958c8cf8 Signed-off-by: Michal Rehak --- .../core/connection/OutboundQueueManager.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 6e07a6dd..8e1061b2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -8,8 +8,11 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; +import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -358,8 +361,21 @@ void ensureFlushing() { } void onEchoRequest(final EchoRequestMessage message) { - final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()).setVersion(message.getVersion()).setXid(message.getXid()).build(); - parent.getChannel().writeAndFlush(reply); + final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()) + .setVersion(message.getVersion()).setXid(message.getXid()).build(); + final SimpleRpcListener simpleMsgRpcListener = new SimpleRpcListener(reply, "echo-reply sending failed"); + + final GenericFutureListener> msgProcessListener = simpleMsgRpcListener.takeListener(); + final Object messageListenerWrapper; + if (address == null) { + messageListenerWrapper = new MessageListenerWrapper(simpleMsgRpcListener.takeMessage(), msgProcessListener); + } else { + messageListenerWrapper = new UdpMessageListenerWrapper(simpleMsgRpcListener.takeMessage(), msgProcessListener, address); + } + final ChannelFuture channelFuture = parent.getChannel().writeAndFlush(messageListenerWrapper); + if (msgProcessListener != null) { + channelFuture.addListener(msgProcessListener); + } } /** From 21c082a3e0d6a9e80e729746258e305252b44c49 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sun, 9 Aug 2015 14:10:01 -0400 Subject: [PATCH 194/285] Use odlparent checkstyle.version Change-Id: I2633028a7bb218dadb2faf9c69829702ef5fb790 Signed-off-by: Thanh Ha --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6ebe3748..32d01689 100644 --- a/pom.xml +++ b/pom.xml @@ -129,8 +129,8 @@ org.apache.maven.plugins - maven-checkstyle-plugin - 2.12 + maven-checkstyle-plugin + ${checkstyle.version} false checkstyle-logging.xml From a4d0afddaa49582b6ed5f88651dc8c8d4018f749 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 27 Aug 2015 14:25:33 +0200 Subject: [PATCH 195/285] Introduced openflowjava parent pom.xml Change-Id: I68b321532e494ead49105012401332cc4a5df19c Signed-off-by: Michal Polkorab --- openflow-protocol-api/pom.xml | 3 +- openflow-protocol-impl/pom.xml | 3 +- openflow-protocol-it/pom.xml | 3 +- openflow-protocol-spi/pom.xml | 3 +- openflowjava-config/pom.xml | 3 +- parent/pom.xml | 442 +++++++++++++++++++++++++++++++++ pom.xml | 431 +------------------------------- simple-client/pom.xml | 3 +- util/pom.xml | 3 +- 9 files changed, 462 insertions(+), 432 deletions(-) create mode 100644 parent/pom.xml diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 888ed68f..08986c62 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -3,8 +3,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent openflow-protocol-api bundle diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 0a4f2fe8..0104a1a6 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -2,8 +2,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent openflow-protocol-impl bundle diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 54f586df..436f8bdf 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -2,8 +2,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent openflow-protocol-it bundle diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 5a7432aa..b3cf8d77 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -2,8 +2,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent openflow-protocol-spi bundle diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index ccdb859c..ad7c00fa 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -10,8 +10,9 @@ org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent openflowjava-config Configuration files for openflowjava statistics diff --git a/parent/pom.xml b/parent/pom.xml new file mode 100644 index 00000000..8cff7901 --- /dev/null +++ b/parent/pom.xml @@ -0,0 +1,442 @@ + + + 4.0.0 + + org.opendaylight.odlparent + odlparent + 1.6.0-SNAPSHOT + + + + org.opendaylight.openflowjava + openflowjava-parent + 0.7.0-SNAPSHOT + pom + + + + The Eclipse Public License v1.0 + http://www.eclipse.org/legal/epl-v10.html + repo + + + + + scm:git:ssh://git.opendaylight.org:29418/openflowjava.git + scm:git:ssh://git.opendaylight.org:29418/openflowjava.git + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + dav:http://nexus.opendaylight.org/content/sites/site + UTF-8 + ${project.build.directory}/yang-gen-config + 1.6.0-SNAPSHOT + ${project.build.directory}/yang-gen-sal + + 0.4.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT + + + 2.4 + jacoco + target/code-coverage/jacoco.exec + target/code-coverage/jacoco-it.exec + + + + + + org.opendaylight.openflowjava + openflowjava-artifacts + ${project.version} + pom + import + + + org.opendaylight.yangtools + yangtools-artifacts + ${yangtools.version} + pom + import + + + org.opendaylight.controller + config-artifacts + ${config.version} + pom + import + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + import + pom + + + + + + + + org.codehaus.sonar-plugins.java + sonar-jacoco-listeners + ${sonar-jacoco-listeners.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + true + + 1.7 + 1.7 + + + + maven-source-plugin + + + attach-sources + deploy + + jar-no-fork + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.groupId}.${project.artifactId} + + ${project.build.directory}/META-INF + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${checkstyle.version} + + false + checkstyle-logging.xml + true + true + ${project.basedir} + **\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang + **\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/ + + + + org.opendaylight.yangtools + checkstyle-logging + ${yangtools.version} + + + + + + check + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + org.jacoco + jacoco-maven-plugin + + + prepare-ut-agent + process-test-classes + + prepare-agent + + + ${sonar.jacoco.reportPath} + jacoco.agent.ut.arg + + + + prepare-it-agent + pre-integration-test + + prepare-agent + + + ${sonar.jacoco.itReportPath} + jacoco.agent.it.arg + + + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + + add-source + + generate-sources + + + src/main/yang + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${jacoco.agent.it.arg} + + + listener + org.sonar.java.jacoco.JUnitListener + + + + ${project.build.directory}/surefire-reports + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${jacoco.agent.ut.arg} + + + listener + org.sonar.java.jacoco.JUnitListener + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + properties-maven-plugin + [0.0,) + + set-system-properties + + + + + + + + + org.jacoco + jacoco-maven-plugin + [0.0,) + + prepare-agent + pre-test + post-test + + + + + + + + + org.ops4j.pax.exam + maven-paxexam-plugin + [1.2.4,) + + generate-depends-file + + + + + false + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + [2.0,) + + check + + + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + [0.5,) + + generate-sources + + + + + + + + + org.codehaus.groovy.maven + gmaven-plugin + 1.0 + + execute + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${enforcer.version} + + enforce + + + + + + + + + + + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.5.2 + + Max + Low + site + + + + maven-jxr-plugin + 2.3 + + true + true + + + + + org.codehaus.mojo + jdepend-maven-plugin + 2.0-beta-2 + + + + + + viewbuild + + true + + + ${project.version} + + + + jenkins + + + BUILDSUFFIX + + + + ${BUILDSUFFIX} + + + + repoBuild + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8.1 + + + + aggregate + + site + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + package + + jar-no-fork + + + + + + + + + diff --git a/pom.xml b/pom.xml index 32d01689..e35a9786 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,13 @@ 4.0.0 - org.opendaylight.odlparent - odlparent - 1.6.0-SNAPSHOT - + org.opendaylight.openflowjava + openflowjava-parent + 0.7.0-SNAPSHOT + parent - org.opendaylight.openflowjava - openflow-protocol-parent - 0.7.0-SNAPSHOT + openflowjava-aggregator openflowjava pom @@ -22,425 +20,8 @@ openflow-protocol-impl openflow-protocol-it openflow-protocol-spi + parent simple-client util - - scm:git:ssh://git.opendaylight.org:29418/openflowjava.git - scm:git:ssh://git.opendaylight.org:29418/openflowjava.git - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - - dav:http://nexus.opendaylight.org/content/sites/site - UTF-8 - ${project.build.directory}/yang-gen-config - 1.6.0-SNAPSHOT - ${project.build.directory}/yang-gen-sal - - 0.4.0-SNAPSHOT - 1.3.0-SNAPSHOT - 0.8.0-SNAPSHOT - - - 2.4 - jacoco - target/code-coverage/jacoco.exec - target/code-coverage/jacoco-it.exec - - - - - - org.opendaylight.openflowjava - openflowjava-artifacts - ${project.version} - pom - import - - - org.opendaylight.yangtools - yangtools-artifacts - ${yangtools.version} - pom - import - - - org.opendaylight.controller - config-artifacts - ${config.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${mdsal.version} - import - pom - - - - - - - - org.codehaus.sonar-plugins.java - sonar-jacoco-listeners - ${sonar-jacoco-listeners.version} - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - true - - 1.7 - 1.7 - - - - maven-source-plugin - - - attach-sources - deploy - - jar-no-fork - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.groupId}.${project.artifactId} - - ${project.build.directory}/META-INF - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${checkstyle.version} - - false - checkstyle-logging.xml - true - true - ${project.basedir} - **\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat,**\/*.yang - **\/target\/,**\/bin\/,**\/target-ide\/,**\/src/main/yang-gen-config\/,**\/src/main/yang-gen-sal\/ - - - - org.opendaylight.yangtools - checkstyle-logging - ${yangtools.version} - - - - - - check - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - org.jacoco - jacoco-maven-plugin - - - prepare-ut-agent - process-test-classes - - prepare-agent - - - ${sonar.jacoco.reportPath} - jacoco.agent.ut.arg - - - - prepare-it-agent - pre-integration-test - - prepare-agent - - - ${sonar.jacoco.itReportPath} - jacoco.agent.it.arg - - - - - - - - - org.opendaylight.yangtools - yang-maven-plugin - ${yangtools.version} - - - org.codehaus.mojo - build-helper-maven-plugin - 1.8 - - - add-source - - add-source - - generate-sources - - - src/main/yang - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - ${jacoco.agent.it.arg} - - - listener - org.sonar.java.jacoco.JUnitListener - - - - ${project.build.directory}/surefire-reports - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${jacoco.agent.ut.arg} - - - listener - org.sonar.java.jacoco.JUnitListener - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - properties-maven-plugin - [0.0,) - - set-system-properties - - - - - - - - - org.jacoco - jacoco-maven-plugin - [0.0,) - - prepare-agent - pre-test - post-test - - - - - - - - - org.ops4j.pax.exam - maven-paxexam-plugin - [1.2.4,) - - generate-depends-file - - - - - false - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - [2.0,) - - check - - - - - - - - - org.opendaylight.yangtools - yang-maven-plugin - [0.5,) - - generate-sources - - - - - - - - - org.codehaus.groovy.maven - gmaven-plugin - 1.0 - - execute - - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - ${enforcer.version} - - enforce - - - - - - - - - - - - - - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.5.2 - - Max - Low - site - - - - maven-jxr-plugin - 2.3 - - true - true - - - - - org.codehaus.mojo - jdepend-maven-plugin - 2.0-beta-2 - - - - - - viewbuild - - true - - - ${project.version} - - - - jenkins - - - BUILDSUFFIX - - - - ${BUILDSUFFIX} - - - - repoBuild - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8.1 - - - - aggregate - - site - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - package - - jar-no-fork - - - - - - - - diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 567cdaae..484b3759 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -2,8 +2,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent simple-client bundle diff --git a/util/pom.xml b/util/pom.xml index a05f694a..4d4f3361 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -4,8 +4,9 @@ 4.0.0 org.opendaylight.openflowjava - openflow-protocol-parent + openflowjava-parent 0.7.0-SNAPSHOT + ../parent bundle util From dcac24a922a4dca4cd16084fa9796dd8ba20d234 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Wed, 2 Sep 2015 16:13:31 +0200 Subject: [PATCH 196/285] Migration to use MD-SAL Project Change-Id: I6cc9068df952934d153b328670508aa8e2314628 Signed-off-by: Tony Tkacik --- features/pom.xml | 38 ++++++-- features/src/main/features/features.xml | 15 +-- openflow-protocol-api/pom.xml | 121 +++++++----------------- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- 5 files changed, 74 insertions(+), 104 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 771afeb0..9bb6181a 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -15,8 +15,10 @@ 0.4.0-SNAPSHOT - 1.3.0-SNAPSHOT - 0.8.0-SNAPSHOT + 1.3.0-SNAPSHOT + 2.0.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT @@ -30,11 +32,19 @@ pom - + - org.opendaylight.yangtools - yangtools-artifacts - ${yangtools.version} + org.opendaylight.mdsal + mdsal-artifacts + ${mdsal.version} + import + pom + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${mdsal.model.version} import pom @@ -50,7 +60,7 @@ org.opendaylight.controller mdsal-artifacts - ${mdsal.version} + ${controller.mdsal.version} import pom @@ -61,8 +71,16 @@ - org.opendaylight.yangtools - features-yangtools + org.opendaylight.mdsal + features-mdsal + ${mdsal.version} + features + xml + + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} features xml @@ -75,7 +93,7 @@ org.opendaylight.controller features-mdsal - ${mdsal.version} + ${controller.mdsal.version} features xml diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 1db95530..ad8963a3 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -3,18 +3,19 @@ - mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features - mvn:org.opendaylight.controller/features-config/${config.version}/xml/features - mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features + mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features + mvn:org.opendaylight.controller/features-config/{{VERSION}}/xml/features + mvn:org.opendaylight.mdsal/features-mdsal/{{VERSION}}/xml/features + mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features + mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features odl-openflowjava-protocol - odl-yangtools-common - odl-yangtools-binding - odl-yangtools-models + odl-mdsal-binding-base + odl-mdsal-models odl-config-api - odl-mdsal-common + odl-mdsal-common mvn:io.netty/netty-buffer/{{VERSION}} mvn:io.netty/netty-common/{{VERSION}} mvn:io.netty/netty-transport/{{VERSION}} diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 08986c62..80e5103f 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -2,12 +2,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.opendaylight.openflowjava - openflowjava-parent - 0.7.0-SNAPSHOT - ../parent + org.opendaylight.mdsal + binding-parent + 0.8.0-SNAPSHOT + + org.opendaylight.openflowjava openflow-protocol-api + 0.7.0-SNAPSHOT bundle Openflow Protocol Library - API @@ -15,47 +17,34 @@ HEAD - - - - org.opendaylight.yangtools - yang-maven-plugin - - - - generate-sources - - - src/main/yang - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - - - ${salGeneratorPath} - - - - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl - target/site/restconf - - - true - - - + + 2.0.0-SNAPSHOT + 0.8.0-SNAPSHOT + - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.version} - jar - - - + + + + + org.opendaylight.mdsal + mdsal-artifacts + ${mdsal.version} + import + pom + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${mdsal.model.version} + import + pom + + + + + + - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.opendaylight.yangtools - - - yang-maven-plugin - - - (0.5.6,) - - - - generate-sources - - - - - - - - - - - - - - org.opendaylight.yangtools + org.opendaylight.mdsal yang-binding @@ -145,15 +96,15 @@ yang-common - org.opendaylight.yangtools.model + org.opendaylight.mdsal.model ietf-inet-types - org.opendaylight.yangtools.model + org.opendaylight.mdsal.model ietf-yang-types - org.opendaylight.yangtools.model + org.opendaylight.mdsal.model yang-ext diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 0104a1a6..272c909a 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -72,7 +72,7 @@ ${config.version} - org.opendaylight.yangtools + org.opendaylight.mdsal maven-sal-api-gen-plugin ${yangtools.version} jar diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index b3cf8d77..8ec7ea7e 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -73,7 +73,7 @@ ${config.version} - org.opendaylight.yangtools + org.opendaylight.mdsal maven-sal-api-gen-plugin ${yangtools.version} jar From 3a0d255bcecd1be4226b63787667fefd793a1263 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Tue, 1 Sep 2015 23:46:13 -0400 Subject: [PATCH 197/285] Use odlparent configuration for jacoco Change-Id: I2825a7637eb95e085cbeeb3286e468362c3545b9 Signed-off-by: Thanh Ha --- parent/pom.xml | 74 -------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 8cff7901..e7b1ea4f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -38,12 +38,6 @@ 0.4.0-SNAPSHOT 1.3.0-SNAPSHOT 0.8.0-SNAPSHOT - - - 2.4 - jacoco - target/code-coverage/jacoco.exec - target/code-coverage/jacoco-it.exec @@ -79,16 +73,6 @@ - - - - org.codehaus.sonar-plugins.java - sonar-jacoco-listeners - ${sonar-jacoco-listeners.version} - test - - - @@ -155,34 +139,6 @@ org.codehaus.mojo build-helper-maven-plugin - - org.jacoco - jacoco-maven-plugin - - - prepare-ut-agent - process-test-classes - - prepare-agent - - - ${sonar.jacoco.reportPath} - jacoco.agent.ut.arg - - - - prepare-it-agent - pre-integration-test - - prepare-agent - - - ${sonar.jacoco.itReportPath} - jacoco.agent.it.arg - - - - @@ -210,36 +166,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - ${jacoco.agent.it.arg} - - - listener - org.sonar.java.jacoco.JUnitListener - - - - ${project.build.directory}/surefire-reports - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${jacoco.agent.ut.arg} - - - listener - org.sonar.java.jacoco.JUnitListener - - - - org.eclipse.m2e From a6d3555e8ddccafaa73498b554b19a3197eefb46 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Sat, 3 Oct 2015 12:43:15 +0200 Subject: [PATCH 198/285] Fixed missing prefix in augmentation. Change-Id: Ia210b3c77cd7b593949439aca06e1f7d3bd719bd Signed-off-by: Tony Tkacik --- openflow-protocol-api/src/main/yang/openflow-augments.yang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 34ca8c43..2df9d5b6 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -122,7 +122,7 @@ } // OFP_MULTIPART AUGMENTS - augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { + augment "/ofproto:multipart-request/ofproto:input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { ext:augment-identifier "experimenter-id-multipart-request"; leaf experimenter { type oft:experimenter-id; @@ -148,4 +148,4 @@ type oft:experimenter-id; } } -} \ No newline at end of file +} From 9303ee5ab096289506a6ec453d467b95bb7cf629 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Thu, 8 Oct 2015 04:51:23 +0200 Subject: [PATCH 199/285] Bug 4432 - NPE problem in OFEncode * add check for listener in msg wrapper * add default listener for logging in OutboundQueueManager Change-Id: Ib652d60a210feaddf96840334af3b435e7d0a14f Signed-off-by: Vaclav Demcak --- .../protocol/impl/core/OFEncoder.java | 23 ++++---- .../core/connection/OutboundQueueManager.java | 53 ++++++++++++------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 075b99da..4c54732b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -12,7 +12,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.util.concurrent.Future; - import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.statistics.CounterEventTypes; @@ -28,31 +27,33 @@ */ public class OFEncoder extends MessageToByteEncoder { - private static final Logger LOGGER = LoggerFactory.getLogger(OFEncoder.class); + private static final Logger LOG = LoggerFactory.getLogger(OFEncoder.class); private SerializationFactory serializationFactory; - private StatisticsCounters statisticsCounters; + private final StatisticsCounters statisticsCounters; /** Constructor of class */ public OFEncoder() { statisticsCounters = StatisticsCounters.getInstance(); - LOGGER.trace("Creating OF13Encoder"); + LOG.trace("Creating OF13Encoder"); } @Override - protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, ByteBuf out) + protected void encode(final ChannelHandlerContext ctx, final MessageListenerWrapper wrapper, final ByteBuf out) throws Exception { - LOGGER.trace("Encoding"); + LOG.trace("Encoding"); try { serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); if(wrapper.getMsg() instanceof FlowModInput){ statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_SENT); } statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS); - } catch(Exception e) { - LOGGER.warn("Message serialization failed ", e); + } catch(final Exception e) { + LOG.warn("Message serialization failed ", e); statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_FAIL); - Future newFailedFuture = ctx.newFailedFuture(e); - wrapper.getListener().operationComplete(newFailedFuture); + if (wrapper.getListener() != null) { + final Future newFailedFuture = ctx.newFailedFuture(e); + wrapper.getListener().operationComplete(newFailedFuture); + } out.clear(); return; } @@ -61,7 +62,7 @@ protected void encode(ChannelHandlerContext ctx, MessageListenerWrapper wrapper, /** * @param serializationFactory */ - public void setSerializationFactory(SerializationFactory serializationFactory) { + public void setSerializationFactory(final SerializationFactory serializationFactory) { this.serializationFactory = serializationFactory; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 8e1061b2..ebf956f9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.concurrent.Future; @@ -16,6 +15,7 @@ import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.Nonnull; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -266,6 +266,7 @@ public void channelActive(final ChannelHandlerContext ctx) throws Exception { conditionalFlush(); } + @Override public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { /* * Tune channel write buffering. We increase the writability window @@ -363,19 +364,7 @@ void ensureFlushing() { void onEchoRequest(final EchoRequestMessage message) { final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()) .setVersion(message.getVersion()).setXid(message.getXid()).build(); - final SimpleRpcListener simpleMsgRpcListener = new SimpleRpcListener(reply, "echo-reply sending failed"); - - final GenericFutureListener> msgProcessListener = simpleMsgRpcListener.takeListener(); - final Object messageListenerWrapper; - if (address == null) { - messageListenerWrapper = new MessageListenerWrapper(simpleMsgRpcListener.takeMessage(), msgProcessListener); - } else { - messageListenerWrapper = new UdpMessageListenerWrapper(simpleMsgRpcListener.takeMessage(), msgProcessListener, address); - } - final ChannelFuture channelFuture = parent.getChannel().writeAndFlush(messageListenerWrapper); - if (msgProcessListener != null) { - channelFuture.addListener(msgProcessListener); - } + parent.getChannel().writeAndFlush(makeMessageListenerWrapper(reply)); } /** @@ -389,12 +378,7 @@ void onEchoRequest(final EchoRequestMessage message) { * adding overhead. */ void writeMessage(final OfHeader message, final long now) { - final Object wrapper; - if (address == null) { - wrapper = new MessageListenerWrapper(message, null); - } else { - wrapper = new UdpMessageListenerWrapper(message, null, address); - } + final Object wrapper = makeMessageListenerWrapper(message); parent.getChannel().write(wrapper); if (message instanceof BarrierInput) { @@ -411,4 +395,33 @@ void writeMessage(final OfHeader message, final long now) { } } } + + /** + * Wraps outgoing message and includes listener attached to this message + * which is send to OFEncoder for serialization. Correct wrapper is + * selected by communication pipeline. + * + * @return + */ + private Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { + Preconditions.checkArgument(msg != null); + + if (address == null) { + return new MessageListenerWrapper(msg, LOG_ENCODER_LISTENER); + } + return new UdpMessageListenerWrapper(msg, LOG_ENCODER_LISTENER, address); + } + + /* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */ + private static final GenericFutureListener> LOG_ENCODER_LISTENER = new GenericFutureListener>() { + + private final Logger LOGGER = LoggerFactory.getLogger("LogEncoderListener"); + + @Override + public void operationComplete(final Future future) throws Exception { + if (future.cause() != null) { + LOGGER.warn("Message encoding fail !", future.cause()); + } + } + }; } From 1bab57414997362845756a427c5306076cdaf96c Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Wed, 14 Oct 2015 17:17:22 +0200 Subject: [PATCH 200/285] Fix BUG 4281 Caused by: java.lang.IllegalStateException: Resource '/META-INF/yang/openflow-instruction.yang' is missing added KEY_WORD into modules ment to live outside of md-sal Change-Id: I3d6cc4d3d9bf5eb845ab5757447bed462567c335 Signed-off-by: Yi Yang Signed-off-by: Vaclav Demcak --- openflow-protocol-api/pom.xml | 43 ------------------- .../src/main/yang/openflow-action.yang | 2 +- .../src/main/yang/openflow-augments.yang | 2 +- .../main/yang/openflow-extensible-match.yang | 2 +- .../src/main/yang/openflow-instruction.yang | 2 +- .../src/main/yang/openflow-protocol.yang | 2 +- .../src/main/yang/openflow-types.yang | 2 +- .../src/main/yang/system-notifications.yang | 2 +- 8 files changed, 7 insertions(+), 50 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 80e5103f..efaa892a 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -43,49 +43,6 @@ - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - prepare-package - - run - - - - - - - - - - - - - - - - - - - - - - - - - - org.opendaylight.mdsal diff --git a/openflow-protocol-api/src/main/yang/openflow-action.yang b/openflow-protocol-api/src/main/yang/openflow-action.yang index 576a7f45..d2ae42f6 100644 --- a/openflow-protocol-api/src/main/yang/openflow-action.yang +++ b/openflow-protocol-api/src/main/yang/openflow-action.yang @@ -17,7 +17,7 @@ import openflow-extensible-match { prefix oxm;} revision "2015-02-03" { - description "OpenFlow 1.3 - action model"; + description "#NOT_PUBLISHED# OpenFlow 1.3 - action model"; } identity experimenter-action-sub-type { diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index 2df9d5b6..f0f96369 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -21,7 +21,7 @@ import openflow-extensible-match {prefix oxm;} revision "2015-02-25" { - description "OpenFlow 1.3 - augments model. + description "#NOT_PUBLISHED# OpenFlow 1.3 - augments model. Please visit https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf - Augmentation Tables chapter"; diff --git a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang index f9d3f6c3..f1f9e9b9 100644 --- a/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang +++ b/openflow-protocol-api/src/main/yang/openflow-extensible-match.yang @@ -15,7 +15,7 @@ import openflow-types {prefix oft;} revision "2015-02-25" { - description "OpenFlow 1.3 - match model"; + description "#NOT_PUBLISHED# OpenFlow 1.3 - match model"; } identity oxm-match-type { diff --git a/openflow-protocol-api/src/main/yang/openflow-instruction.yang b/openflow-protocol-api/src/main/yang/openflow-instruction.yang index a58fc349..b9e515b3 100644 --- a/openflow-protocol-api/src/main/yang/openflow-instruction.yang +++ b/openflow-protocol-api/src/main/yang/openflow-instruction.yang @@ -14,7 +14,7 @@ import openflow-action {prefix ofaction;} revision "2013-07-31" { - description "OpenFlow 1.3 - instruction model"; + description "#NOT_PUBLISHED# OpenFlow 1.3 - instruction model"; } container instruction-container { diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 9c9dbf0e..3d9f1d6c 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -18,7 +18,7 @@ import openflow-action {prefix ofaction;} revision "2013-07-31" { - description "OpenFlow 1.3 - protocol objects model"; + description "#NOT_PUBLISHED# OpenFlow 1.3 - protocol objects model"; } // Generic Structures diff --git a/openflow-protocol-api/src/main/yang/openflow-types.yang b/openflow-protocol-api/src/main/yang/openflow-types.yang index be0e9f5d..251a845e 100644 --- a/openflow-protocol-api/src/main/yang/openflow-types.yang +++ b/openflow-protocol-api/src/main/yang/openflow-types.yang @@ -11,7 +11,7 @@ prefix "oft"; revision "2013-07-31" { - description "OpenFlow 1.3 - common types model"; + description "#NOT_PUBLISHED# OpenFlow 1.3 - common types model"; } typedef port-number { diff --git a/openflow-protocol-api/src/main/yang/system-notifications.yang b/openflow-protocol-api/src/main/yang/system-notifications.yang index b31dd02b..5bd805c3 100644 --- a/openflow-protocol-api/src/main/yang/system-notifications.yang +++ b/openflow-protocol-api/src/main/yang/system-notifications.yang @@ -11,7 +11,7 @@ prefix "ofs"; revision "2013-09-27" { - description "Model of system messages used in OpenFlow Protocol Library"; + description "#NOT_PUBLISHED# Model of system messages used in OpenFlow Protocol Library"; } notification disconnect-event { From 721e833bec7d967c8c3fa57db2bf80d8812c2c4e Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Tue, 13 Oct 2015 14:05:32 +0200 Subject: [PATCH 201/285] Bug 4460 - Util project is too general project name Project with name "util" is too general. I guess, this project is not common util project for whole Openflow or ODL projects. So name has to be change to "openflowjava-util" because it looks like util project only for openflowjava parent. Change-Id: I5e5477b10c2542ae84a0cf4ffa3a5bec95e07004 Signed-off-by: Vaclav Demcak --- artifacts/pom.xml | 2 +- features/pom.xml | 2 +- features/src/main/features/features.xml | 2 +- openflow-protocol-impl/pom.xml | 2 +- {util => openflowjava-util}/pom.xml | 2 +- .../java/org/opendaylight/openflowjava/util/ByteBufUtils.java | 0 .../openflowjava/util/ExperimenterDeserializerKeyFactory.java | 0 .../openflowjava/util/ExperimenterSerializerKeyFactory.java | 0 .../org/opendaylight/openflowjava/util/ByteBufUtilsTest.java | 0 .../util/ExperimenterDeserializerKeyFactoryTest.java | 0 .../openflowjava/util/ExperimenterSerializerKeyFactoryTest.java | 0 pom.xml | 2 +- 12 files changed, 6 insertions(+), 6 deletions(-) rename {util => openflowjava-util}/pom.xml (94%) rename {util => openflowjava-util}/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java (100%) rename {util => openflowjava-util}/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java (100%) rename {util => openflowjava-util}/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java (100%) rename {util => openflowjava-util}/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java (100%) rename {util => openflowjava-util}/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java (100%) rename {util => openflowjava-util}/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java (100%) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 5b452b21..eaa3779f 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -46,7 +46,7 @@ ${project.groupId} - util + openflowjava-util ${project.version} diff --git a/features/pom.xml b/features/pom.xml index 9bb6181a..b6e92a39 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -113,7 +113,7 @@ org.opendaylight.openflowjava - util + openflowjava-util ${project.groupId} diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index ad8963a3..689c1927 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -24,7 +24,7 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-api/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} - mvn:org.opendaylight.openflowjava/util/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflowjava-util/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 272c909a..fae2c30b 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -104,7 +104,7 @@ org.opendaylight.openflowjava - util + openflowjava-util org.opendaylight.controller diff --git a/util/pom.xml b/openflowjava-util/pom.xml similarity index 94% rename from util/pom.xml rename to openflowjava-util/pom.xml index 4d4f3361..7b78d39e 100644 --- a/util/pom.xml +++ b/openflowjava-util/pom.xml @@ -9,7 +9,7 @@ ../parent bundle - util + openflowjava-util diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java similarity index 100% rename from util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java rename to openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java similarity index 100% rename from util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java rename to openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java similarity index 100% rename from util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java rename to openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java similarity index 100% rename from util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java rename to openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java similarity index 100% rename from util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java rename to openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java similarity index 100% rename from util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java rename to openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java diff --git a/pom.xml b/pom.xml index e35a9786..6f178361 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,6 @@ openflow-protocol-spi parent simple-client - util + openflowjava-util From 433d6eb1a30efb37e9b2f86884399316c990e985 Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Thu, 22 Oct 2015 14:59:51 +0200 Subject: [PATCH 202/285] BUG-4283: experimenter msg support - serialization part - added serialization support for symmetric and multipart experimenter message - comments worked in Change-Id: I8fc4d00e6afc058b335034e8298f9b846d24d8bc Signed-off-by: Michal Rehak --- .../api/extensibility/OFDeserializer.java | 5 +- .../api/extensibility/OFSerializer.java | 5 +- .../SerializerExtensionProvider.java | 11 ++- .../api/keys/ExperimenterIdSerializerKey.java | 20 +++--- .../keys/ExperimenterIdTypeSerializerKey.java | 60 ++++++++++++++++ .../src/main/yang/openflow-augments.yang | 20 ------ .../src/main/yang/openflow-protocol.yang | 25 ++++++- .../ExperimenterIdSerializerKeyTest.java | 7 +- .../ExperimenterIdTypeSerializerKeyTest.java | 72 +++++++++++++++++++ .../core/SwitchConnectionProviderImpl.java | 15 ++-- .../MessageFactoryInitializer.java | 3 +- .../ExperimenterInputMessageFactory.java | 27 ++++--- .../MultipartRequestInputFactory.java | 19 +++-- .../OF10StatsRequestInputFactory.java | 16 +++-- .../factories/VendorInputMessageFactory.java | 20 +++--- .../ConnectionAdapterImplStatisticsTest.java | 12 ++-- .../SwitchConnectionProviderImpl02Test.java | 15 ++-- .../ExperimenterInputMessageFactoryTest.java | 27 ++++--- .../VendorInputMessageFactoryTest.java | 17 +++-- .../MultipartRequestExperimenterTest.java | 23 +++--- .../OF10StatsRequestExperimenterTest.java | 23 +++--- .../ExperimenterSerializerKeyFactory.java | 22 +++--- .../ExperimenterSerializerKeyFactoryTest.java | 72 ++++++++++--------- 23 files changed, 353 insertions(+), 183 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java index a49d84c3..06c54f9d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFDeserializer.java @@ -9,8 +9,7 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; import io.netty.buffer.ByteBuf; - -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * Uniform interface for deserializing factories @@ -18,7 +17,7 @@ * @author timotej.kubas * @param message code type */ -public interface OFDeserializer extends OFGeneralDeserializer { +public interface OFDeserializer extends OFGeneralDeserializer { /** * Transforms byte message into POJO/DTO (of type E). diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java index 6b2ef473..ec63be53 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFSerializer.java @@ -8,9 +8,8 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; -import org.opendaylight.yangtools.yang.binding.DataObject; - import io.netty.buffer.ByteBuf; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * Uniform interface for serializers @@ -18,7 +17,7 @@ * @author timotej.kubas * @param message type */ -public interface OFSerializer extends OFGeneralSerializer { +public interface OFSerializer extends OFGeneralSerializer { /** * Transforms POJO/DTO into byte message (ByteBuf). diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index ebccdad8..13162491 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -15,9 +15,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; @@ -73,16 +72,16 @@ void registerMatchEntrySerializer * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); + void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); /** * Registers multipart-request (stats-request) serializer * @param key used for serializer lookup * @param serializer serializer implementation */ - void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); + void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); /** * Registers multipart-request table-features serializer diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java index 89525282..8a900e34 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdSerializerKey.java @@ -8,16 +8,16 @@ package org.opendaylight.openflowjava.protocol.api.keys; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * @author michal.polkorab * @param class of object to be serialized */ -public class ExperimenterIdSerializerKey extends MessageTypeKey +public class ExperimenterIdSerializerKey extends MessageTypeKey implements ExperimenterSerializerKey { - private Long experimenterId; + private long experimenterId; /** * @param msgVersion protocol wire version @@ -25,7 +25,7 @@ public class ExperimenterIdSerializerKey extends MessageTy * @param objectClass class of object to be serialized */ public ExperimenterIdSerializerKey(short msgVersion, - Long experimenterId, Class objectClass) { + long experimenterId, Class objectClass) { super(msgVersion, objectClass); this.experimenterId = experimenterId; } @@ -34,10 +34,14 @@ public ExperimenterIdSerializerKey(short msgVersion, public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + hashCodeOfLong(experimenterId); return result; } + protected int hashCodeOfLong(long longValue) { + return (int) (longValue ^ (longValue >>> 32)); + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -50,11 +54,7 @@ public boolean equals(Object obj) { return false; } ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { + if (experimenterId != other.experimenterId) { return false; } return true; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java new file mode 100644 index 00000000..b8f6ac93 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeSerializerKey.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * @param class of object to be serialized + * @author michal.polkorab + */ +public class ExperimenterIdTypeSerializerKey extends ExperimenterIdSerializerKey { + + private long type; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param type data type according to vendor implementation + * @param objectClass class of object to be serialized + */ + public ExperimenterIdTypeSerializerKey(short msgVersion, + long experimenterId, long type, Class objectClass) { + super(msgVersion, experimenterId, objectClass); + this.type = type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + hashCodeOfLong(type); + return result; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdTypeSerializerKey)) { + return false; + } + ExperimenterIdTypeSerializerKey other = (ExperimenterIdTypeSerializerKey) obj; + if (type != other.type) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + "; type: " + type; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index f0f96369..e5be7e56 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -121,26 +121,6 @@ } } -// OFP_MULTIPART AUGMENTS - augment "/ofproto:multipart-request/ofproto:input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { - ext:augment-identifier "experimenter-id-multipart-request"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { - ext:augment-identifier "experimenter-id-multipart-reply"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - // OFP_METER_BAND AUGMENTS augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { ext:augment-identifier "experimenter-id-meter-band"; diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 3d9f1d6c..84e78a58 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -219,6 +219,26 @@ type uint32; } } + + grouping experimenter-core { + description "General experimenter message content suitable for symmetric and multipart message"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp_type { + type uint32; + } + choice experimenter-data-of-choice { + // to be augmented by vendors + } + } + grouping experimenter-of-message { + reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + uses experimenter-core; + } + /* Switch configuration messages. */ grouping features-request { reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"; @@ -678,7 +698,7 @@ } case multipart-request-experimenter-case { container multipart-request-experimenter { - // empty body - used for experimenter augmentation + uses experimenter-core; } } } @@ -1280,8 +1300,9 @@ } rpc experimenter { + description "Send experimenter message to device, reply is not solicitated."; input { - uses experimenter; + uses experimenter-of-message; } } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index aa5d1275..a3bf7891 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -26,7 +26,7 @@ public class ExperimenterIdSerializerKeyTest { * Test ExperimenterIdSerializerKey equals and hashCode */ @Test - public void test() { + public void testHashCodeAndEquals() { ExperimenterIdSerializerKey key1 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); ExperimenterIdSerializerKey key2 = @@ -36,9 +36,6 @@ public void test() { key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); @@ -56,7 +53,7 @@ public void test() { @Test public void testEquals() { ExperimenterIdSerializerKey key1 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, ExperimenterMessage.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java new file mode 100644 index 00000000..a613d0d8 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeSerializerKeyTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + */ +public class ExperimenterIdTypeSerializerKeyTest { + + /** + * Test ExperimenterIdTypeSerializerKey equals and hashCode + */ + @Test + public void testHashCodeAndEquals() { + ExperimenterIdTypeSerializerKey key1 = + new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + ExperimenterIdTypeSerializerKey key2 = + new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + + key2 = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 2L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdTypeSerializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdTypeSerializerKey key1 = + new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, 1L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + ExperimenterIdSerializerKey mk = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdTypeSerializerKey key2 = + new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + ExperimenterIdTypeSerializerKey key3 = + new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 41L, 2L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by type.", key1.equals(key3)); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index c2b4890d..5d6d26c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -9,8 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import io.netty.channel.nio.NioEventLoopGroup; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -43,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; @@ -50,9 +52,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - /** * Exposed class for server handling
          * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)
          @@ -253,14 +252,14 @@ public void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, } @Override - public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer) { + public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer) { + public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index c3610c13..95303409 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -35,6 +35,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.VendorInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; @@ -77,7 +78,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); - registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new VendorInputMessageFactory()); registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java index 6dd5f663..b544a8ff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java @@ -9,30 +9,41 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** - * Translates Experimenter messages + * Translates Experimenter messages (both: symmetric request and single reply) * @author michal.polkorab */ -public class ExperimenterInputMessageFactory implements OFSerializer, +public class ExperimenterInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private SerializerRegistry registry; + /** Code type of symmetric Experimenter message */ + private static final byte MESSAGE_TYPE = 4; + @Override - public void serialize(ExperimenterInput message, ByteBuf outBuffer) { + public void serialize(ExperimenterOfMessage message, ByteBuf outBuffer) { long expId = message.getExperimenter().getValue(); - OFSerializer serializer = registry.getSerializer( + OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF10_VERSION_ID, expId)); - serializer.serialize(message, outBuffer); + EncodeConstants.OF13_VERSION_ID, expId, message.getExpType().longValue())); + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + + // write experimenterId and type + outBuffer.writeInt(message.getExperimenter().getValue().intValue()); + outBuffer.writeInt(message.getExpType().intValue()); + + serializer.serialize(message.getExperimenterDataOfChoice(), outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 7afb253b..2287a64a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -9,9 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; @@ -23,7 +21,6 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; @@ -37,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase; @@ -144,11 +142,18 @@ private void serializeExperimenterBody(final MultipartRequestInput message, MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) message.getMultipartRequestBody(); MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter(); - long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue(); - OFSerializer serializer = registry.getSerializer( + final long expId = experimenter.getExperimenter().getValue().longValue(); + final long expType = experimenter.getExpType().longValue(); + + // write experimenterId and type + outBuffer.writeInt((int) expId); + outBuffer.writeInt((int) expType); + + // serialize experimenter data + OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF13_VERSION_ID, expId)); - serializer.serialize(expCase, outBuffer); + EncodeConstants.OF13_VERSION_ID, expId, expType)); + serializer.serialize(experimenter.getExperimenterDataOfChoice(), outBuffer); } private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlags flags) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java index ca81ef13..fa01f6d8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; @@ -17,10 +16,10 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase; @@ -132,11 +131,16 @@ private static void serializeQueueBody(final MultipartRequestBody multipartReque private void serializeExperimenterBody(final MultipartRequestBody multipartRequestBody, final ByteBuf output) { MultipartRequestExperimenterCase expCase = (MultipartRequestExperimenterCase) multipartRequestBody; MultipartRequestExperimenter experimenter = expCase.getMultipartRequestExperimenter(); - long expId = experimenter.getAugmentation(ExperimenterIdMultipartRequest.class).getExperimenter().getValue(); - OFSerializer serializer = registry.getSerializer( + final long expId = experimenter.getExperimenter().getValue().longValue(); + + // write experimenterId + output.writeInt((int) expId); + + OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, expId)); - serializer.serialize(expCase, output); + EncodeConstants.OF10_VERSION_ID, expId, + -1 /* in order not to collide with OF >= 1.3 codecs*/)); + serializer.serialize(experimenter.getExperimenterDataOfChoice(), output); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java index 1cf2adc3..2cc7148e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactory.java @@ -9,30 +9,34 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** - * Translates Vendor messages + * Translates Vendor messages (OF-1.0 limited version - skipping experimenter type) * @author michal.polkorab */ -public class VendorInputMessageFactory implements OFSerializer, +public class VendorInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private SerializerRegistry registry; @Override - public void serialize(ExperimenterInput message, ByteBuf outBuffer) { + public void serialize(ExperimenterOfMessage message, ByteBuf outBuffer) { long expId = message.getExperimenter().getValue(); - OFSerializer serializer = registry.getSerializer( + OFSerializer serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF10_VERSION_ID, expId)); - serializer.serialize(message, outBuffer); + EncodeConstants.OF10_VERSION_ID, expId, message.getExpType().longValue())); + + // write experimenterId + outBuffer.writeInt(message.getExperimenter().getValue().intValue()); + + serializer.serialize(message.getExperimenterDataOfChoice(), outBuffer); } @Override diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java index a770e853..862de53d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -8,15 +8,18 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import static org.mockito.Mockito.when; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPipeline; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.channel.socket.SocketChannel; - import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; - import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -57,11 +60,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - /** * Test counters in ConnectionAdapter (at least DS_ENTERED_OFJAVA, DS_FLOW_MODS_ENTERED and US_MESSAGE_PASS counters have to be enabled) * @author madamjak diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index c83e60c5..f70962f6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; - import org.junit.Assert; import org.junit.Test; import org.mockito.Mock; @@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; @@ -63,8 +64,8 @@ public class SwitchConnectionProviderImpl02Test { @Mock OFDeserializer deserializerMultipartRplMsg; @Mock OFDeserializer deserializerQueueProperty; @Mock OFDeserializer deserializerMeterBandExpCase; - @Mock OFSerializer serializerExperimenterInput; - @Mock OFSerializer serializerMultipartRequestExpCase; + @Mock OFSerializer serializerExperimenterInput; + @Mock OFSerializer serializerMultipartRequestExpCase; @Mock OFSerializer serializerMeterBandExpCase; private static final int SWITCH_IDLE_TIMEOUT = 2000; private InetAddress startupAddress; @@ -211,14 +212,14 @@ public void testUnregisterExistingKeys(){ Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11)); Assert.assertFalse("Wrong -- unregister MeterBandDeserializer by not existing key", provider.unregisterDeserializer(key11)); // -- registerExperimenterMessageSerializer - ExperimenterIdSerializerKey key12 - = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,ExperimenterInput.class); + ExperimenterIdSerializerKey key12 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterDataOfChoice.class); provider.registerExperimenterMessageSerializer(key12, serializerExperimenterInput); Assert.assertTrue("Wrong -- unregister ExperimenterMessageSerializer", provider.unregisterSerializer(key12)); Assert.assertFalse("Wrong -- unregister ExperimenterMessageSerializer by not existing key", provider.unregisterSerializer(key12)); //registerMultipartRequestSerializer - ExperimenterIdSerializerKey key13 - = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MultipartRequestExperimenterCase.class); + ExperimenterIdSerializerKey key13 + = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterDataOfChoice.class); provider.registerMultipartRequestSerializer(key13, serializerMultipartRequestExpCase); Assert.assertTrue("Wrong -- unregister MultipartRequestSerializer", provider.unregisterSerializer(key13)); Assert.assertFalse("Wrong -- unregister MultipartRequestSerializer by not existing key", provider.unregisterSerializer(key13)); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java index 89e0f958..9b6720e4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -9,8 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - import org.junit.Test; import org.mockito.Matchers; import org.mockito.Mock; @@ -26,6 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab @@ -34,8 +34,13 @@ public class ExperimenterInputMessageFactoryTest { @Mock SerializerRegistry registry; - @Mock OFSerializer serializer; - private OFSerializer expFactory; + @Mock + private OFSerializer serializer; + private OFSerializer expFactory; + @Mock + private ExperimenterDataOfChoice vendorData; + @Mock + private ByteBuf out; /** * Sets up ExperimenterInputMessageFactory @@ -64,9 +69,10 @@ public void testV10Real() throws Exception { ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(21L); + builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); } @@ -81,9 +87,10 @@ public void testV13Real() throws Exception { ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(22L); + builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); } @@ -98,13 +105,15 @@ public void testV10() throws Exception { ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(21L); + builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); Mockito.when(registry.getSerializer( (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); + Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out); } /** @@ -118,12 +127,14 @@ public void testV13() throws Exception { ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(21L); + builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); Mockito.when(registry.getSerializer( (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); expFactory.serialize(input, out); + Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java index 15496598..f299e818 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java @@ -10,19 +10,21 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; - import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab @@ -32,14 +34,16 @@ public class VendorInputMessageFactoryTest { @Mock SerializerRegistry registry; - @Mock ExperimenterInputMessageFactory serializer; + @Mock OFSerializer foundSerializer; + @Mock ExperimenterDataOfChoice vendorData; + VendorInputMessageFactory serializer; /** - * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} + * Tests {@link VendorInputMessageFactory#serialize(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterOfMessage, ByteBuf)} */ @Test public void test() { - Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) + Mockito.when(registry.getSerializer(Matchers.>any())) .thenReturn(serializer); VendorInputMessageFactory factory = new VendorInputMessageFactory(); factory.injectSerializerRegistry(registry); @@ -49,9 +53,12 @@ public void test() { builder.setXid(12345L); builder.setExperimenter(new ExperimenterId(42L)); builder.setExpType(84L); + builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput experimenterInput = builder.build(); + Mockito.when(registry.getSerializer(Matchers.>any())) + .thenReturn(foundSerializer); factory.serialize(experimenterInput, buffer); - Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); + Mockito.verify(foundSerializer, Mockito.times(1)).serialize(experimenterInput.getExperimenterDataOfChoice(), buffer); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java index c4d58dc9..ce94f426 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,18 +19,16 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; @@ -43,7 +40,9 @@ public class MultipartRequestExperimenterTest { @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; + @Mock OFSerializer serializer; + + @Mock ExperimenterDataOfChoice vendorData; /** * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization @@ -51,7 +50,7 @@ public class MultipartRequestExperimenterTest { */ @Test public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + Mockito.when(mockRegistry.getSerializer(Matchers.>any())) .thenReturn(serializer); MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); multipartFactory.injectSerializerRegistry(mockRegistry); @@ -61,9 +60,9 @@ public void testExperimenter() throws Exception { builder.setFlags(new MultipartRequestFlags(false)); MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + expBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.setExpType(21L); + expBuilder.setExperimenterDataOfChoice(vendorData); caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); @@ -71,9 +70,9 @@ public void testExperimenter() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - BufferHelper.checkHeaderV13(out, (byte) 18, 16); + BufferHelper.checkHeaderV13(out, (byte) 18, 24); Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java index 0fcacef1..15430aa6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -10,7 +10,6 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,18 +19,16 @@ import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMultipartRequestBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; @@ -43,7 +40,9 @@ public class OF10StatsRequestExperimenterTest { @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; + @Mock OFSerializer serializer; + @Mock + private ExperimenterDataOfChoice vendorData; /** * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization @@ -51,7 +50,7 @@ public class OF10StatsRequestExperimenterTest { */ @Test public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + Mockito.when(mockRegistry.getSerializer(Matchers.>any())) .thenReturn(serializer); OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); multipartFactory.injectSerializerRegistry(mockRegistry); @@ -61,9 +60,9 @@ public void testExperimenter() throws Exception { builder.setFlags(new MultipartRequestFlags(false)); MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + expBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.setExpType(21L); + expBuilder.setExperimenterDataOfChoice(vendorData); caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); builder.setMultipartRequestBody(caseBuilder.build()); MultipartRequestInput message = builder.build(); @@ -71,9 +70,9 @@ public void testExperimenter() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); multipartFactory.serialize(message, out); - BufferHelper.checkHeaderV10(out, (byte) 16, 12); + BufferHelper.checkHeaderV10(out, (byte) 16, 16); Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out); } } \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 36033d07..edc6f25e 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -9,9 +9,9 @@ package org.opendaylight.openflowjava.util; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; /** @@ -23,21 +23,23 @@ public abstract class ExperimenterSerializerKeyFactory { /** * @param msgVersion openflow wire version * @param experimenterId experimenter / vendor ID + * @param type experimenter type according to vendor implementation * @return key instance */ - public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); + public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( + short msgVersion, long experimenterId, long type) { + return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class); } /** * @param msgVersion openflow wire version * @param experimenterId experimenter / vendor ID + * @param type experimenter type according to vendor implementation * @return key instance */ - public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); + public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( + short msgVersion, long experimenterId, long type) { + return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, ExperimenterDataOfChoice.class); } /** @@ -46,7 +48,7 @@ public static ExperimenterIdSerializerKey crea * @return key instance */ public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( - short msgVersion, Long experimenterId) { + short msgVersion, long experimenterId) { return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); } @@ -56,7 +58,7 @@ public static ExperimenterIdSerializerKey createMultipar * @return key instance */ public static ExperimenterIdSerializerKey createMeterBandSerializerKey( - short msgVersion, Long experimenterId) { + short msgVersion, long experimenterId) { return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); } } \ No newline at end of file diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java index 91435929..211186d7 100644 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -11,62 +11,64 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; /** + * Test ExperimenterSerializerKeyFactory key creation * @author michal.polkorab * */ public class ExperimenterSerializerKeyFactoryTest { - /** - * Test ExperimenterSerializerKeyFactory key creation - */ @Test - public void test() { - ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory - .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdSerializerKey comparationKey = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 43L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 44L, MultipartRequestExperimenterCase.class); + public void testCreateExperimenterMessageSerializerKey() throws Exception { + ExperimenterIdSerializerKey createdKey; + ExperimenterIdSerializerKey comparationKey; + + createdKey = ExperimenterSerializerKeyFactory + .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L); + comparationKey = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 42L, 1L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } + + @Test + public void testCreateMultipartRequestSerializerKey() throws Exception { + ExperimenterIdSerializerKey createdKey; + ExperimenterIdSerializerKey comparationKey; + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); + EncodeConstants.OF10_VERSION_ID, 44L, 1L); comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MultipartRequestExperimenterCase.class); + 44L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } + + @Test + public void testCreateMultipartRequestTFSerializerKey() throws Exception { + ExperimenterIdSerializerKey createdKey; + ExperimenterIdSerializerKey comparationKey; + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( EncodeConstants.OF10_VERSION_ID, 45L); comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 45L, TableFeatureProperties.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateMeterBandSerializerKey() throws Exception { + ExperimenterIdSerializerKey createdKey; + ExperimenterIdSerializerKey comparationKey; + + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); + 43L, MeterBandExperimenterCase.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); } } \ No newline at end of file From 7f38a8310fbde1f32529412cd198d40daf197b10 Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Thu, 22 Oct 2015 15:12:09 +0200 Subject: [PATCH 203/285] BUG-4283: experimenter msg support - deserialization part - added support for symmetric and multipart experimenter message deserialization Change-Id: Id0efd13f8f6254d55a30cd10871840d93174117a Signed-off-by: Michal Rehak --- .../DeserializerExtensionProvider.java | 7 +- .../keys/ExperimenterIdDeserializerKey.java | 21 +- .../ExperimenterIdTypeDeserializerKey.java | 59 +++++ .../src/main/yang/openflow-protocol.yang | 19 +- .../ExperimenterIdDeserializerKeyTest.java | 4 +- ...ExperimenterIdTypeDeserializerKeyTest.java | 72 ++++++ .../core/SwitchConnectionProviderImpl.java | 8 +- .../connection/ConnectionAdapterImpl.java | 2 +- .../DeserializerRegistryImpl.java | 1 - .../MessageDeserializerInitializer.java | 7 +- .../factories/ExperimenterMessageFactory.java | 25 +- .../MultipartReplyMessageFactory.java | 216 ++++++++++-------- .../OF10StatsReplyMessageFactory.java | 58 +++-- .../factories/VendorMessageFactory.java | 22 +- .../SwitchConnectionProviderImpl02Test.java | 8 +- .../ExperimenterMessageFactoryTest.java | 21 +- .../factories/VendorMessageFactoryTest.java | 7 +- .../MultipartReplyExperimenterTest.java | 8 +- .../OF10StatsReplyExperimenterTest.java | 8 +- .../ExperimenterDeserializerKeyFactory.java | 38 ++- ...xperimenterDeserializerKeyFactoryTest.java | 127 ++++++---- 21 files changed, 489 insertions(+), 249 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java create mode 100644 openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeDeserializerKeyTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index b38b5cfa..b227453e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -14,8 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; @@ -80,7 +79,7 @@ void registerErrorDeserializer(ExperimenterIdDeserializerKey key, * @param deserializer deserializer instance */ void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); + OFDeserializer deserializer); /** * Registers multipart-reply (stats) message deserializer @@ -88,7 +87,7 @@ void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, * @param deserializer deserializer instance */ void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); + OFDeserializer deserializer); /** * Registers multipart-reply table-features message deserializer diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java index dfc75a8e..8f66900d 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java @@ -9,16 +9,16 @@ package org.opendaylight.openflowjava.protocol.api.keys; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * @author michal.polkorab * */ -public final class ExperimenterIdDeserializerKey extends MessageCodeKey +public class ExperimenterIdDeserializerKey extends MessageCodeKey implements ExperimenterDeserializerKey { - private Long experimenterId; + private long experimenterId; /** * @param type of target experimenter object @@ -26,18 +26,21 @@ public final class ExperimenterIdDeserializerKey extends MessageCodeKey * @param experimenterId experimenter / vendor ID * @param objectClass class of created object */ - public ExperimenterIdDeserializerKey(short version, - Long experimenterId, Class objectClass) { + public ExperimenterIdDeserializerKey(short version, + long experimenterId, Class objectClass) { super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); this.experimenterId = experimenterId; } + protected int hashCodeOfLong(long longValue) { + return (int) (longValue ^ (longValue >>> 32)); + } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + hashCodeOfLong(experimenterId); return result; } @@ -53,11 +56,7 @@ public boolean equals(Object obj) { return false; } ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { + if (experimenterId != other.experimenterId) { return false; } return true; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java new file mode 100644 index 00000000..cb88b1ad --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * @author michal.polkorab + */ +public class ExperimenterIdTypeDeserializerKey extends ExperimenterIdDeserializerKey { + + private long type; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param type data type according to vendor implementation + * @param objectClass class of object to be serialized + */ + public ExperimenterIdTypeDeserializerKey(short msgVersion, + long experimenterId, long type, Class objectClass) { + super(msgVersion, experimenterId, objectClass); + this.type = type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + hashCodeOfLong(type); + return result; + } + + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdTypeDeserializerKey)) { + return false; + } + ExperimenterIdTypeDeserializerKey other = (ExperimenterIdTypeDeserializerKey) obj; + if (type != other.type) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + "; type: " + type; + } +} \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 84e78a58..7e42a2b9 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -207,19 +207,7 @@ type binary; } } - grouping experimenter { - reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp_type { - type uint32; - } - } - grouping experimenter-core { description "General experimenter message content suitable for symmetric and multipart message"; leaf experimenter { @@ -231,7 +219,7 @@ choice experimenter-data-of-choice { // to be augmented by vendors } - } + } grouping experimenter-of-message { reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; /* Symmetric message */ @@ -1065,7 +1053,7 @@ } case multipart-reply-experimenter-case { container multipart-reply-experimenter { - // empty body - used for experimenter augmentation + uses experimenter-core; } } } @@ -1270,7 +1258,8 @@ /* Symmetric message */ } notification experimenter-message { - uses experimenter; + description "Experimenter request message from device."; + uses experimenter-of-message; reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; // TODO:: does switch send this when understood experimenter msg from lib? /* Symmetric message */ diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index eb71029a..d7f61084 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -36,7 +36,7 @@ public void test() { key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0L, ExperimenterMessage.class); Assert.assertFalse("Wrong equals", key1.equals(key2)); Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); @@ -56,7 +56,7 @@ public void test() { @Test public void testEquals() { ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0L, ExperimenterMessage.class); Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeDeserializerKeyTest.java new file mode 100644 index 00000000..7405b773 --- /dev/null +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdTypeDeserializerKeyTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.api.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + */ +public class ExperimenterIdTypeDeserializerKeyTest { + + /** + * Test ExperimenterIdTypeDeserializerKey equals and hashCode + */ + @Test + public void testHashCodeAndEquals() { + ExperimenterIdTypeDeserializerKey key1 = + new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + ExperimenterIdTypeDeserializerKey key2 = + new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, 1L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + + key2 = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 2L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdTypeDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdTypeDeserializerKey key1 = + new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 41L, 1L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + ExperimenterIdSerializerKey mk = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdTypeDeserializerKey key2 = + new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + ExperimenterIdTypeDeserializerKey key3 = + new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, 41L, 2L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by type.", key1.equals(key3)); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 5d6d26c2..0217d1f2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -41,12 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; import org.slf4j.Logger; @@ -223,13 +219,13 @@ public void registerErrorDeserializer(ExperimenterIdDeserializerKey key, @Override public void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer) { + OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override public void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer) { + OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index cf2693c8..4a2d0b9d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -161,7 +161,7 @@ public Future> echoReply(final EchoReplyInput input) { @Override public Future> experimenter(final ExperimenterInput input) { - return sendToSwitchFuture(input, "experimenter sending failed"); + return sendToSwitchFuture(input, "experimenter reply sending failed"); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 3479bcc0..bbbb0681 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -10,7 +10,6 @@ import java.util.HashMap; import java.util.Map; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index c82408bf..37f3a71f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -8,10 +8,12 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ExperimenterMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FeaturesReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowRemovedMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncReplyMessageFactory; @@ -34,12 +36,13 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortStatusMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.QueueGetConfigReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.VendorMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; @@ -73,6 +76,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); + helper.registerDeserializer(4, null, ExperimenterMessage.class, new VendorMessageFactory()); helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); @@ -87,6 +91,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(4, null, ExperimenterMessage.class, new ExperimenterMessageFactory()); helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java index 269976ff..244b4bfa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -9,13 +9,15 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab @@ -24,17 +26,26 @@ public class ExperimenterMessageFactory implements OFDeserializer, DeserializerRegistryInjector { - /** Experimenter ID index after version, message type and length were read */ - private static final byte EXPERIMENTER_ID_INDEX = 4; private DeserializerRegistry deserializerRegistry; @Override public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( + final long xid = message.readUnsignedInt(); + final long expId = message.readUnsignedInt(); + final long expType = message.readUnsignedInt(); + + OFDeserializer deserializer = deserializerRegistry.getDeserializer( ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF13_VERSION_ID, expId)); - return deserializer.deserialize(message); + EncodeConstants.OF13_VERSION_ID, expId, expType)); + final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message); + + ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder() + .setVersion((short) EncodeConstants.OF13_VERSION_ID) + .setXid(xid) + .setExperimenter(new ExperimenterId(expId)) + .setExpType(expType) + .setExperimenterDataOfChoice(vendorData); + return messageBld.build(); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index b6e24b45..085a8565 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import java.math.BigInteger; import java.util.ArrayList; import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -38,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; @@ -61,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -71,6 +71,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; @@ -97,6 +98,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; @@ -140,6 +142,7 @@ /** * Translates MultipartReply messages + * * @author timotej.kubas * @author michal.polkorab */ @@ -189,38 +192,53 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER); switch (MultipartType.forValue(type)) { - case OFPMPDESC: builder.setMultipartReplyBody(setDesc(rawMessage)); - break; - case OFPMPFLOW: builder.setMultipartReplyBody(setFlow(rawMessage)); - break; - case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); - break; - case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); - break; - case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); - break; - case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); - break; - case OFPMPGROUP: builder.setMultipartReplyBody(setGroup(rawMessage)); - break; - case OFPMPGROUPDESC: builder.setMultipartReplyBody(setGroupDesc(rawMessage)); - break; - case OFPMPGROUPFEATURES: builder.setMultipartReplyBody(setGroupFeatures(rawMessage)); - break; - case OFPMPMETER: builder.setMultipartReplyBody(setMeter(rawMessage)); - break; - case OFPMPMETERCONFIG: builder.setMultipartReplyBody(setMeterConfig(rawMessage)); - break; - case OFPMPMETERFEATURES: builder.setMultipartReplyBody(setMeterFeatures(rawMessage)); - break; - case OFPMPTABLEFEATURES: builder.setMultipartReplyBody(setTableFeatures(rawMessage)); - break; - case OFPMPPORTDESC: builder.setMultipartReplyBody(setPortDesc(rawMessage)); - break; - case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); - break; - default: - break; + case OFPMPDESC: + builder.setMultipartReplyBody(setDesc(rawMessage)); + break; + case OFPMPFLOW: + builder.setMultipartReplyBody(setFlow(rawMessage)); + break; + case OFPMPAGGREGATE: + builder.setMultipartReplyBody(setAggregate(rawMessage)); + break; + case OFPMPTABLE: + builder.setMultipartReplyBody(setTable(rawMessage)); + break; + case OFPMPPORTSTATS: + builder.setMultipartReplyBody(setPortStats(rawMessage)); + break; + case OFPMPQUEUE: + builder.setMultipartReplyBody(setQueue(rawMessage)); + break; + case OFPMPGROUP: + builder.setMultipartReplyBody(setGroup(rawMessage)); + break; + case OFPMPGROUPDESC: + builder.setMultipartReplyBody(setGroupDesc(rawMessage)); + break; + case OFPMPGROUPFEATURES: + builder.setMultipartReplyBody(setGroupFeatures(rawMessage)); + break; + case OFPMPMETER: + builder.setMultipartReplyBody(setMeter(rawMessage)); + break; + case OFPMPMETERCONFIG: + builder.setMultipartReplyBody(setMeterConfig(rawMessage)); + break; + case OFPMPMETERFEATURES: + builder.setMultipartReplyBody(setMeterFeatures(rawMessage)); + break; + case OFPMPTABLEFEATURES: + builder.setMultipartReplyBody(setTableFeatures(rawMessage)); + break; + case OFPMPPORTDESC: + builder.setMultipartReplyBody(setPortDesc(rawMessage)); + break; + case OFPMPEXPERIMENTER: + builder.setMultipartReplyBody(setExperimenter(rawMessage)); + break; + default: + break; } return builder.build(); @@ -294,7 +312,7 @@ private MultipartReplyFlowCase setFlow(ByteBuf input) { return caseBuilder.build(); } - private static FlowModFlags createFlowModFlagsFromBitmap(int input){ + private static FlowModFlags createFlowModFlagsFromBitmap(int input) { final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0; final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0; final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0; @@ -501,7 +519,7 @@ private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { } private static MultipartReplyQueueCase setQueue(ByteBuf input) { - MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); + MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); List queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { @@ -579,7 +597,7 @@ private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { return caseBuilder.build(); } - private static MeterFlags createMeterFlags(long input){ + private static MeterFlags createMeterFlags(long input) { final Boolean mfKBPS = (input & (1 << 0)) != 0; final Boolean mfPKTPS = (input & (1 << 1)) != 0; final Boolean mfBURST = (input & (1 << 2)) != 0; @@ -649,7 +667,7 @@ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { int bandType = input.readUnsignedShort(); switch (bandType) { case 1: - MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder(); + MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder(); MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder(); bandDropBuilder.setType(MeterBandType.forValue(bandType)); actualLength += input.readUnsignedShort(); @@ -660,7 +678,7 @@ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { bandsBuilder.setMeterBand(bandDropCaseBuilder.build()); break; case 2: - MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); + MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder(); bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType)); actualLength += input.readUnsignedShort(); @@ -694,8 +712,20 @@ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { } private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { - return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF13_VERSION_ID, input.readUnsignedInt())); + final long expId = input.readUnsignedInt(); + final long expType = input.readUnsignedInt(); + + final OFDeserializer deserializer = registry.getDeserializer( + ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId, expType)); + + final MultipartReplyExperimenterBuilder mpExperimenterBld = new MultipartReplyExperimenterBuilder() + .setExperimenter(new ExperimenterId(expId)) + .setExpType(expType) + .setExperimenterDataOfChoice(deserializer.deserialize(input)); + final MultipartReplyExperimenterCaseBuilder mpReplyExperimenterCaseBld = new MultipartReplyExperimenterCaseBuilder() + .setMultipartReplyExperimenter(mpExperimenterBld.build()); + return mpReplyExperimenterCaseBld.build(); } private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { @@ -726,38 +756,38 @@ private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { return caseBuilder.build(); } - private static PortConfig createPortConfig(long input){ - final Boolean pcPortDown = ((input) & (1<<0)) != 0; - final Boolean pcNRecv = ((input) & (1<<2)) != 0; - final Boolean pcNFwd = ((input) & (1<<5)) != 0; - final Boolean pcNPacketIn = ((input) & (1<<6)) != 0; + private static PortConfig createPortConfig(long input) { + final Boolean pcPortDown = ((input) & (1 << 0)) != 0; + final Boolean pcNRecv = ((input) & (1 << 2)) != 0; + final Boolean pcNFwd = ((input) & (1 << 5)) != 0; + final Boolean pcNPacketIn = ((input) & (1 << 6)) != 0; return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } - private static PortState createPortState(long input){ - final Boolean psLinkDown = ((input) & (1<<0)) != 0; - final Boolean psBlocked = ((input) & (1<<1)) != 0; - final Boolean psLive = ((input) & (1<<2)) != 0; + private static PortState createPortState(long input) { + final Boolean psLinkDown = ((input) & (1 << 0)) != 0; + final Boolean psBlocked = ((input) & (1 << 1)) != 0; + final Boolean psLive = ((input) & (1 << 2)) != 0; return new PortState(psBlocked, psLinkDown, psLive); } - private static PortFeatures createPortFeatures(long input){ - final Boolean pf10mbHd = ((input) & (1<<0)) != 0; - final Boolean pf10mbFd = ((input) & (1<<1)) != 0; - final Boolean pf100mbHd = ((input) & (1<<2)) != 0; - final Boolean pf100mbFd = ((input) & (1<<3)) != 0; - final Boolean pf1gbHd = ((input) & (1<<4)) != 0; - final Boolean pf1gbFd = ((input) & (1<<5)) != 0; - final Boolean pf10gbFd = ((input) & (1<<6)) != 0; - final Boolean pf40gbFd = ((input) & (1<<7)) != 0; - final Boolean pf100gbFd = ((input) & (1<<8)) != 0; - final Boolean pf1tbFd = ((input) & (1<<9)) != 0; - final Boolean pfOther = ((input) & (1<<10)) != 0; - final Boolean pfCopper = ((input) & (1<<11)) != 0; - final Boolean pfFiber = ((input) & (1<<12)) != 0; - final Boolean pfAutoneg = ((input) & (1<<13)) != 0; - final Boolean pfPause = ((input) & (1<<14)) != 0; - final Boolean pfPauseAsym = ((input) & (1<<15)) != 0; + private static PortFeatures createPortFeatures(long input) { + final Boolean pf10mbHd = ((input) & (1 << 0)) != 0; + final Boolean pf10mbFd = ((input) & (1 << 1)) != 0; + final Boolean pf100mbHd = ((input) & (1 << 2)) != 0; + final Boolean pf100mbFd = ((input) & (1 << 3)) != 0; + final Boolean pf1gbHd = ((input) & (1 << 4)) != 0; + final Boolean pf1gbFd = ((input) & (1 << 5)) != 0; + final Boolean pf10gbFd = ((input) & (1 << 6)) != 0; + final Boolean pf40gbFd = ((input) & (1 << 7)) != 0; + final Boolean pf100gbFd = ((input) & (1 << 8)) != 0; + final Boolean pf1tbFd = ((input) & (1 << 9)) != 0; + final Boolean pfOther = ((input) & (1 << 10)) != 0; + final Boolean pfCopper = ((input) & (1 << 11)) != 0; + final Boolean pfFiber = ((input) & (1 << 12)) != 0; + final Boolean pfAutoneg = ((input) & (1 << 13)) != 0; + final Boolean pfPause = ((input) & (1 << 14)) != 0; + final Boolean pfPauseAsym = ((input) & (1 << 15)) != 0; return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); } @@ -768,12 +798,12 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt())); featuresBuilder.setCapabilities(createCapabilities(rawMessage.readUnsignedInt())); List maxGroupsList = new ArrayList<>(); - for (int i = 0; i < GROUP_TYPES ; i++) { + for (int i = 0; i < GROUP_TYPES; i++) { maxGroupsList.add(rawMessage.readUnsignedInt()); } featuresBuilder.setMaxGroups(maxGroupsList); List actionBitmaps = new ArrayList<>(); - for (int i = 0; i < GROUP_TYPES ; i++) { + for (int i = 0; i < GROUP_TYPES; i++) { actionBitmaps.add(createActionBitmap(rawMessage.readUnsignedInt())); } featuresBuilder.setActionsBitmap(actionBitmaps); @@ -782,22 +812,22 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa } private static ActionType createActionBitmap(long input) { - final Boolean atOutput = ((input) & (1<<0)) != 0; - final Boolean atCopyTTLout = ((input) & (1<<11)) != 0; - final Boolean atCopyTTLin = ((input) & (1<<12)) != 0; - final Boolean atSetMplsTTL = ((input) & (1<<15)) != 0; - final Boolean atDecMplsTTL = ((input) & (1<<16)) != 0; - final Boolean atPushVLAN = ((input) & (1<<17)) != 0; - final Boolean atPopVLAN = ((input) & (1<<18)) != 0; - final Boolean atPushMPLS = ((input) & (1<<19)) != 0; - final Boolean atPopMPLS = ((input) & (1<<20)) != 0; - final Boolean atSetQueue = ((input) & (1<<21)) != 0; - final Boolean atGroup = ((input) & (1<<22)) != 0; - final Boolean atSetNWTTL = ((input) & (1<<23)) != 0; - final Boolean atDecNWTTL = ((input) & (1<<24)) != 0; - final Boolean atSetField = ((input) & (1<<25)) != 0; - final Boolean atPushPBB = ((input) & (1<<26)) != 0; - final Boolean atPopPBB = ((input) & (1<<27)) != 0; + final Boolean atOutput = ((input) & (1 << 0)) != 0; + final Boolean atCopyTTLout = ((input) & (1 << 11)) != 0; + final Boolean atCopyTTLin = ((input) & (1 << 12)) != 0; + final Boolean atSetMplsTTL = ((input) & (1 << 15)) != 0; + final Boolean atDecMplsTTL = ((input) & (1 << 16)) != 0; + final Boolean atPushVLAN = ((input) & (1 << 17)) != 0; + final Boolean atPopVLAN = ((input) & (1 << 18)) != 0; + final Boolean atPushMPLS = ((input) & (1 << 19)) != 0; + final Boolean atPopMPLS = ((input) & (1 << 20)) != 0; + final Boolean atSetQueue = ((input) & (1 << 21)) != 0; + final Boolean atGroup = ((input) & (1 << 22)) != 0; + final Boolean atSetNWTTL = ((input) & (1 << 23)) != 0; + final Boolean atDecNWTTL = ((input) & (1 << 24)) != 0; + final Boolean atSetField = ((input) & (1 << 25)) != 0; + final Boolean atPushPBB = ((input) & (1 << 26)) != 0; + final Boolean atPopPBB = ((input) & (1 << 27)) != 0; final Boolean atExperimenter = false; return new ActionType(atCopyTTLin, atCopyTTLout, atDecMplsTTL, atDecNWTTL, atExperimenter, atGroup, atOutput, atPopMPLS, @@ -806,18 +836,18 @@ private static ActionType createActionBitmap(long input) { } private static GroupCapabilities createCapabilities(long input) { - final Boolean gcSelectWeight = ((input) & (1<<0)) != 0; - final Boolean gcSelectLiveness = ((input) & (1<<1)) != 0; - final Boolean gcChaining = ((input) & (1<<2)) != 0; - final Boolean gcChainingChecks = ((input) & (1<<3)) != 0; + final Boolean gcSelectWeight = ((input) & (1 << 0)) != 0; + final Boolean gcSelectLiveness = ((input) & (1 << 1)) != 0; + final Boolean gcChaining = ((input) & (1 << 2)) != 0; + final Boolean gcChainingChecks = ((input) & (1 << 3)) != 0; return new GroupCapabilities(gcChaining, gcChainingChecks, gcSelectLiveness, gcSelectWeight); } private static GroupTypes createGroupType(long input) { - final Boolean gtAll = ((input) & (1<<0)) != 0; - final Boolean gtSelect = ((input) & (1<<1)) != 0; - final Boolean gtIndirect = ((input) & (1<<2)) != 0; - final Boolean gtFF = ((input) & (1<<3)) != 0; + final Boolean gtAll = ((input) & (1 << 0)) != 0; + final Boolean gtSelect = ((input) & (1 << 1)) != 0; + final Boolean gtIndirect = ((input) & (1 << 2)) != 0; + final Boolean gtFF = ((input) & (1 << 3)) != 0; return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java index 691a270f..f0999285 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactory.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import java.math.BigInteger; import java.util.ArrayList; import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -26,16 +24,19 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; @@ -46,6 +47,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; @@ -61,6 +63,7 @@ /** * Translates StatsReply messages (OpenFlow v1.0) + * * @author michal.polkorab */ public class OF10StatsReplyMessageFactory implements OFDeserializer, @@ -88,22 +91,29 @@ public MultipartReplyMessage deserialize(ByteBuf rawMessage) { builder.setType(MultipartType.forValue(type)); builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0)); switch (MultipartType.forValue(type)) { - case OFPMPDESC: builder.setMultipartReplyBody(setDesc(rawMessage)); - break; - case OFPMPFLOW: builder.setMultipartReplyBody(setFlow(rawMessage)); - break; - case OFPMPAGGREGATE: builder.setMultipartReplyBody(setAggregate(rawMessage)); - break; - case OFPMPTABLE: builder.setMultipartReplyBody(setTable(rawMessage)); - break; - case OFPMPPORTSTATS: builder.setMultipartReplyBody(setPortStats(rawMessage)); - break; - case OFPMPQUEUE: builder.setMultipartReplyBody(setQueue(rawMessage)); - break; - case OFPMPEXPERIMENTER: builder.setMultipartReplyBody(setExperimenter(rawMessage)); - break; - default: - break; + case OFPMPDESC: + builder.setMultipartReplyBody(setDesc(rawMessage)); + break; + case OFPMPFLOW: + builder.setMultipartReplyBody(setFlow(rawMessage)); + break; + case OFPMPAGGREGATE: + builder.setMultipartReplyBody(setAggregate(rawMessage)); + break; + case OFPMPTABLE: + builder.setMultipartReplyBody(setTable(rawMessage)); + break; + case OFPMPPORTSTATS: + builder.setMultipartReplyBody(setPortStats(rawMessage)); + break; + case OFPMPQUEUE: + builder.setMultipartReplyBody(setQueue(rawMessage)); + break; + case OFPMPEXPERIMENTER: + builder.setMultipartReplyBody(setExperimenter(rawMessage)); + break; + default: + break; } return builder.build(); } @@ -295,8 +305,16 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { } private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { - return registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, input.readUnsignedInt())); + final long expId = input.readUnsignedInt(); + final OFDeserializer deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + + final MultipartReplyExperimenterBuilder mpExperimenterBld = new MultipartReplyExperimenterBuilder() + .setExperimenter(new ExperimenterId(expId)) + .setExperimenterDataOfChoice(deserializer.deserialize(input)); + final MultipartReplyExperimenterCaseBuilder mpReplyExperimenterCaseBld = new MultipartReplyExperimenterCaseBuilder() + .setMultipartReplyExperimenter(mpExperimenterBld.build()); + return mpReplyExperimenterCaseBld.build(); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java index be6d0004..9461da1c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java @@ -9,31 +9,39 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab - * */ public class VendorMessageFactory implements OFDeserializer, DeserializerRegistryInjector { - private static final byte VENDOR_ID_INDEX = 8; private DeserializerRegistry deserializerRegistry; @Override public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + final long xid = message.readUnsignedInt(); + final long expId = message.readUnsignedInt(); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey( EncodeConstants.OF10_VERSION_ID, expId)); - return deserializer.deserialize(message); + final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message); + + final ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder() + .setVersion((short) EncodeConstants.OF10_VERSION_ID) + .setXid(xid) + .setExperimenter(new ExperimenterId(expId)) + .setExperimenterDataOfChoice(vendorData); + return messageBld.build(); } @Override diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index f70962f6..73237c4a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -40,17 +40,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; -import com.google.common.util.concurrent.ListenableFuture; - /** * @author madamjak * @author michal.polkorab @@ -60,8 +56,8 @@ public class SwitchConnectionProviderImpl02Test { @Mock OFGeneralSerializer serializer; @Mock OFGeneralDeserializer deserializer; @Mock OFDeserializer deserializerError; - @Mock OFDeserializer deserializerExpMsg; - @Mock OFDeserializer deserializerMultipartRplMsg; + @Mock OFDeserializer deserializerExpMsg; + @Mock OFDeserializer deserializerMultipartRplMsg; @Mock OFDeserializer deserializerQueueProperty; @Mock OFDeserializer deserializerMeterBandExpCase; @Mock OFSerializer serializerExperimenterInput; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java index d25137ca..37dd6dde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -10,35 +10,39 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.when; -import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBuf; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab * */ +@RunWith(MockitoJUnitRunner.class) public class ExperimenterMessageFactoryTest { @Mock DeserializerRegistry registry; - @Mock OFDeserializer deserializer; - @Mock ExperimenterMessage message; + @Mock OFDeserializer deserializer; + @Mock ExperimenterDataOfChoice message; + private ExperimenterMessageFactory factory; /** * Initializes mocks */ @Before public void startUp() { - MockitoAnnotations.initMocks(this); + factory = new ExperimenterMessageFactory(); } /** @@ -49,11 +53,10 @@ public void test() { when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); - ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10 00 00 00 20"); factory.injectDeserializerRegistry(registry); ExperimenterMessage deserializedMessage = factory.deserialize(buffer); - Assert.assertEquals("Wrong return value", message, deserializedMessage); - Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); + Assert.assertEquals("Wrong return value", message, deserializedMessage.getExperimenterDataOfChoice()); + Assert.assertEquals("ByteBuf index moved", 0, buffer.readableBytes()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java index 050eee0e..aaa94680 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,13 +35,13 @@ public class VendorMessageFactoryTest { */ @Test public void test() { - Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); + Mockito.when(registry.getDeserializer(Matchers.any())).thenReturn(deserializer); + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("01 02 03 04 FF FF FF FF 80 00 00 00"); VendorMessageFactory factory = new VendorMessageFactory(); factory.injectDeserializerRegistry(registry); factory.deserialize(buffer); Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); - Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java index 1e989ed3..5acb3f32 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; import io.netty.buffer.ByteBuf; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,10 +17,12 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab @@ -33,12 +34,15 @@ public class MultipartReplyExperimenterTest { @Mock DeserializerRegistry registry; private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + @Mock + private OFDeserializer vendorDeserializer; /** * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO */ @Test public void testMultipartReplyExperimenter() { + Mockito.when(registry.getDeserializer(Matchers.any())).thenReturn(vendorDeserializer); factory.injectDeserializerRegistry(registry); ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + "00 00 00 01 00 00 00 02"); // expID, expType @@ -48,6 +52,6 @@ public void testMultipartReplyExperimenter() { Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + Mockito.verify(vendorDeserializer).deserialize(bb); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java index 8986f5c8..69d420fe 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories.multipart; import io.netty.buffer.ByteBuf; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,10 +17,12 @@ import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; /** * @author michal.polkorab @@ -31,12 +32,14 @@ public class OF10StatsReplyExperimenterTest { @Mock DeserializerRegistry registry; + @Mock private OFDeserializer vendorDeserializer; /** * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation */ @Test public void test() { + Mockito.when(registry.getDeserializer(Matchers.any())).thenReturn(vendorDeserializer); OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); factory.injectDeserializerRegistry(registry); @@ -47,6 +50,7 @@ public void test() { BufferHelper.checkHeaderV10(builtByFactory); Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + + Mockito.verify(vendorDeserializer).deserialize(bb); } } \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 36f44ff2..6c65deed 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -9,10 +9,10 @@ package org.opendaylight.openflowjava.util; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; @@ -39,21 +39,43 @@ public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerK /** * @param version openflow wire version * @param experimenterId experimenter / vendor ID + * @param type experimenter type according to vendor implementation * @return key instance */ - public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); + public static ExperimenterIdTypeDeserializerKey createExperimenterMessageDeserializerKey( + short version, long experimenterId, long type) { + return new ExperimenterIdTypeDeserializerKey(version, experimenterId, type, ExperimenterDataOfChoice.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createVendorMessageDeserializerKey( + short version, long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterDataOfChoice.class); } /** * @param version openflow wire version * @param experimenterId experimenter / vendor ID + * @param type * @return key instance */ - public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); + public static ExperimenterIdTypeDeserializerKey createMultipartReplyMessageDeserializerKey( + short version, long experimenterId, long type) { + return new ExperimenterIdTypeDeserializerKey(version, experimenterId, type, ExperimenterDataOfChoice.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyVendorMessageDeserializerKey( + short version, long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterDataOfChoice.class); } /** diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java index 1b422d31..a8cc8368 100644 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java @@ -11,84 +11,111 @@ import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; /** * @author michal.polkorab - * */ public class ExperimenterDeserializerKeyFactoryTest { - /** - * Test ExperimenterDeserializerKeyFactory key creation - */ @Test - public void test() { - ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory + public void testCreateExperimenterErrorDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdDeserializerKey comparationKey = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 43L, ExperimenterMessage.class); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } + + @Test + public void testCreateExperimenterMessageDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 44L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); + EncodeConstants.OF10_VERSION_ID, 43L, 1L); + comparationKey = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 43L, 1L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } + + @Test + public void testCreateMultipartReplyMessageDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 45L); + EncodeConstants.OF10_VERSION_ID, 45L, 1L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 45L, MultipartReplyExperimenterCase.class); + 45L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateMultipartReplyTFDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 46L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MultipartReplyExperimenterCase.class); + 46L, TableFeatureProperties.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateQueuePropertyDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 47L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); + 47L, QueueProperty.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateMeterBandDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); + 44L, MeterBandExperimenterCase.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateVendorMessageDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); + 43L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); + } + + @Test + public void testCreateMultipartReplyVendorMessageDeserializerKey() throws Exception { + ExperimenterIdDeserializerKey createdKey; + ExperimenterIdDeserializerKey comparationKey; + + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); + 43L, ExperimenterDataOfChoice.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); } } \ No newline at end of file From 62e42c8dbabad5fc74c03c252740a1b290f2e69f Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 13 Nov 2015 14:30:46 +0100 Subject: [PATCH 204/285] Added maven central required tags Change-Id: I0ea22ab090ee45d7f906b921cffda056c3e1ddf3 Signed-off-by: Michal Polkorab --- parent/pom.xml | 20 ++++++++++++++++++++ pom.xml | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index e7b1ea4f..59048b9a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -12,6 +12,11 @@ openflowjava-parent 0.7.0-SNAPSHOT pom + openflowjava + + Openflow protocol library - serializes and deserializes openflow messages + handles connections with openflow devices. + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main @@ -28,6 +33,21 @@ HEAD + + + Michal Polkorab + michal.polkorab@pantheon.sk + Pantheon Technologies + https://www.pantheon.sk/en/ + + + Michal Rehak + mirehak@cisco.com + Cisco Systems + www.cisco.com + + + dav:http://nexus.opendaylight.org/content/sites/site UTF-8 diff --git a/pom.xml b/pom.xml index 6f178361..56e8b447 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,6 @@ openflowjava-aggregator - openflowjava pom From fa1866fd90861d8652f3868a99ad86d9929d72dc Mon Sep 17 00:00:00 2001 From: Renato Aguiar Date: Wed, 18 Nov 2015 15:41:01 -0800 Subject: [PATCH 205/285] Bug 4473 - Ignore unsupported features on table features This patch just ignores any unsupported feature, so the controller is still able to connect to the switch and use the currently supported features. Without this change, the connection gets dropped if the switch implements a new feature, e.g. experimenter action, that is not yet supported by the controller. Change-Id: Ibb8d3e5d5bde35903277df923aeb226a42ff947b Signed-off-by: Renato Aguiar --- .../protocol/impl/util/ListDeserializer.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index 93d3c3e2..a53749c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -16,13 +16,18 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author michal.polkorab * */ public final class ListDeserializer { + private static final Logger LOG = LoggerFactory.getLogger(ListDeserializer.class); private ListDeserializer() { throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); @@ -53,7 +58,7 @@ public static List deserializeList(short version, int } /** - * Deserializes headers of items into list + * Deserializes headers of items into list (used in MultipartReplyMessage - Table features) * @param version openflow wire version * @param length length of list in ByteBuf (bytes) * @param input input buffer @@ -68,7 +73,15 @@ public static List deserializeHeaders(short version, i items = new ArrayList<>(); int startIndex = input.readerIndex(); while ((input.readerIndex() - startIndex) < length){ - HeaderDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); + HeaderDeserializer deserializer; + MessageCodeKey key = keyMaker.make(input); + try { + deserializer = registry.getDeserializer(key); + } catch (IllegalStateException e) { + LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", key); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + continue; + } E item = deserializer.deserializeHeader(input); items.add(item); } From 83f36f60aa2fed13e4a4fb38f8209eb29ac64b72 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 25 Nov 2015 15:09:21 +0100 Subject: [PATCH 206/285] Use odlparent's netty feature Instead of pulling n specific version of netty, pull in the feature from odlparent. Change-Id: Id954fa4179a93e9c9d3056e5b4252350bb6aab27 Signed-off-by: Robert Varga Signed-off-by: Stephen Kitt --- features/pom.xml | 15 +++++++++++++++ features/src/main/features/features.xml | 7 ++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index b6e92a39..4cc091be 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -32,6 +32,15 @@ pom
          + + + org.opendaylight.odlparent + odlparent-artifacts + 1.6.0-SNAPSHOT + import + pom + + org.opendaylight.mdsal @@ -97,6 +106,12 @@ features xml + + org.opendaylight.odlparent + features-odlparent + features + xml + diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 689c1927..111100a6 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -8,6 +8,7 @@ mvn:org.opendaylight.mdsal/features-mdsal/{{VERSION}}/xml/features mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features + mvn:org.opendaylight.odlparent/features-odlparent/{{VERSION}}/xml/features odl-openflowjava-protocol @@ -16,11 +17,7 @@ odl-mdsal-models odl-config-api odl-mdsal-common - mvn:io.netty/netty-buffer/{{VERSION}} - mvn:io.netty/netty-common/{{VERSION}} - mvn:io.netty/netty-transport/{{VERSION}} - mvn:io.netty/netty-codec/{{VERSION}} - mvn:io.netty/netty-handler/{{VERSION}} + odl-netty mvn:org.opendaylight.openflowjava/openflow-protocol-api/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} From 7d2311dd81ec104024944110b3d682cc5a63d1e8 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sun, 29 Nov 2015 17:23:09 -0500 Subject: [PATCH 207/285] Use odlparent-lite as artifacts parent We created odlparent-lite to provide a minimal pom which allows projects to publish to the correct server. Without this ${project}-artifacts may fail to deploy to Nexus. Change-Id: Ieb6f598818d0a7be91954a65a9878118682c12b1 Signed-off-by: Thanh Ha --- artifacts/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index eaa3779f..80abc2e6 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -10,6 +10,14 @@ 4.0.0 + + + org.opendaylight.odlparent + odlparent-lite + 1.6.0-SNAPSHOT + + + org.opendaylight.openflowjava openflowjava-artifacts 0.7.0-SNAPSHOT From 8910e62151c4a5b6285c38bf398b5a479b939fe2 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Wed, 9 Sep 2015 11:02:30 +0200 Subject: [PATCH 208/285] Barrier turn on/off-add switcher value to Config-Subsystem * use-barrier support * base trapnsport impl to ConnectionAdapter * fix tests Change-Id: I0ccb92cd9296880954a84dd9935a5273262840a1 Signed-off-by: Vaclav Demcak (cherry picked from commit 07ac625cae363f78ea5dd48356f617544c73913d) --- .../connection/ConnectionConfiguration.java | 5 ++ .../impl/core/ChannelInitializerFactory.java | 23 ++++-- .../impl/core/OFDatagramPacketHandler.java | 2 +- .../impl/core/ProtocolChannelInitializer.java | 18 ++++- .../core/SwitchConnectionProviderImpl.java | 79 +++++++++--------- .../impl/core/TcpChannelInitializer.java | 35 ++++---- .../connection/ConnectionAdapterFactory.java | 9 ++- .../ConnectionAdapterFactoryImpl.java | 8 +- .../connection/ConnectionAdapterImpl.java | 21 +++-- .../SwitchConnectionProviderModule.java | 12 ++- ...nflow-switch-connection-provider-impl.yang | 6 ++ .../PublishingChannelInitializerTest.java | 6 +- .../ChannelOutboundQueue02Test.java | 32 +++----- .../ConnectionAdapterFactoryImplTest.java | 12 +-- .../ConnectionAdapterImp02lTest.java | 27 +++---- .../ConnectionAdapterImpl02Test.java | 27 +++---- .../ConnectionAdapterImplStatisticsTest.java | 6 +- .../connection/ConnectionAdapterImplTest.java | 50 +++++------- .../ConnectionConfigurationImpl.java | 25 ++++-- .../SwitchConnectionProviderImpl02Test.java | 44 +++++----- .../SwitchConnectionProviderImplTest.java | 18 ++--- .../it/integration/IntegrationTest.java | 81 +++++++++---------- 22 files changed, 283 insertions(+), 263 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java index 310e0a5a..578e97b5 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionConfiguration.java @@ -50,4 +50,9 @@ public interface ConnectionConfiguration { * @return thread numbers for TcpHandler's eventloopGroups */ ThreadConfiguration getThreadConfiguration(); + + /** + * @return boolean value for usability of Barrier + */ + boolean useBarrier(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java index 042d4640..414f2c25 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java @@ -24,17 +24,19 @@ public class ChannelInitializerFactory { private SerializationFactory serializationFactory; private TlsConfiguration tlsConfig; private SwitchConnectionHandler switchConnectionHandler; + private boolean useBarrier; /** * @return PublishingChannelInitializer that initializes new channels */ public TcpChannelInitializer createPublishingChannelInitializer() { - TcpChannelInitializer initializer = new TcpChannelInitializer(); + final TcpChannelInitializer initializer = new TcpChannelInitializer(); initializer.setSwitchIdleTimeout(switchIdleTimeOut); initializer.setDeserializationFactory(deserializationFactory); initializer.setSerializationFactory(serializationFactory); initializer.setTlsConfiguration(tlsConfig); initializer.setSwitchConnectionHandler(switchConnectionHandler); + initializer.setUseBarrier(useBarrier); return initializer; } @@ -42,7 +44,7 @@ public TcpChannelInitializer createPublishingChannelInitializer() { * @return PublishingChannelInitializer that initializes new channels */ public UdpChannelInitializer createUdpChannelInitializer() { - UdpChannelInitializer initializer = new UdpChannelInitializer(); + final UdpChannelInitializer initializer = new UdpChannelInitializer(); initializer.setSwitchIdleTimeout(switchIdleTimeOut); initializer.setDeserializationFactory(deserializationFactory); initializer.setSerializationFactory(serializationFactory); @@ -53,35 +55,42 @@ public UdpChannelInitializer createUdpChannelInitializer() { /** * @param switchIdleTimeOut */ - public void setSwitchIdleTimeout(long switchIdleTimeOut) { + public void setSwitchIdleTimeout(final long switchIdleTimeOut) { this.switchIdleTimeOut = switchIdleTimeOut; } /** * @param deserializationFactory */ - public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { this.deserializationFactory = deserializationFactory; } /** * @param serializationFactory */ - public void setSerializationFactory(SerializationFactory serializationFactory) { + public void setSerializationFactory(final SerializationFactory serializationFactory) { this.serializationFactory = serializationFactory; } /** * @param tlsConfig */ - public void setTlsConfig(TlsConfiguration tlsConfig) { + public void setTlsConfig(final TlsConfiguration tlsConfig) { this.tlsConfig = tlsConfig; } /** * @param switchConnectionHandler */ - public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { + public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { this.switchConnectionHandler = switchConnectionHandler; } + + /** + * @param useBarrier + */ + public void setUseBarrier(final boolean useBarrier) { + this.useBarrier = useBarrier; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index ff805840..16068a5e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -62,7 +62,7 @@ protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); if (consumer == null) { ConnectionFacade connectionFacade = - adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); + adapterFactory.createConnectionFacade(ctx.channel(), msg.sender(), false); connectionHandler.onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); UdpConnectionMap.addConnection(msg.sender(), connectionFacade); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java index f450c064..ec4ffd4a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java @@ -10,7 +10,6 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; - import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; @@ -28,6 +27,7 @@ public abstract class ProtocolChannelInitializer private SerializationFactory serializationFactory; private DeserializationFactory deserializationFactory; private TlsConfiguration tlsConfiguration; + private boolean useBarrier; /** * @param switchConnectionHandler the switchConnectionHandler to set @@ -60,7 +60,7 @@ public void setDeserializationFactory(final DeserializationFactory deserializati /** * @param tlsConfiguration */ - public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { + public void setTlsConfiguration(final TlsConfiguration tlsConfiguration) { this.tlsConfiguration = tlsConfiguration; } @@ -98,4 +98,18 @@ public DeserializationFactory getDeserializationFactory() { public TlsConfiguration getTlsConfiguration() { return tlsConfiguration; } + + /** + * @param useBarrier + */ + public void setUseBarrier(final boolean useBarrier) { + this.useBarrier = useBarrier; + } + + /** + * @return useBarrrier + */ + public boolean useBarrier() { + return useBarrier; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 0217d1f2..f5a39eab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -62,10 +62,10 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C private SwitchConnectionHandler switchConnectionHandler; private ServerFacade serverFacade; private ConnectionConfiguration connConfig; - private SerializationFactory serializationFactory; - private SerializerRegistry serializerRegistry; - private DeserializerRegistry deserializerRegistry; - private DeserializationFactory deserializationFactory; + private final SerializationFactory serializationFactory; + private final SerializerRegistry serializerRegistry; + private final DeserializerRegistry deserializerRegistry; + private final DeserializationFactory deserializationFactory; private TcpConnectionInitializer connectionInitializer; /** Constructor */ @@ -81,12 +81,12 @@ public SwitchConnectionProviderImpl() { } @Override - public void setConfiguration(ConnectionConfiguration connConfig) { + public void setConfiguration(final ConnectionConfiguration connConfig) { this.connConfig = connConfig; } @Override - public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { + public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { LOGGER.debug("setSwitchConnectionHandler"); this.switchConnectionHandler = switchConnectionHandler; } @@ -112,8 +112,8 @@ public ListenableFuture startup() { } new Thread(serverFacade).start(); result = serverFacade.getIsOnlineFuture(); - } catch (Exception e) { - SettableFuture exResult = SettableFuture.create(); + } catch (final Exception e) { + final SettableFuture exResult = SettableFuture.create(); exResult.setException(e); result = exResult; } @@ -126,20 +126,21 @@ public ListenableFuture startup() { private ServerFacade createAndConfigureServer() { LOGGER.debug("Configuring .."); ServerFacade server = null; - ChannelInitializerFactory factory = new ChannelInitializerFactory(); + final ChannelInitializerFactory factory = new ChannelInitializerFactory(); factory.setSwitchConnectionHandler(switchConnectionHandler); factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout()); factory.setTlsConfig(connConfig.getTlsConfiguration()); factory.setSerializationFactory(serializationFactory); factory.setDeserializationFactory(deserializationFactory); - TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol(); + factory.setUseBarrier(connConfig.useBarrier()); + final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol(); if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); - TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer(); + final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer(); ((TcpHandler) server).setChannelInitializer(channelInitializer); ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration()); - NioEventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup(); + final NioEventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup(); connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler); connectionInitializer.setChannelInitializer(channelInitializer); connectionInitializer.run(); @@ -166,54 +167,54 @@ public void close() throws Exception { } @Override - public boolean unregisterSerializer(ExperimenterSerializerKey key) { + public boolean unregisterSerializer(final ExperimenterSerializerKey key) { return serializerRegistry.unregisterSerializer((MessageTypeKey) key); } @Override - public boolean unregisterDeserializer(ExperimenterDeserializerKey key) { + public boolean unregisterDeserializer(final ExperimenterDeserializerKey key) { return deserializerRegistry.unregisterDeserializer((MessageCodeKey) key); } @Override - public void registerActionSerializer(ActionSerializerKey key, - OFGeneralSerializer serializer) { + public void registerActionSerializer(final ActionSerializerKey key, + final OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void registerActionDeserializer(ExperimenterActionDeserializerKey key, - OFGeneralDeserializer deserializer) { + public void registerActionDeserializer(final ExperimenterActionDeserializerKey key, + final OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override - public void registerInstructionSerializer(InstructionSerializerKey key, - OFGeneralSerializer serializer) { + public void registerInstructionSerializer(final InstructionSerializerKey key, + final OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, - OFGeneralDeserializer deserializer) { + public void registerInstructionDeserializer(final ExperimenterInstructionDeserializerKey key, + final OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override - public void registerMatchEntrySerializer(MatchEntrySerializerKey key, - OFGeneralSerializer serializer) { + public void registerMatchEntrySerializer(final MatchEntrySerializerKey key, + final OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, - OFGeneralDeserializer deserializer) { + public void registerMatchEntryDeserializer(final MatchEntryDeserializerKey key, + final OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override - public void registerErrorDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer) { + public void registerErrorDeserializer(final ExperimenterIdDeserializerKey key, + final OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @@ -230,20 +231,20 @@ public void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializer } @Override - public void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, - OFGeneralDeserializer deserializer) { + public void registerMultipartReplyTFDeserializer(final ExperimenterIdDeserializerKey key, + final OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override - public void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer) { + public void registerQueuePropertyDeserializer(final ExperimenterIdDeserializerKey key, + final OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @Override - public void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer) { + public void registerMeterBandDeserializer(final ExperimenterIdDeserializerKey key, + final OFDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } @@ -260,19 +261,19 @@ public void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, - OFGeneralSerializer serializer) { + public void registerMultipartRequestTFSerializer(final ExperimenterIdSerializerKey key, + final OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void registerMeterBandSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer) { + public void registerMeterBandSerializer(final ExperimenterIdSerializerKey key, + final OFSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } @Override - public void initiateConnection(String host, int port) { + public void initiateConnection(final String host, final int port) { connectionInitializer.initiateConnection(host, port); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 3be9f96f..18566eb2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -12,15 +12,12 @@ import io.netty.channel.group.DefaultChannelGroup; import io.netty.channel.socket.SocketChannel; import io.netty.handler.ssl.SslHandler; - +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; import java.net.InetAddress; import java.util.Iterator; import java.util.concurrent.TimeUnit; - import javax.net.ssl.SSLEngine; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; @@ -36,7 +33,7 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer :{}", switchAddress.toString(), remotePort, port); @@ -72,7 +69,7 @@ protected void initChannel(final SocketChannel ch) { LOGGER.debug("Incoming connection accepted - building pipeline"); allChannels.add(ch); ConnectionFacade connectionFacade = null; - connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null); + connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null, useBarrier()); try { LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler()); getSwitchConnectionHandler().onSwitchConnected(connectionFacade); @@ -83,16 +80,16 @@ protected void initChannel(final SocketChannel ch) { // If this channel is configured to support SSL it will only support SSL if (getTlsConfiguration() != null) { tlsPresent = true; - SslContextFactory sslFactory = new SslContextFactory(getTlsConfiguration()); - SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); + final SslContextFactory sslFactory = new SslContextFactory(getTlsConfiguration()); + final SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); engine.setNeedClientAuth(true); engine.setUseClientMode(false); - SslHandler ssl = new SslHandler(engine); - Future handshakeFuture = ssl.handshakeFuture(); + final SslHandler ssl = new SslHandler(engine); + final Future handshakeFuture = ssl.handshakeFuture(); final ConnectionFacade finalConnectionFacade = connectionFacade; handshakeFuture.addListener(new GenericFutureListener>() { @Override - public void operationComplete(Future future) throws Exception { + public void operationComplete(final Future future) throws Exception { finalConnectionFacade.fireConnectionReadyNotification(); } }); @@ -101,17 +98,17 @@ public void operationComplete(Future future) throws Exception { ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(), new OFFrameDecoder(connectionFacade, tlsPresent)); ch.pipeline().addLast(PipelineHandlers.OF_VERSION_DETECTOR.name(), new OFVersionDetector()); - OFDecoder ofDecoder = new OFDecoder(); + final OFDecoder ofDecoder = new OFDecoder(); ofDecoder.setDeserializationFactory(getDeserializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_DECODER.name(), ofDecoder); - OFEncoder ofEncoder = new OFEncoder(); + final OFEncoder ofEncoder = new OFEncoder(); ofEncoder.setSerializationFactory(getSerializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofEncoder); ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); if (!tlsPresent) { connectionFacade.fireConnectionReadyNotification(); } - } catch (Exception e) { + } catch (final Exception e) { LOGGER.warn("Failed to initialize channel", e); ch.close(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java index 046e2917..1b0a83a7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import java.net.InetSocketAddress; - import io.netty.channel.Channel; +import java.net.InetSocketAddress; /** * @author mirehak @@ -20,9 +19,11 @@ public interface ConnectionAdapterFactory { /** - * @param ch + * @param ch {@link Channel} channel + * @param address {@link InetSocketAddress} + * @param useBarrier * @return connection adapter tcp-implementation */ - ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) ; + ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address, boolean useBarrier); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java index 5a67da8a..91871580 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import java.net.InetSocketAddress; - import io.netty.channel.Channel; +import java.net.InetSocketAddress; /** * @author mirehak @@ -24,8 +23,9 @@ public class ConnectionAdapterFactoryImpl implements ConnectionAdapterFactory { * @return connection adapter tcp-implementation */ @Override - public ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address) { - return new ConnectionAdapterImpl(ch, address); + public ConnectionFacade createConnectionFacade(final Channel ch, final InetSocketAddress address, + final boolean useBarrier) { + return new ConnectionAdapterImpl(ch, address, useBarrier); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 4a2d0b9d..81a9aceb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -122,20 +122,25 @@ public void onRemoval( private OFVersionDetector versionDetector; private final InetSocketAddress address; + private final boolean useBarrier; + /** * default ctor * @param channel the channel to be set - used for communication * @param address client address (used only in case of UDP communication, * as there is no need to store address over tcp (stable channel)) */ - public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address) { + public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address, final boolean useBarrier) { + this.channel = Preconditions.checkNotNull(channel); + this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); + this.address = address; + responseCache = CacheBuilder.newBuilder() .concurrencyLevel(1) .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); - this.channel = Preconditions.checkNotNull(channel); - this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); - this.address = address; + + this.useBarrier = useBarrier; channel.pipeline().addLast(output); statisticsCounters = StatisticsCounters.getInstance(); @@ -250,7 +255,7 @@ public Future> setAsync(final SetAsyncInput input) { @Override public Future disconnect() { - ChannelFuture disconnectResult = channel.disconnect(); + final ChannelFuture disconnectResult = channel.disconnect(); responseCache.invalidateAll(); disconnectOccured = true; @@ -328,7 +333,7 @@ public void consume(final DataObject message) { LOG.debug("OFheader msg received"); if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { - RpcResponseKey key = createRpcResponseKey((OfHeader) message); + final RpcResponseKey key = createRpcResponseKey((OfHeader) message); final ResponseExpectedRpcListener listener = findRpcResponse(key); if (listener != null) { LOG.debug("corresponding rpcFuture found"); @@ -508,6 +513,10 @@ public OutboundQueueHandlerRegistration regi final T handler, final int maxQueueDepth, final long maxBarrierNanos) { Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager); + if (useBarrier) { + + } + final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); outputManager = ret; channel.pipeline().addLast(outputManager); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 9cbd9c96..6077c787 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -58,11 +58,11 @@ protected void customValidation(){ @Override public java.lang.AutoCloseable createInstance() { LOG.info("SwitchConnectionProvider started."); - SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); + final SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); try { - ConnectionConfiguration connConfiguration = createConnectionConfiguration(); + final ConnectionConfiguration connConfiguration = createConnectionConfiguration(); switchConnectionProviderImpl.setConfiguration(connConfiguration); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { throw new IllegalArgumentException(e.getMessage(), e); } return switchConnectionProviderImpl; @@ -78,6 +78,7 @@ private ConnectionConfiguration createConnectionConfiguration() throws UnknownHo final long switchIdleTimeout = getSwitchIdleTimeout(); final Tls tlsConfig = getTls(); final Threads threads = getThreads(); + final Boolean useBarrier = getUseBarrier(); final TransportProtocol transportProtocol = getTransportProtocol(); return new ConnectionConfiguration() { @@ -164,6 +165,11 @@ public int getBossThreadCount() { } }; } + + @Override + public boolean useBarrier() { + return useBarrier; + } }; } diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index 2f80d957..aead1758 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -35,6 +35,12 @@ module openflow-switch-connection-provider-impl { case openflow-switch-connection-provider-impl { when "/config:modules/config:module/config:type = 'openflow-switch-connection-provider-impl'"; + leaf use-barrier { + description "Enable barrier in Openflow java"; + type boolean; + default true; + } + leaf port { description "local listening port"; type uint16; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index 3d8717c7..bcd2ebb9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -20,13 +20,10 @@ import io.netty.channel.group.DefaultChannelGroup; import io.netty.channel.socket.SocketChannel; import io.netty.handler.ssl.SslHandler; - import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; - import javax.net.ssl.SSLEngine; - import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -76,13 +73,14 @@ public void setUp() throws Exception { pubChInitializer.setDeserializationFactory(mockDeserializationFactory); pubChInitializer.setSwitchIdleTimeout(1) ; pubChInitializer.getConnectionIterator() ; + pubChInitializer.setUseBarrier(true); when( mockChGrp.size()).thenReturn(1) ; pubChInitializer.setSwitchConnectionHandler( mockSwConnHandler ) ; inetSockAddr = new InetSocketAddress(InetAddress.getLocalHost(), 8675 ) ; - when(mockConnAdaptorFactory.createConnectionFacade(mockSocketCh, null)) + when(mockConnAdaptorFactory.createConnectionFacade(mockSocketCh, null, true)) .thenReturn(mockConnFacade); when(mockSocketCh.remoteAddress()).thenReturn(inetSockAddr) ; when(mockSocketCh.localAddress()).thenReturn(inetSockAddr) ; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java index ccc24e55..5f080dc5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue02Test.java @@ -7,36 +7,28 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; - import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; - import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - /** * @author madamjak * @@ -82,12 +74,12 @@ public void tierDown(){ */ @Test public void test01() throws Exception { - EmbeddedChannel ec = new EmbeddedChannel(new EmbededChannelHandler()); - adapter = new ConnectionAdapterImpl(ec,InetSocketAddress.createUnresolved("localhost", 9876)); + final EmbeddedChannel ec = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(ec, InetSocketAddress.createUnresolved("localhost", 9876), true); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); - ChannelOutboundQueue cq = (ChannelOutboundQueue) ec.pipeline().last(); + final ChannelOutboundQueue cq = (ChannelOutboundQueue) ec.pipeline().last(); counter=0; adapter.barrier(barrierInput); adapter.echo(echoInput); @@ -107,8 +99,8 @@ public void test01() throws Exception { */ @Test public void test02(){ - ChangeWritableEmbededChannel ec = new ChangeWritableEmbededChannel(new EmbededChannelHandler()); - adapter = new ConnectionAdapterImpl(ec,InetSocketAddress.createUnresolved("localhost", 9876)); + final ChangeWritableEmbededChannel ec = new ChangeWritableEmbededChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(ec, InetSocketAddress.createUnresolved("localhost", 9876), true); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); @@ -132,8 +124,8 @@ public void test02(){ */ private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { @Override - public void write(ChannelHandlerContext ctx, Object msg, - ChannelPromise promise) throws Exception { + public void write(final ChannelHandlerContext ctx, final Object msg, + final ChannelPromise promise) throws Exception { if(msg instanceof MessageListenerWrapper){ counter++; } @@ -147,7 +139,7 @@ public void write(ChannelHandlerContext ctx, Object msg, */ private class ChangeWritableEmbededChannel extends EmbeddedChannel { private boolean isWrittable; - public ChangeWritableEmbededChannel(ChannelHandler channelHandler){ + public ChangeWritableEmbededChannel(final ChannelHandler channelHandler){ super(channelHandler); setReadOnly(); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java index a7e9904e..e3317e32 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImplTest.java @@ -10,16 +10,12 @@ import static org.mockito.Mockito.when; import io.netty.channel.Channel; import io.netty.channel.ChannelPipeline; - import java.net.InetSocketAddress; - -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; /** * * @author madamjak @@ -39,8 +35,8 @@ public void startUp(){ @Test public void test(){ - ConnectionAdapterFactoryImpl connAdapterFactory = new ConnectionAdapterFactoryImpl(); - ConnectionFacade connFacade = connAdapterFactory.createConnectionFacade(channel, address); + final ConnectionAdapterFactoryImpl connAdapterFactory = new ConnectionAdapterFactoryImpl(); + final ConnectionFacade connFacade = connAdapterFactory.createConnectionFacade(channel, address, true); Assert.assertNotNull("Wrong - ConnectionFacade has not created.", connFacade); Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionFacade.isAlive()", channel.isOpen(), connFacade.isAlive()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java index 7088bc09..0909547c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImp02lTest.java @@ -7,24 +7,22 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; - import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; - import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -46,11 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - /** * @author madamjak * @author michal.polkorab @@ -109,8 +102,8 @@ public void tierDown(){ */ @Test public void testRcp() { - EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); - adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + final EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel, InetSocketAddress.createUnresolved("localhost", 9876), true); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); @@ -200,12 +193,12 @@ public void testRcp() { */ private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { @Override - public void write(ChannelHandlerContext ctx, Object msg, - ChannelPromise promise) throws Exception { + public void write(final ChannelHandlerContext ctx, final Object msg, + final ChannelPromise promise) throws Exception { responseOfCall = null; if(msg instanceof MessageListenerWrapper){ - MessageListenerWrapper listener = (MessageListenerWrapper) msg; - OfHeader ofHeader = listener.getMsg(); + final MessageListenerWrapper listener = (MessageListenerWrapper) msg; + final OfHeader ofHeader = listener.getMsg(); responseOfCall = ofHeader; } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java index 55c3945d..07860095 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl02Test.java @@ -7,24 +7,22 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; - import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; - import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -46,11 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - /** * @author madamjak * @author michal.polkorab @@ -109,8 +102,8 @@ public void tierDown(){ */ @Test public void testRcp() { - EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); - adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + final EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel, InetSocketAddress.createUnresolved("localhost", 9876), true); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); @@ -200,12 +193,12 @@ public void testRcp() { */ private class EmbededChannelHandler extends ChannelOutboundHandlerAdapter { @Override - public void write(ChannelHandlerContext ctx, Object msg, - ChannelPromise promise) throws Exception { + public void write(final ChannelHandlerContext ctx, final Object msg, + final ChannelPromise promise) throws Exception { responseOfCall = null; if(msg instanceof MessageListenerWrapper){ - MessageListenerWrapper listener = (MessageListenerWrapper) msg; - OfHeader ofHeader = listener.getMsg(); + final MessageListenerWrapper listener = (MessageListenerWrapper) msg; + final OfHeader ofHeader = listener.getMsg(); responseOfCall = ofHeader; } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java index 862de53d..706c624e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplStatisticsTest.java @@ -141,8 +141,8 @@ public void testEnterOFJavaCounter() { if(!statCounters.isCounterEnabled(CounterEventTypes.DS_FLOW_MODS_ENTERED)){ Assert.fail("Counter " + CounterEventTypes.DS_FLOW_MODS_ENTERED + " is not enabled"); } - EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); - adapter = new ConnectionAdapterImpl(embChannel,InetSocketAddress.createUnresolved("localhost", 9876)); + final EmbeddedChannel embChannel = new EmbeddedChannel(new EmbededChannelHandler()); + adapter = new ConnectionAdapterImpl(embChannel, InetSocketAddress.createUnresolved("localhost", 9876), true); cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); @@ -198,7 +198,7 @@ public void testMessagePassCounter() { Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled"); } when(channel.pipeline()).thenReturn(pipeline); - adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true); adapter.setMessageListener(messageListener); adapter.setSystemListener(systemListener); adapter.setConnectionReadyListener(readyListener); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java index c9f52772..0859a34f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java @@ -12,13 +12,15 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelPipeline; import io.netty.channel.socket.SocketChannel; - import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,9 +28,6 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; @@ -58,11 +57,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - /** * @author michal.polkorab * @author madamjak @@ -98,7 +92,7 @@ public void onRemoval( public void setUp() { MockitoAnnotations.initMocks(this); when(channel.pipeline()).thenReturn(pipeline); - adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true); adapter.setMessageListener(messageListener); adapter.setSystemListener(systemListener); adapter.setConnectionReadyListener(readyListener); @@ -154,9 +148,9 @@ public void testConsume() { @Test public void testConsume2() { adapter.setResponseCache(mockCache); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + final BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); barrierBuilder.setXid(42L); - BarrierOutput barrier = barrierBuilder.build(); + final BarrierOutput barrier = barrierBuilder.build(); adapter.consume(barrier); verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); } @@ -166,19 +160,19 @@ public void testConsume2() { */ @Test public void testConsume3() { - BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); + final BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); inputBuilder.setXid(42L); - BarrierInput barrierInput = inputBuilder.build(); - RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); - ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, + final BarrierInput barrierInput = inputBuilder.build(); + final RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); + final ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, "failure", mockCache, key); cache.put(key, listener); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + final BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); barrierBuilder.setXid(42L); - BarrierOutput barrierOutput = barrierBuilder.build(); + final BarrierOutput barrierOutput = barrierBuilder.build(); adapter.consume(barrierOutput); - ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); + final ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); Assert.assertNull("Listener was not discarded", ifPresent); } /** @@ -186,10 +180,10 @@ public void testConsume3() { */ @Test public void testIsAlive(){ - int port = 9876; - String host ="localhost"; - InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); - ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel,inetSockAddr); + final int port = 9876; + final String host ="localhost"; + final InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + final ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel, inetSockAddr, true); Assert.assertEquals("Wrong - diffrence between channel.isOpen() and ConnectionAdapterImpl.isAlive()", channel.isOpen(), connAddapter.isAlive()); connAddapter.disconnect(); @@ -201,10 +195,10 @@ public void testIsAlive(){ */ @Test(expected = java.lang.IllegalStateException.class) public void testMissingListeners(){ - int port = 9876; - String host ="localhost"; - InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); - ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel,inetSockAddr); + final int port = 9876; + final String host ="localhost"; + final InetSocketAddress inetSockAddr = InetSocketAddress.createUnresolved(host, port); + final ConnectionAdapterImpl connAddapter = new ConnectionAdapterImpl(channel, inetSockAddr, true); connAddapter.setSystemListener(null); connAddapter.setMessageListener(null); connAddapter.setConnectionReadyListener(null); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java index 76936754..b4097dda 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionConfigurationImpl.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import java.net.InetAddress; - import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; @@ -21,25 +20,30 @@ */ public class ConnectionConfigurationImpl implements ConnectionConfiguration { - private InetAddress address; - private int port; + private final InetAddress address; + private final int port; private Object transferProtocol; - private TlsConfiguration tlsConfig; - private long switchIdleTimeout; + private final TlsConfiguration tlsConfig; + private final long switchIdleTimeout; private ThreadConfiguration threadConfig; + private final boolean useBarrier; /** * Creates {@link ConnectionConfigurationImpl} + * * @param address * @param port * @param tlsConfig * @param switchIdleTimeout + * @param useBarrier */ - public ConnectionConfigurationImpl(InetAddress address, int port, TlsConfiguration tlsConfig, long switchIdleTimeout) { + public ConnectionConfigurationImpl(final InetAddress address, final int port, final TlsConfiguration tlsConfig, + final long switchIdleTimeout, final boolean useBarrier) { this.address = address; this.port = port; this.tlsConfig = tlsConfig; this.switchIdleTimeout = switchIdleTimeout; + this.useBarrier = useBarrier; } @Override @@ -61,7 +65,7 @@ public Object getTransferProtocol() { * Used for testing - sets transport protocol * @param protocol */ - public void setTransferProtocol(TransportProtocol protocol) { + public void setTransferProtocol(final TransportProtocol protocol) { this.transferProtocol = protocol; } @@ -89,7 +93,12 @@ public ThreadConfiguration getThreadConfiguration() { /** * @param threadConfig thread model configuration (configures threads used) */ - public void setThreadConfiguration(ThreadConfiguration threadConfig) { + public void setThreadConfiguration(final ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } + + @Override + public boolean useBarrier() { + return useBarrier; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 73237c4a..447f464b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -73,7 +73,7 @@ public class SwitchConnectionProviderImpl02Test { * Creates new {@link SwitchConnectionProvider} instance for each test * @param protocol communication protocol */ - public void startUp(TransportProtocol protocol) { + public void startUp(final TransportProtocol protocol) { MockitoAnnotations.initMocks(this); config = null; if (protocol != null) { @@ -82,10 +82,10 @@ public void startUp(TransportProtocol protocol) { provider = new SwitchConnectionProviderImpl(); } - private void createConfig(TransportProtocol protocol) { + private void createConfig(final TransportProtocol protocol) { try { startupAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { e.printStackTrace(); } tlsConfiguration = null; @@ -94,7 +94,7 @@ private void createConfig(TransportProtocol protocol) { "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH) ; } - config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); config.setTransferProtocol(protocol); } @@ -106,8 +106,8 @@ private void createConfig(TransportProtocol protocol) { public void testServerFacade(){ startUp(TransportProtocol.TCP); provider.setConfiguration(config); - ListenableFuture future = provider.startup(); - ServerFacade serverFacade = provider.getServerFacade(); + final ListenableFuture future = provider.startup(); + final ServerFacade serverFacade = provider.getServerFacade(); Assert.assertNotNull("Wrong -- getServerFacade return null",serverFacade); } @@ -126,10 +126,10 @@ public void testShutdownUnconfigured(){ public void testUnregisterWrongKeys(){ startUp(TransportProtocol.TCP); provider.setConfiguration(config); - ExperimenterInstructionSerializerKey testSerKey + final ExperimenterInstructionSerializerKey testSerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); Assert.assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey)); - ExperimenterInstructionDeserializerKey tesDeserKey + final ExperimenterInstructionDeserializerKey tesDeserKey = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,24L); Assert.assertFalse("Wrong -- unregisterDeserializer",provider.unregisterDeserializer(tesDeserKey)); } @@ -142,67 +142,67 @@ public void testUnregisterExistingKeys(){ startUp(TransportProtocol.TCP); provider.setConfiguration(config); // -- registerActionSerializer - ExperimenterActionSerializerKey key1 + final ExperimenterActionSerializerKey key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); provider.registerActionSerializer(key1, serializer); Assert.assertTrue("Wrong -- unregister ActionSerializer", provider.unregisterSerializer(key1)); Assert.assertFalse("Wrong -- unregister ActionSerializer by not existing key", provider.unregisterSerializer(key1)); // -- registerActionDeserializer - ExperimenterActionDeserializerKey key2 + final ExperimenterActionDeserializerKey key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); provider.registerActionDeserializer(key2, deserializer); Assert.assertTrue("Wrong -- unregister ActionDeserializer", provider.unregisterDeserializer(key2)); Assert.assertFalse("Wrong -- unregister ActionDeserializer by not existing key", provider.unregisterDeserializer(key2)); // -- registerInstructionSerializer - ExperimenterInstructionSerializerKey key3 + final ExperimenterInstructionSerializerKey key3 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID,42L); provider.registerInstructionSerializer(key3, serializer); Assert.assertTrue("Wrong -- unregister InstructionSerializer", provider.unregisterSerializer(key3)); Assert.assertFalse("Wrong -- unregister InstructionSerializer by not existing key", provider.unregisterSerializer(key3)); // -- registerInstructionDeserializer - ExperimenterInstructionDeserializerKey key4 + final ExperimenterInstructionDeserializerKey key4 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID,42L); provider.registerInstructionDeserializer(key4, deserializer); Assert.assertTrue("Wrong -- unregister InstructionDeserializer", provider.unregisterDeserializer(key4)); Assert.assertFalse("Wrong -- unregister InstructionDeserializer by not existing key", provider.unregisterDeserializer(key4)); // -- registerMatchEntryDeserializer - MatchEntryDeserializerKey key5 + final MatchEntryDeserializerKey key5 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); provider.registerMatchEntryDeserializer(key5, deserializer); Assert.assertTrue("Wrong -- unregister MatchEntryDeserializer", provider.unregisterDeserializer(key5)); Assert.assertFalse("Wrong -- unregister MatchEntryDeserializer by not existing key", provider.unregisterDeserializer(key5)); // -- registerErrorDeserializer - ExperimenterIdDeserializerKey key6 + final ExperimenterIdDeserializerKey key6 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); provider.registerErrorDeserializer(key6, deserializerError); Assert.assertTrue("Wrong -- unregister ErrorDeserializer", provider.unregisterDeserializer(key6)); Assert.assertFalse("Wrong -- unregister ErrorDeserializer by not existing key", provider.unregisterDeserializer(key6)); // -- registerExperimenterMessageDeserializer - ExperimenterIdDeserializerKey key7 + final ExperimenterIdDeserializerKey key7 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); provider.registerExperimenterMessageDeserializer(key7, deserializerExpMsg); Assert.assertTrue("Wrong -- unregister ExperimenterMessageDeserializer", provider.unregisterDeserializer(key7)); Assert.assertFalse("Wrong -- unregister ExperimenterMessageDeserializer by not existing key", provider.unregisterDeserializer(key7)); // -- registerMultipartReplyMessageDeserializer - ExperimenterIdDeserializerKey key8 + final ExperimenterIdDeserializerKey key8 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MultipartReplyMessage.class); provider.registerMultipartReplyMessageDeserializer(key8, deserializerMultipartRplMsg); Assert.assertTrue("Wrong -- unregister MultipartReplyMessageDeserializer", provider.unregisterDeserializer(key8)); Assert.assertFalse("Wrong -- unregister MultipartReplyMessageDeserializer by not existing key", provider.unregisterDeserializer(key8)); // -- registerMultipartReplyTFDeserializer - ExperimenterIdDeserializerKey key9 = + final ExperimenterIdDeserializerKey key9 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MultipartReplyMessage.class); provider.registerMultipartReplyTFDeserializer(key9, deserializer); Assert.assertTrue("Wrong -- unregister MultipartReplyTFDeserializer", provider.unregisterDeserializer(key9)); Assert.assertFalse("Wrong -- unregister MultipartReplyTFDeserializer by non existing key", provider.unregisterDeserializer(key9)); // -- registerQueuePropertyDeserializer - ExperimenterIdDeserializerKey key10 + final ExperimenterIdDeserializerKey key10 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, QueueProperty.class); provider.registerQueuePropertyDeserializer(key10, deserializerQueueProperty); Assert.assertTrue("Wrong -- unregister QueuePropertyDeserializer", provider.unregisterDeserializer(key10)); Assert.assertFalse("Wrong -- unregister QueuePropertyDeserializer by not existing key", provider.unregisterDeserializer(key10)); // -- registerMeterBandDeserializer - ExperimenterIdDeserializerKey key11 + final ExperimenterIdDeserializerKey key11 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, MeterBandExperimenterCase.class); provider.registerMeterBandDeserializer(key11, deserializerMeterBandExpCase); Assert.assertTrue("Wrong -- unregister MeterBandDeserializer", provider.unregisterDeserializer(key11)); @@ -220,19 +220,19 @@ public void testUnregisterExistingKeys(){ Assert.assertTrue("Wrong -- unregister MultipartRequestSerializer", provider.unregisterSerializer(key13)); Assert.assertFalse("Wrong -- unregister MultipartRequestSerializer by not existing key", provider.unregisterSerializer(key13)); // -- registerMultipartRequestTFSerializer - ExperimenterIdSerializerKey key14 + final ExperimenterIdSerializerKey key14 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,TableFeatureProperties.class); provider.registerMultipartRequestTFSerializer(key14, serializer); Assert.assertTrue("Wrong -- unregister MultipartRequestTFSerializer", provider.unregisterSerializer(key14)); Assert.assertFalse("Wrong -- unregister MultipartRequestTFSerializer by not existing key", provider.unregisterSerializer(key14)); // -- registerMeterBandSerializer - ExperimenterIdSerializerKey key15 + final ExperimenterIdSerializerKey key15 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MeterBandExperimenterCase.class); provider.registerMeterBandSerializer(key15, serializerMeterBandExpCase); Assert.assertTrue("Wrong -- unregister MeterBandSerializer", provider.unregisterSerializer(key15)); Assert.assertFalse("Wrong -- unregister MeterBandSerializer by not existing key", provider.unregisterSerializer(key15)); // -- registerMatchEntrySerializer - MatchEntrySerializerKey key16 + final MatchEntrySerializerKey key16 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); provider.registerMatchEntrySerializer(key16, serializer); Assert.assertTrue("Wrong -- unregister MatchEntrySerializer", provider.unregisterSerializer(key16)); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 8fa76e80..3b53eed6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -8,12 +8,12 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.junit.Assert; import org.junit.Test; import org.mockito.Mock; @@ -27,8 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; -import com.google.common.util.concurrent.ListenableFuture; - /** * @author michal.polkorab * @@ -48,7 +46,7 @@ public class SwitchConnectionProviderImplTest { * Creates new {@link SwitchConnectionProvider} instance for each test * @param protocol communication protocol */ - public void startUp(TransportProtocol protocol) { + public void startUp(final TransportProtocol protocol) { MockitoAnnotations.initMocks(this); config = null; if (protocol != null) { @@ -57,10 +55,10 @@ public void startUp(TransportProtocol protocol) { provider = new SwitchConnectionProviderImpl(); } - private void createConfig(TransportProtocol protocol) { + private void createConfig(final TransportProtocol protocol) { try { startupAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { + } catch (final UnknownHostException e) { e.printStackTrace(); } tlsConfiguration = null; @@ -69,7 +67,7 @@ private void createConfig(TransportProtocol protocol) { "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH) ; } - config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); config.setTransferProtocol(protocol); } @@ -79,7 +77,7 @@ private void createConfig(TransportProtocol protocol) { @Test public void testStartup1() { provider = new SwitchConnectionProviderImpl(); - ListenableFuture future = provider.startup(); + final ListenableFuture future = provider.startup(); try { future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { @@ -94,7 +92,7 @@ public void testStartup1() { public void testStartup2() { startUp(null); provider.setSwitchConnectionHandler(handler); - ListenableFuture future = provider.startup(); + final ListenableFuture future = provider.startup(); try { future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { @@ -109,7 +107,7 @@ public void testStartup2() { public void testStartup3() { startUp(TransportProtocol.TCP); provider.setConfiguration(config); - ListenableFuture future = provider.startup(); + final ListenableFuture future = provider.startup(); try { future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index 54ccb37e..e10d12de 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; - import org.junit.After; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; @@ -65,10 +64,10 @@ private enum ClientType {SIMPLE, LISTENING} * @param protocol communication protocol to be used during test * @throws Exception */ - public void setUp(TransportProtocol protocol) throws Exception { + public void setUp(final TransportProtocol protocol) throws Exception { LOGGER.debug("\n starting test -------------------------------"); - String currentDir = System.getProperty("user.dir"); + final String currentDir = System.getProperty("user.dir"); LOGGER.debug("Current dir using System: {}", currentDir); startupAddress = InetAddress.getLocalHost(); tlsConfiguration = null; @@ -77,7 +76,7 @@ public void setUp(TransportProtocol protocol) throws Exception { "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH) ; } - connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); connConfig.setTransferProtocol(protocol); mockPlugin = new MockPlugin(); @@ -86,10 +85,10 @@ public void setUp(TransportProtocol protocol) throws Exception { switchConnectionProvider.setConfiguration(connConfig); switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); if (protocol.equals(TransportProtocol.TCP) || protocol.equals(TransportProtocol.TLS)) { - TcpHandler tcpHandler = (TcpHandler) switchConnectionProvider.getServerFacade(); + final TcpHandler tcpHandler = (TcpHandler) switchConnectionProvider.getServerFacade(); port = tcpHandler.getPort(); } else { - UdpHandler udpHandler = (UdpHandler) switchConnectionProvider.getServerFacade(); + final UdpHandler udpHandler = (UdpHandler) switchConnectionProvider.getServerFacade(); port = udpHandler.getPort(); } } @@ -110,11 +109,11 @@ public void tearDown() throws Exception { @Test public void testHandshake() throws Exception { setUp(TransportProtocol.TCP); - int amountOfCLients = 1; - Deque scenario = ScenarioFactory.createHandshakeScenario(); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); - OFClient firstClient = clients.get(0); + final int amountOfCLients = 1; + final Deque scenario = ScenarioFactory.createHandshakeScenario(); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); + final OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -128,11 +127,11 @@ public void testHandshake() throws Exception { @Test public void testTlsHandshake() throws Exception { setUp(TransportProtocol.TLS); - int amountOfCLients = 1; - Deque scenario = ScenarioFactory.createHandshakeScenario(); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); - OFClient firstClient = clients.get(0); + final int amountOfCLients = 1; + final Deque scenario = ScenarioFactory.createHandshakeScenario(); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); + final OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); Thread.sleep(1000); @@ -146,15 +145,15 @@ public void testTlsHandshake() throws Exception { @Test public void testHandshakeAndEcho() throws Exception { setUp(TransportProtocol.TCP); - int amountOfCLients = 1; - Deque scenario = ScenarioFactory.createHandshakeScenario(); + final int amountOfCLients = 1; + final Deque scenario = ScenarioFactory.createHandshakeScenario(); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); - OFClient firstClient = clients.get(0); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE); + final OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); LOGGER.debug("testHandshakeAndEcho() Finished") ; @@ -167,15 +166,15 @@ public void testHandshakeAndEcho() throws Exception { @Test public void testTlsHandshakeAndEcho() throws Exception { setUp(TransportProtocol.TLS); - int amountOfCLients = 1; - Deque scenario = ScenarioFactory.createHandshakeScenario(); + final int amountOfCLients = 1; + final Deque scenario = ScenarioFactory.createHandshakeScenario(); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); - OFClient firstClient = clients.get(0); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE); + final OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); LOGGER.debug("testTlsHandshakeAndEcho() Finished") ; @@ -188,15 +187,15 @@ public void testTlsHandshakeAndEcho() throws Exception { @Test public void testUdpHandshakeAndEcho() throws Exception { setUp(TransportProtocol.UDP); - int amountOfCLients = 1; - Deque scenario = ScenarioFactory.createHandshakeScenario(); + final int amountOfCLients = 1; + final Deque scenario = ScenarioFactory.createHandshakeScenario(); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04"))); scenario.addFirst(new SleepEvent(1000)); scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04"))); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE); - OFClient firstClient = clients.get(0); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE); + final OFClient firstClient = clients.get(0); firstClient.getScenarioDone().get(); LOGGER.debug("testUdpHandshakeAndEcho() Finished") ; @@ -217,9 +216,9 @@ public void testCommunicationWithVM() throws Exception { * @return new clients up and running * @throws ExecutionException if some client could not start */ - private List createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler, - TransportProtocol protocol, ClientType clientType) throws ExecutionException { - List clientsHorde = new ArrayList<>(); + private List createAndStartClient(final int amountOfCLients, final ScenarioHandler scenarioHandler, + final TransportProtocol protocol, final ClientType clientType) throws ExecutionException { + final List clientsHorde = new ArrayList<>(); for (int i = 0; i < amountOfCLients; i++) { LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress()); OFClient sc = null; @@ -248,10 +247,10 @@ private List createAndStartClient(int amountOfCLients, ScenarioHandler t = new Thread(sc); t.start(); } - for (OFClient sc : clientsHorde) { + for (final OFClient sc : clientsHorde) { try { sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (Exception e) { + } catch (final Exception e) { LOGGER.error("createAndStartClient: Something borked ... ", e.getMessage(), e); throw new ExecutionException(e); } @@ -266,12 +265,12 @@ private List createAndStartClient(int amountOfCLients, ScenarioHandler public void testInitiateConnection() throws Exception { setUp(TransportProtocol.TCP); - Deque scenario = ScenarioFactory.createHandshakeScenario(); - ScenarioHandler handler = new ScenarioHandler(scenario); - List clients = createAndStartClient(1, handler, TransportProtocol.TCP, ClientType.LISTENING); - OFClient ofClient = clients.get(0); + final Deque scenario = ScenarioFactory.createHandshakeScenario(); + final ScenarioHandler handler = new ScenarioHandler(scenario); + final List clients = createAndStartClient(1, handler, TransportProtocol.TCP, ClientType.LISTENING); + final OFClient ofClient = clients.get(0); ofClient.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS); - int listeningClientPort = ((ListeningSimpleClient) ofClient).getPort(); + final int listeningClientPort = ((ListeningSimpleClient) ofClient).getPort(); mockPlugin.initiateConnection(switchConnectionProvider, "localhost", listeningClientPort); ofClient.getScenarioDone().get(); LOGGER.debug("testInitiateConnection() Finished") ; From cccc72339d6c385d4d7aa09786a4ea241321a0e1 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Fri, 25 Sep 2015 00:06:54 +0200 Subject: [PATCH 209/285] Barrier turn on/off - Split ConnectionAdapter functionality Split ConnectionAdapter functionaly to Abstract parents for clean implementation * add AbstractConnectionAdapter primary implement OpenflowProtocolSevice * add AbstractConnectionAdapterStatistics StatCouter wrapper Change-Id: Ibfd809d6bc7e2e95339f7c21e26958306b157d41 Signed-off-by: Vaclav Demcak (cherry picked from commit e35d417dacc1bf002076e432b575931e15769f65) --- .../connection/AbstractConnectionAdapter.java | 331 +++++++++++++++++ .../AbstractConnectionAdapterStatistics.java | 78 ++++ .../connection/ConnectionAdapterImpl.java | 349 +----------------- 3 files changed, 424 insertions(+), 334 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapterStatistics.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java new file mode 100644 index 00000000..57f1498c --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalCause; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; +import java.util.concurrent.Future; +import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * {@link ConnectionAdapter} interface contains couple of OF message handling approaches. + * {@link AbstractConnectionAdapter} class contains direct RPC processing from OpenflowProtocolService + * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService} + */ +abstract class AbstractConnectionAdapter implements ConnectionAdapter { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractConnectionAdapter.class); + + /** after this time, RPC future response objects will be thrown away (in minutes) */ + private static final int RPC_RESPONSE_EXPIRATION = 1; + + private static final Exception QUEUE_FULL_EXCEPTION = new RejectedExecutionException("Output queue is full"); + + /** + * Default depth of write queue, e.g. we allow these many messages + * to be queued up before blocking producers. + */ + private static final int DEFAULT_QUEUE_DEPTH = 1024; + + protected static final RemovalListener> REMOVAL_LISTENER = new RemovalListener>() { + @Override + public void onRemoval(final RemovalNotification> notification) { + if (!notification.getCause().equals(RemovalCause.EXPLICIT)) { + notification.getValue().discard(); + } + } + }; + + protected final Channel channel; + protected final InetSocketAddress address; + protected boolean disconnectOccured = false; + protected final ChannelOutboundQueue output; + + /** expiring cache for future rpcResponses */ + protected Cache> responseCache; + + + AbstractConnectionAdapter(@Nonnull final Channel channel, @Nullable final InetSocketAddress address) { + this.channel = Preconditions.checkNotNull(channel); + this.address = address; + + responseCache = CacheBuilder.newBuilder().concurrencyLevel(1) + .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES).removalListener(REMOVAL_LISTENER).build(); + this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); + channel.pipeline().addLast(output); + } + + @Override + public Future disconnect() { + final ChannelFuture disconnectResult = channel.disconnect(); + responseCache.invalidateAll(); + disconnectOccured = true; + + return handleTransportChannelFuture(disconnectResult); + } + + @Override + public Future> barrier(final BarrierInput input) { + return sendToSwitchExpectRpcResultFuture(input, BarrierOutput.class, "barrier-input sending failed"); + } + + @Override + public Future> echo(final EchoInput input) { + return sendToSwitchExpectRpcResultFuture(input, EchoOutput.class, "echo-input sending failed"); + } + + @Override + public Future> echoReply(final EchoReplyInput input) { + return sendToSwitchFuture(input, "echo-reply sending failed"); + } + + @Override + public Future> experimenter(final ExperimenterInput input) { + return sendToSwitchFuture(input, "experimenter sending failed"); + } + + @Override + public Future> flowMod(final FlowModInput input) { + return sendToSwitchFuture(input, "flow-mod sending failed"); + } + + @Override + public Future> getConfig(final GetConfigInput input) { + return sendToSwitchExpectRpcResultFuture(input, GetConfigOutput.class, "get-config-input sending failed"); + } + + @Override + public Future> getFeatures(final GetFeaturesInput input) { + return sendToSwitchExpectRpcResultFuture(input, GetFeaturesOutput.class, "get-features-input sending failed"); + } + + @Override + public Future> getQueueConfig(final GetQueueConfigInput input) { + return sendToSwitchExpectRpcResultFuture(input, GetQueueConfigOutput.class, + "get-queue-config-input sending failed"); + } + + @Override + public Future> groupMod(final GroupModInput input) { + return sendToSwitchFuture(input, "group-mod-input sending failed"); + } + + @Override + public Future> hello(final HelloInput input) { + return sendToSwitchFuture(input, "hello-input sending failed"); + } + + @Override + public Future> meterMod(final MeterModInput input) { + return sendToSwitchFuture(input, "meter-mod-input sending failed"); + } + + @Override + public Future> packetOut(final PacketOutInput input) { + return sendToSwitchFuture(input, "packet-out-input sending failed"); + } + + @Override + public Future> multipartRequest(final MultipartRequestInput input) { + return sendToSwitchFuture(input, "multi-part-request sending failed"); + } + + @Override + public Future> portMod(final PortModInput input) { + return sendToSwitchFuture(input, "port-mod-input sending failed"); + } + + @Override + public Future> roleRequest(final RoleRequestInput input) { + return sendToSwitchExpectRpcResultFuture(input, RoleRequestOutput.class, + "role-request-config-input sending failed"); + } + + @Override + public Future> setConfig(final SetConfigInput input) { + return sendToSwitchFuture(input, "set-config-input sending failed"); + } + + @Override + public Future> tableMod(final TableModInput input) { + return sendToSwitchFuture(input, "table-mod-input sending failed"); + } + + @Override + public Future> getAsync(final GetAsyncInput input) { + return sendToSwitchExpectRpcResultFuture(input, GetAsyncOutput.class, "get-async-input sending failed"); + } + + @Override + public Future> setAsync(final SetAsyncInput input) { + return sendToSwitchFuture(input, "set-async-input sending failed"); + } + + @Override + public boolean isAlive() { + return channel.isOpen(); + } + + @Override + public boolean isAutoRead() { + return channel.config().isAutoRead(); + } + + @Override + public void setAutoRead(final boolean autoRead) { + channel.config().setAutoRead(autoRead); + } + + @Override + public InetSocketAddress getRemoteAddress() { + return (InetSocketAddress) channel.remoteAddress(); + } + + /** + * Used only for testing purposes + * @param cache replacement + */ + @VisibleForTesting + void setResponseCache(final Cache> cache) { + this.responseCache = cache; + } + + /** + * Return cached RpcListener or {@code null} if not cached + * @return + */ + protected ResponseExpectedRpcListener findRpcResponse(final RpcResponseKey key) { + return responseCache.getIfPresent(key); + } + + /** + * sends given message to switch, sending result or switch response will be reported via return value + * + * @param input message to send + * @param responseClazz type of response + * @param failureInfo describes, what type of message caused failure by sending + * @return future object, + *
            + *
          • if send fails, {@link RpcResult} will contain errors and failed status
          • + *
          • else {@link RpcResult} will be stored in responseCache and wait for particular timeout ( + * {@link ConnectionAdapterImpl#RPC_RESPONSE_EXPIRATION}), + *
              + *
            • either switch will manage to answer and then corresponding response message will be set into returned + * future
            • + *
            • or response in cache will expire and returned future will be cancelled
            • + *
            + *
          • + *
          + */ + protected ListenableFuture> sendToSwitchExpectRpcResultFuture( + final IN input, final Class responseClazz, final String failureInfo) { + final RpcResponseKey key = new RpcResponseKey(input.getXid(), responseClazz.getName()); + final ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(input, failureInfo, + responseCache, key); + return enqueueMessage(listener); + } + + /** + * sends given message to switch, sending result will be reported via return value + * + * @param input message to send + * @param failureInfo describes, what type of message caused failure by sending + * @return future object, + *
            + *
          • if send successful, {@link RpcResult} without errors and successful status will be returned,
          • + *
          • else {@link RpcResult} will contain errors and failed status
          • + *
          + */ + protected ListenableFuture> sendToSwitchFuture(final DataObject input, final String failureInfo) { + return enqueueMessage(new SimpleRpcListener(input, failureInfo)); + } + + private ListenableFuture> enqueueMessage(final AbstractRpcListener promise) { + LOG.debug("Submitting promise {}", promise); + + if (!output.enqueue(promise)) { + LOG.debug("Message queue is full, rejecting execution"); + promise.failedRpc(QUEUE_FULL_EXCEPTION); + } else { + LOG.debug("Promise enqueued successfully"); + } + + return promise.getResult(); + } + + /** + * @param resultFuture + * @param failureInfo + * @param errorSeverity + * @param message + * @return + */ + private static SettableFuture handleTransportChannelFuture(final ChannelFuture resultFuture) { + + final SettableFuture transportResult = SettableFuture.create(); + + resultFuture.addListener(new GenericFutureListener>() { + + @Override + public void operationComplete(final io.netty.util.concurrent.Future future) throws Exception { + transportResult.set(future.isSuccess()); + if (!future.isSuccess()) { + transportResult.setException(future.cause()); + } + } + }); + return transportResult; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapterStatistics.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapterStatistics.java new file mode 100644 index 00000000..730403b6 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapterStatistics.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.util.concurrent.ListenableFuture; +import io.netty.channel.Channel; +import java.net.InetSocketAddress; +import java.util.concurrent.Future; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.Notification; +import org.opendaylight.yangtools.yang.common.RpcResult; + +/** + * Class is only wrapper for {@link AbstractConnectionAdapter} to provide statistics + * records for counting all needed RPC messages in Openflow Java. + */ +abstract class AbstractConnectionAdapterStatistics extends AbstractConnectionAdapter implements MessageConsumer { + + private final StatisticsCounters statisticsCounters; + + AbstractConnectionAdapterStatistics(final Channel channel, final InetSocketAddress address) { + super(channel, address); + statisticsCounters = StatisticsCounters.getInstance(); + } + + @Override + public Future> flowMod(final FlowModInput input) { + statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_ENTERED); + return super.flowMod(input); + } + + @Override + protected ListenableFuture> sendToSwitchExpectRpcResultFuture( + final IN input, final Class responseClazz, final String failureInfo) { + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); + return super.sendToSwitchExpectRpcResultFuture(input, responseClazz, failureInfo); + } + + @Override + protected ListenableFuture> sendToSwitchFuture(final DataObject input, final String failureInfo) { + statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); + return super.sendToSwitchFuture(input, failureInfo); + } + + @Override + public void consume(final DataObject message) { + if (Notification.class.isInstance(message)) { + if (!(DisconnectEvent.class.isInstance(message) || SwitchIdleEvent.class.isInstance(message))) { + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); + } + } else if (OfHeader.class.isInstance(message)) { + statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); + } + consumeDeviceMessage(message); + } + + /** + * Method is equivalent to {@link MessageConsumer#consume(DataObject)} to prevent missing method + * in every children of {@link AbstractConnectionAdapterStatistics} class, because we overriding + * original method for {@link StatisticsCounters} + * + * @param message from device to processing + */ + protected abstract void consumeDeviceMessage(DataObject message); +} + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 81a9aceb..d22f2f06 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -10,69 +10,28 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalCause; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.util.concurrent.GenericFutureListener; import java.net.InetSocketAddress; -import java.util.concurrent.Future; -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.TimeUnit; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector; import org.opendaylight.openflowjava.protocol.impl.core.PipelineHandlers; -import org.opendaylight.openflowjava.statistics.CounterEventTypes; -import org.opendaylight.openflowjava.statistics.StatisticsCounters; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,199 +40,49 @@ * @author mirehak * @author michal.polkorab */ -public class ConnectionAdapterImpl implements ConnectionFacade { - /** after this time, RPC future response objects will be thrown away (in minutes) */ - public static final int RPC_RESPONSE_EXPIRATION = 1; +public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics implements ConnectionFacade { - /** - * Default depth of write queue, e.g. we allow these many messages - * to be queued up before blocking producers. - */ - public static final int DEFAULT_QUEUE_DEPTH = 1024; - - private static final Logger LOG = LoggerFactory - .getLogger(ConnectionAdapterImpl.class); - private static final Exception QUEUE_FULL_EXCEPTION = - new RejectedExecutionException("Output queue is full"); - - private static final RemovalListener> REMOVAL_LISTENER = - new RemovalListener>() { - @Override - public void onRemoval( - final RemovalNotification> notification) { - if (! notification.getCause().equals(RemovalCause.EXPLICIT)) { - notification.getValue().discard(); - } - } - }; - - /** expiring cache for future rpcResponses */ - private Cache> responseCache; - - private final ChannelOutboundQueue output; - private final Channel channel; + private static final Logger LOG = LoggerFactory.getLogger(ConnectionAdapterImpl.class); private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; private SystemNotificationsListener systemListener; private OutboundQueueManager outputManager; - private boolean disconnectOccured = false; - private final StatisticsCounters statisticsCounters; private OFVersionDetector versionDetector; - private final InetSocketAddress address; private final boolean useBarrier; /** * default ctor + * * @param channel the channel to be set - used for communication * @param address client address (used only in case of UDP communication, - * as there is no need to store address over tcp (stable channel)) + * as there is no need to store address over tcp (stable channel)) + * @param useBarrier value is configurable by configSubsytem */ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address, final boolean useBarrier) { - this.channel = Preconditions.checkNotNull(channel); - this.output = new ChannelOutboundQueue(channel, DEFAULT_QUEUE_DEPTH, address); - this.address = address; - - responseCache = CacheBuilder.newBuilder() - .concurrencyLevel(1) - .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) - .removalListener(REMOVAL_LISTENER).build(); - + super(channel, address); this.useBarrier = useBarrier; - channel.pipeline().addLast(output); - statisticsCounters = StatisticsCounters.getInstance(); - LOG.debug("ConnectionAdapter created"); } @Override - public Future> barrier(final BarrierInput input) { - return sendToSwitchExpectRpcResultFuture( - input, BarrierOutput.class, "barrier-input sending failed"); - } - - @Override - public Future> echo(final EchoInput input) { - return sendToSwitchExpectRpcResultFuture( - input, EchoOutput.class, "echo-input sending failed"); - } - - @Override - public Future> echoReply(final EchoReplyInput input) { - return sendToSwitchFuture(input, "echo-reply sending failed"); - } - - @Override - public Future> experimenter(final ExperimenterInput input) { - return sendToSwitchFuture(input, "experimenter reply sending failed"); - } - - @Override - public Future> flowMod(final FlowModInput input) { - statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_ENTERED); - return sendToSwitchFuture(input, "flow-mod sending failed"); - } - - @Override - public Future> getConfig(final GetConfigInput input) { - return sendToSwitchExpectRpcResultFuture( - input, GetConfigOutput.class, "get-config-input sending failed"); - } - - @Override - public Future> getFeatures( - final GetFeaturesInput input) { - return sendToSwitchExpectRpcResultFuture( - input, GetFeaturesOutput.class, "get-features-input sending failed"); - } - - @Override - public Future> getQueueConfig( - final GetQueueConfigInput input) { - return sendToSwitchExpectRpcResultFuture( - input, GetQueueConfigOutput.class, "get-queue-config-input sending failed"); - } - - @Override - public Future> groupMod(final GroupModInput input) { - return sendToSwitchFuture(input, "group-mod-input sending failed"); - } - - @Override - public Future> hello(final HelloInput input) { - return sendToSwitchFuture(input, "hello-input sending failed"); - } - - @Override - public Future> meterMod(final MeterModInput input) { - return sendToSwitchFuture(input, "meter-mod-input sending failed"); - } - - @Override - public Future> packetOut(final PacketOutInput input) { - return sendToSwitchFuture(input, "packet-out-input sending failed"); - } - - @Override - public Future> multipartRequest(final MultipartRequestInput input) { - return sendToSwitchFuture(input, "multi-part-request sending failed"); - } - - @Override - public Future> portMod(final PortModInput input) { - return sendToSwitchFuture(input, "port-mod-input sending failed"); - } - - @Override - public Future> roleRequest( - final RoleRequestInput input) { - return sendToSwitchExpectRpcResultFuture( - input, RoleRequestOutput.class, "role-request-config-input sending failed"); - } - - @Override - public Future> setConfig(final SetConfigInput input) { - return sendToSwitchFuture(input, "set-config-input sending failed"); - } - - @Override - public Future> tableMod(final TableModInput input) { - return sendToSwitchFuture(input, "table-mod-input sending failed"); - } - - @Override - public Future> getAsync(final GetAsyncInput input) { - return sendToSwitchExpectRpcResultFuture( - input, GetAsyncOutput.class, "get-async-input sending failed"); - } - - @Override - public Future> setAsync(final SetAsyncInput input) { - return sendToSwitchFuture(input, "set-async-input sending failed"); - } - - @Override - public Future disconnect() { - final ChannelFuture disconnectResult = channel.disconnect(); - responseCache.invalidateAll(); - disconnectOccured = true; - - return handleTransportChannelFuture(disconnectResult); + public void setMessageListener(final OpenflowProtocolListener messageListener) { + this.messageListener = messageListener; } @Override - public boolean isAlive() { - return channel.isOpen(); + public void setConnectionReadyListener(final ConnectionReadyListener connectionReadyListener) { + this.connectionReadyListener = connectionReadyListener; } @Override - public void setMessageListener(final OpenflowProtocolListener messageListener) { - this.messageListener = messageListener; + public void setSystemListener(final SystemNotificationsListener systemListener) { + this.systemListener = systemListener; } @Override - public void consume(final DataObject message) { + public void consumeDeviceMessage(final DataObject message) { LOG.debug("ConsumeIntern msg on {}", channel); if (disconnectOccured ) { return; @@ -294,38 +103,30 @@ public void consume(final DataObject message) { } else { messageListener.onEchoRequestMessage((EchoRequestMessage) message); } - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ErrorMessage) { // Send only unmatched errors if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { messageListener.onErrorMessage((ErrorMessage) message); } - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof ExperimenterMessage) { if (outputManager != null) { outputManager.onMessage((OfHeader) message); } messageListener.onExperimenterMessage((ExperimenterMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof FlowRemovedMessage) { messageListener.onFlowRemovedMessage((FlowRemovedMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof HelloMessage) { LOG.info("Hello received / branch"); messageListener.onHelloMessage((HelloMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof MultipartReplyMessage) { if (outputManager != null) { outputManager.onMessage((OfHeader) message); } messageListener.onMultipartReplyMessage((MultipartReplyMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PacketInMessage) { messageListener.onPacketInMessage((PacketInMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else if (message instanceof PortStatusMessage) { messageListener.onPortStatusMessage((PortStatusMessage) message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); } else { LOG.warn("message listening not supported for type: {}", message.getClass()); } @@ -338,7 +139,6 @@ public void consume(final DataObject message) { if (listener != null) { LOG.debug("corresponding rpcFuture found"); listener.completed((OfHeader)message); - statisticsCounters.incrementCounter(CounterEventTypes.US_MESSAGE_PASS); LOG.debug("after setting rpcFuture"); responseCache.invalidate(key); } else { @@ -350,86 +150,6 @@ public void consume(final DataObject message) { } } - private ListenableFuture> enqueueMessage(final AbstractRpcListener promise) { - LOG.debug("Submitting promise {}", promise); - - if (!output.enqueue(promise)) { - LOG.debug("Message queue is full, rejecting execution"); - promise.failedRpc(QUEUE_FULL_EXCEPTION); - } else { - LOG.debug("Promise enqueued successfully"); - } - - return promise.getResult(); - } - - /** - * sends given message to switch, sending result will be reported via return value - * @param input message to send - * @param failureInfo describes, what type of message caused failure by sending - * @return future object,
            - *
          • if send successful, {@link RpcResult} without errors and successful - * status will be returned,
          • - *
          • else {@link RpcResult} will contain errors and failed status
          • - *
          - */ - private ListenableFuture> sendToSwitchFuture( - final DataObject input, final String failureInfo) { - statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); - return enqueueMessage(new SimpleRpcListener(input, failureInfo)); - } - - /** - * sends given message to switch, sending result or switch response will be reported via return value - * @param input message to send - * @param responseClazz type of response - * @param failureInfo describes, what type of message caused failure by sending - * @return future object,
            - *
          • if send fails, {@link RpcResult} will contain errors and failed status
          • - *
          • else {@link RpcResult} will be stored in responseCache and wait for particular timeout - * ({@link ConnectionAdapterImpl#RPC_RESPONSE_EXPIRATION}), - *
            • either switch will manage to answer - * and then corresponding response message will be set into returned future
            • - *
            • or response in cache will expire and returned future will be cancelled
            - *
          • - *
          - */ - private ListenableFuture> sendToSwitchExpectRpcResultFuture( - final IN input, final Class responseClazz, final String failureInfo) { - final RpcResponseKey key = new RpcResponseKey(input.getXid(), responseClazz.getName()); - final ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>(input, failureInfo, responseCache, key); - statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA); - return enqueueMessage(listener); - } - - /** - * @param resultFuture - * @param failureInfo - * @param errorSeverity - * @param message - * @return - */ - private static SettableFuture handleTransportChannelFuture( - final ChannelFuture resultFuture) { - - final SettableFuture transportResult = SettableFuture.create(); - - resultFuture.addListener(new GenericFutureListener>() { - - @Override - public void operationComplete( - final io.netty.util.concurrent.Future future) - throws Exception { - transportResult.set(future.isSuccess()); - if (!future.isSuccess()) { - transportResult.setException(future.cause()); - } - } - }); - return transportResult; - } - /** * @param message * @return @@ -438,18 +158,6 @@ private static RpcResponseKey createRpcResponseKey(final OfHeader message) { return new RpcResponseKey(message.getXid(), message.getImplementedInterface().getName()); } - /** - * @return - */ - private ResponseExpectedRpcListener findRpcResponse(final RpcResponseKey key) { - return responseCache.getIfPresent(key); - } - - @Override - public void setSystemListener(final SystemNotificationsListener systemListener) { - this.systemListener = systemListener; - } - @Override public void checkListeners() { final StringBuilder buffer = new StringBuilder(); @@ -479,35 +187,6 @@ public void run() { }).start(); } - @Override - public void setConnectionReadyListener( - final ConnectionReadyListener connectionReadyListener) { - this.connectionReadyListener = connectionReadyListener; - } - - @Override - public InetSocketAddress getRemoteAddress() { - return (InetSocketAddress) channel.remoteAddress(); - } - - /** - * Used only for testing purposes - * @param cache - */ - public void setResponseCache(final Cache> cache) { - this.responseCache = cache; - } - - @Override - public boolean isAutoRead() { - return channel.config().isAutoRead(); - } - - @Override - public void setAutoRead(final boolean autoRead) { - channel.config().setAutoRead(autoRead); - } - @Override public OutboundQueueHandlerRegistration registerOutboundQueueHandler( final T handler, final int maxQueueDepth, final long maxBarrierNanos) { @@ -519,6 +198,8 @@ public OutboundQueueHandlerRegistration regi final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); outputManager = ret; + /* we don't need it anymore */ + channel.pipeline().remove(output); channel.pipeline().addLast(outputManager); return new OutboundQueueHandlerRegistrationImpl(handler) { From 62620c14c4fde7e81605b07527f5b829393ef7f4 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Sat, 26 Sep 2015 23:27:24 +0200 Subject: [PATCH 210/285] Barrier turn on/off - Split OutboundQueueManager * Split OutboundQueueManger functionaly to Abstract parent for split barrier functionality and Channel management Change-Id: Iff85917145034689fa494a679bf6a65b969c775b Signed-off-by: Vaclav Demcak (cherry picked from commit deca37b27340c6e9b1576c281982d5d7f4ee1795) --- .../AbstractOutboundQueueManager.java | 353 ++++++++++++++++++ .../core/connection/OutboundQueueManager.java | 313 +--------------- .../core/connection/StackedOutboundQueue.java | 7 +- 3 files changed, 361 insertions(+), 312 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java new file mode 100644 index 00000000..49c6ddfa --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import javax.annotation.Nonnull; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class capsulate basic processing for stacking requests for netty channel + * and provide functionality for pairing request/response device message communication. + */ +abstract class AbstractOutboundQueueManager extends ChannelInboundHandlerAdapter + implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractOutboundQueueManager.class); + + private static enum PipelineState { + /** + * Netty thread is potentially idle, no assumptions + * can be made about its state. + */ + IDLE, + /** + * Netty thread is currently reading, once the read completes, + * if will flush the queue in the {@link #WRITING} state. + */ + READING, + /** + * Netty thread is currently performing a flush on the queue. + * It will then transition to {@link #IDLE} state. + */ + WRITING, + } + + /** + * Default low write watermark. Channel will become writable when number of outstanding + * bytes dips below this value. + */ + private static final int DEFAULT_LOW_WATERMARK = 128 * 1024; + + /** + * Default write high watermark. Channel will become un-writable when number of + * outstanding bytes hits this value. + */ + private static final int DEFAULT_HIGH_WATERMARK = DEFAULT_LOW_WATERMARK * 2; + + private final AtomicBoolean flushScheduled = new AtomicBoolean(); + protected final ConnectionAdapterImpl parent; + protected final InetSocketAddress address; + protected final StackedOutboundQueue currentQueue; + private final T handler; + + // Accessed concurrently + private volatile PipelineState state = PipelineState.IDLE; + + // Updated from netty only + private boolean alreadyReading; + protected boolean shuttingDown; + + // Passed to executor to request triggering of flush + protected final Runnable flushRunnable = new Runnable() { + @Override + public void run() { + flush(); + } + }; + + AbstractOutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler) { + this.parent = Preconditions.checkNotNull(parent); + this.handler = Preconditions.checkNotNull(handler); + this.address = address; + currentQueue = new StackedOutboundQueue(this); + LOG.debug("Queue manager instantiated with queue {}", currentQueue); + + handler.onConnectionQueueChanged(currentQueue); + } + + @Override + public void close() { + handler.onConnectionQueueChanged(null); + } + + @Override + public String toString() { + return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get()); + } + + @Override + public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { + /* + * Tune channel write buffering. We increase the writability window + * to ensure we can flush an entire queue segment in one go. We definitely + * want to keep the difference above 64k, as that will ensure we use jam-packed + * TCP packets. UDP will fragment as appropriate. + */ + ctx.channel().config().setWriteBufferHighWaterMark(DEFAULT_HIGH_WATERMARK); + ctx.channel().config().setWriteBufferLowWaterMark(DEFAULT_LOW_WATERMARK); + + super.handlerAdded(ctx); + } + + @Override + public void channelActive(final ChannelHandlerContext ctx) throws Exception { + super.channelActive(ctx); + conditionalFlush(); + } + + @Override + public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception { + super.channelReadComplete(ctx); + + // Run flush regardless of writability. This is not strictly required, as + // there may be a scheduled flush. Instead of canceling it, which is expensive, + // we'll steal its work. Note that more work may accumulate in the time window + // between now and when the task will run, so it may not be a no-op after all. + // + // The reason for this is to will the output buffer before we go into selection + // phase. This will make sure the pipe is full (in which case our next wake up + // will be the queue becoming writable). + writeAndFlush(); + } + + @Override + public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { + super.channelWritabilityChanged(ctx); + + // The channel is writable again. There may be a flush task on the way, but let's + // steal its work, potentially decreasing latency. Since there is a window between + // now and when it will run, it may still pick up some more work to do. + LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); + writeAndFlush(); + } + + @Override + public void channelInactive(final ChannelHandlerContext ctx) throws Exception { + super.channelInactive(ctx); + + LOG.debug("Channel {} initiating shutdown...", ctx.channel()); + + shuttingDown = true; + final long entries = currentQueue.startShutdown(ctx.channel()); + LOG.debug("Cleared {} queue entries from channel {}", entries, ctx.channel()); + + scheduleFlush(); + } + + @Override + public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { + // Netty does not provide a 'start reading' callback, so this is our first + // (and repeated) chance to detect reading. Since this callback can be invoked + // multiple times, we keep a boolean we check. That prevents a volatile write + // on repeated invocations. It will be cleared in channelReadComplete(). + if (!alreadyReading) { + alreadyReading = true; + state = PipelineState.READING; + } + super.channelRead(ctx, msg); + } + + /** + * Invoked whenever a message comes in from the switch. Runs matching + * on all active queues in an attempt to complete a previous request. + * + * @param message Potential response message + * @return True if the message matched a previous request, false otherwise. + */ + boolean onMessage(final OfHeader message) { + LOG.trace("Attempting to pair message {} to a request", message); + + return currentQueue.pairRequest(message); + } + + T getHandler() { + return handler; + } + + void ensureFlushing() { + // If the channel is not writable, there's no point in waking up, + // once we become writable, we will run a full flush + if (!parent.getChannel().isWritable()) { + return; + } + + // We are currently reading something, just a quick sync to ensure we will in fact + // flush state. + final PipelineState localState = state; + LOG.debug("Synchronize on pipeline state {}", localState); + switch (localState) { + case READING: + // Netty thread is currently reading, it will flush the pipeline once it + // finishes reading. This is a no-op situation. + break; + case WRITING: + case IDLE: + default: + // We cannot rely on the change being flushed, schedule a request + scheduleFlush(); + } + } + + /** + * Method immediately response on Echo message. + * + * @param message incoming Echo message from device + */ + void onEchoRequest(final EchoRequestMessage message) { + final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()) + .setVersion(message.getVersion()).setXid(message.getXid()).build(); + parent.getChannel().writeAndFlush(makeMessageListenerWrapper(reply)); + } + + /** + * Wraps outgoing message and includes listener attached to this message + * which is send to OFEncoder for serialization. Correct wrapper is + * selected by communication pipeline. + * + * @param message + * @param now + */ + void writeMessage(final OfHeader message, final long now) { + final Object wrapper = makeMessageListenerWrapper(message); + parent.getChannel().write(wrapper); + } + + /** + * Wraps outgoing message and includes listener attached to this message + * which is send to OFEncoder for serialization. Correct wrapper is + * selected by communication pipeline. + * + * @return + */ + private Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { + Preconditions.checkArgument(msg != null); + + if (address == null) { + return new MessageListenerWrapper(msg, LOG_ENCODER_LISTENER); + } + return new UdpMessageListenerWrapper(msg, LOG_ENCODER_LISTENER, address); + } + + /* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */ + private static final GenericFutureListener> LOG_ENCODER_LISTENER = new GenericFutureListener>() { + + private final Logger LOGGER = LoggerFactory.getLogger("LogEncoderListener"); + + @Override + public void operationComplete(final Future future) throws Exception { + if (future.cause() != null) { + LOGGER.warn("Message encoding fail !", future.cause()); + } + } + }; + + /** + * Perform a single flush operation. We keep it here so we do not generate + * syntetic accessors for private fields. Otherwise it could be moved into {@link #flushRunnable}. + */ + protected void flush() { + // If the channel is gone, just flush whatever is not completed + if (!shuttingDown) { + LOG.trace("Dequeuing messages to channel {}", parent.getChannel()); + writeAndFlush(); + rescheduleFlush(); + } else if (currentQueue.finishShutdown()) { + close(); + LOG.debug("Channel {} shutdown complete", parent.getChannel()); + } else { + LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); + rescheduleFlush(); + } + } + + private void scheduleFlush() { + if (flushScheduled.compareAndSet(false, true)) { + LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); + parent.getChannel().eventLoop().execute(flushRunnable); + } else { + LOG.trace("Flush task is already present on channel {}", parent.getChannel()); + } + } + + private void writeAndFlush() { + state = PipelineState.WRITING; + + final long start = System.nanoTime(); + + final int entries = currentQueue.writeEntries(parent.getChannel(), start); + if (entries > 0) { + LOG.trace("Flushing channel {}", parent.getChannel()); + parent.getChannel().flush(); + } + + if (LOG.isDebugEnabled()) { + final long stop = System.nanoTime(); + LOG.debug("Flushed {} messages to channel {} in {}us", entries, parent.getChannel(), + TimeUnit.NANOSECONDS.toMicros(stop - start)); + } + + state = PipelineState.IDLE; + } + + private void rescheduleFlush() { + /* + * We are almost ready to terminate. This is a bit tricky, because + * we do not want to have a race window where a message would be + * stuck on the queue without a flush being scheduled. + * So we mark ourselves as not running and then re-check if a + * flush out is needed. That will re-synchronized with other threads + * such that only one flush is scheduled at any given time. + */ + if (!flushScheduled.compareAndSet(true, false)) { + LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); + } + + conditionalFlush(); + } + + /** + * Schedule a queue flush if it is not empty and the channel is found + * to be writable. May only be called from Netty context. + */ + private void conditionalFlush() { + if (currentQueue.needsFlush()) { + if (shuttingDown || parent.getChannel().isWritable()) { + scheduleFlush(); + } else { + LOG.debug("Channel {} is not I/O ready, not scheduling a flush", parent.getChannel()); + } + } else { + LOG.trace("Queue is empty, no flush needed"); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index ebf956f9..6b90daae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -8,81 +8,24 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import java.net.InetSocketAddress; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.Nonnull; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -final class OutboundQueueManager extends ChannelInboundHandlerAdapter implements AutoCloseable { - private static enum PipelineState { - /** - * Netty thread is potentially idle, no assumptions - * can be made about its state. - */ - IDLE, - /** - * Netty thread is currently reading, once the read completes, - * if will flush the queue in the {@link #FLUSHING} state. - */ - READING, - /** - * Netty thread is currently performing a flush on the queue. - * It will then transition to {@link #IDLE} state. - */ - WRITING, - } - +final class OutboundQueueManager extends AbstractOutboundQueueManager { private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueManager.class); - /** - * Default low write watermark. Channel will become writable when number of outstanding - * bytes dips below this value. - */ - private static final int DEFAULT_LOW_WATERMARK = 128 * 1024; - - /** - * Default write high watermark. Channel will become un-writable when number of - * outstanding bytes hits this value. - */ - private static final int DEFAULT_HIGH_WATERMARK = DEFAULT_LOW_WATERMARK * 2; - - private final AtomicBoolean flushScheduled = new AtomicBoolean(); - private final StackedOutboundQueue currentQueue; - private final ConnectionAdapterImpl parent; - private final InetSocketAddress address; private final int maxNonBarrierMessages; private final long maxBarrierNanos; - private final T handler; - - // Accessed concurrently - private volatile PipelineState state = PipelineState.IDLE; // Updated from netty only - private boolean alreadyReading; private boolean barrierTimerEnabled; private long lastBarrierNanos = System.nanoTime(); private int nonBarrierMessages; - private boolean shuttingDown; - - // Passed to executor to request triggering of flush - private final Runnable flushRunnable = new Runnable() { - @Override - public void run() { - flush(); - } - }; // Passed to executor to request a periodic barrier check private final Runnable barrierRunnable = new Runnable() { @@ -94,27 +37,13 @@ public void run() { OutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler, final int maxNonBarrierMessages, final long maxBarrierNanos) { - this.parent = Preconditions.checkNotNull(parent); - this.handler = Preconditions.checkNotNull(handler); + super(parent, address, handler); Preconditions.checkArgument(maxNonBarrierMessages > 0); this.maxNonBarrierMessages = maxNonBarrierMessages; Preconditions.checkArgument(maxBarrierNanos > 0); this.maxBarrierNanos = maxBarrierNanos; - this.address = address; - - currentQueue = new StackedOutboundQueue(this); - LOG.debug("Queue manager instantiated with queue {}", currentQueue); - handler.onConnectionQueueChanged(currentQueue); } - T getHandler() { - return handler; - } - - @Override - public void close() { - handler.onConnectionQueueChanged(null); - } private void scheduleBarrierTimer(final long now) { long next = lastBarrierNanos + maxBarrierNanos; @@ -136,33 +65,11 @@ private void scheduleBarrierMessage() { return; } - currentQueue.commitEntry(xid, handler.createBarrierRequest(xid), null); + currentQueue.commitEntry(xid, getHandler().createBarrierRequest(xid), null); LOG.trace("Barrier XID {} scheduled", xid); } - /** - * Invoked whenever a message comes in from the switch. Runs matching - * on all active queues in an attempt to complete a previous request. - * - * @param message Potential response message - * @return True if the message matched a previous request, false otherwise. - */ - boolean onMessage(final OfHeader message) { - LOG.trace("Attempting to pair message {} to a request", message); - - return currentQueue.pairRequest(message); - } - - private void scheduleFlush() { - if (flushScheduled.compareAndSet(false, true)) { - LOG.trace("Scheduling flush task on channel {}", parent.getChannel()); - parent.getChannel().eventLoop().execute(flushRunnable); - } else { - LOG.trace("Flush task is already present on channel {}", parent.getChannel()); - } - } - /** * Periodic barrier check. */ @@ -187,186 +94,6 @@ protected void barrier() { } } - private void rescheduleFlush() { - /* - * We are almost ready to terminate. This is a bit tricky, because - * we do not want to have a race window where a message would be - * stuck on the queue without a flush being scheduled. - * - * So we mark ourselves as not running and then re-check if a - * flush out is needed. That will re-synchronized with other threads - * such that only one flush is scheduled at any given time. - */ - if (!flushScheduled.compareAndSet(true, false)) { - LOG.warn("Channel {} queue {} flusher found unscheduled", parent.getChannel(), this); - } - - conditionalFlush(); - } - - private void writeAndFlush() { - state = PipelineState.WRITING; - - final long start = System.nanoTime(); - - final int entries = currentQueue.writeEntries(parent.getChannel(), start); - if (entries > 0) { - LOG.trace("Flushing channel {}", parent.getChannel()); - parent.getChannel().flush(); - } - - if (LOG.isDebugEnabled()) { - final long stop = System.nanoTime(); - LOG.debug("Flushed {} messages to channel {} in {}us", entries, - parent.getChannel(), TimeUnit.NANOSECONDS.toMicros(stop - start)); - } - - state = PipelineState.IDLE; - } - - /** - * Perform a single flush operation. We keep it here so we do not generate - * syntetic accessors for private fields. Otherwise it could be moved into - * {@link #flushRunnable}. - */ - protected void flush() { - // If the channel is gone, just flush whatever is not completed - if (!shuttingDown) { - LOG.trace("Dequeuing messages to channel {}", parent.getChannel()); - writeAndFlush(); - rescheduleFlush(); - } else if (currentQueue.finishShutdown()) { - handler.onConnectionQueueChanged(null); - LOG.debug("Channel {} shutdown complete", parent.getChannel()); - } else { - LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); - rescheduleFlush(); - } - } - - /** - * Schedule a queue flush if it is not empty and the channel is found - * to be writable. May only be called from Netty context. - */ - private void conditionalFlush() { - if (currentQueue.needsFlush()) { - if (shuttingDown || parent.getChannel().isWritable()) { - scheduleFlush(); - } else { - LOG.debug("Channel {} is not I/O ready, not scheduling a flush", parent.getChannel()); - } - } else { - LOG.trace("Queue is empty, no flush needed"); - } - } - - @Override - public void channelActive(final ChannelHandlerContext ctx) throws Exception { - super.channelActive(ctx); - conditionalFlush(); - } - - @Override - public void handlerAdded(final ChannelHandlerContext ctx) throws Exception { - /* - * Tune channel write buffering. We increase the writability window - * to ensure we can flush an entire queue segment in one go. We definitely - * want to keep the difference above 64k, as that will ensure we use jam-packed - * TCP packets. UDP will fragment as appropriate. - */ - ctx.channel().config().setWriteBufferHighWaterMark(DEFAULT_HIGH_WATERMARK); - ctx.channel().config().setWriteBufferLowWaterMark(DEFAULT_LOW_WATERMARK); - - super.handlerAdded(ctx); - } - - @Override - public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Exception { - super.channelWritabilityChanged(ctx); - - // The channel is writable again. There may be a flush task on the way, but let's - // steal its work, potentially decreasing latency. Since there is a window between - // now and when it will run, it may still pick up some more work to do. - LOG.debug("Channel {} writability changed, invoking flush", parent.getChannel()); - writeAndFlush(); - } - - @Override - public void channelInactive(final ChannelHandlerContext ctx) throws Exception { - super.channelInactive(ctx); - - LOG.debug("Channel {} initiating shutdown...", ctx.channel()); - - shuttingDown = true; - final long entries = currentQueue.startShutdown(ctx.channel()); - LOG.debug("Cleared {} queue entries from channel {}", entries, ctx.channel()); - - scheduleFlush(); - } - - @Override - public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { - // Netty does not provide a 'start reading' callback, so this is our first - // (and repeated) chance to detect reading. Since this callback can be invoked - // multiple times, we keep a boolean we check. That prevents a volatile write - // on repeated invocations. It will be cleared in channelReadComplete(). - if (!alreadyReading) { - alreadyReading = true; - state = PipelineState.READING; - } - super.channelRead(ctx, msg); - } - - @Override - public void channelReadComplete(final ChannelHandlerContext ctx) throws Exception { - super.channelReadComplete(ctx); - - // Run flush regardless of writability. This is not strictly required, as - // there may be a scheduled flush. Instead of canceling it, which is expensive, - // we'll steal its work. Note that more work may accumulate in the time window - // between now and when the task will run, so it may not be a no-op after all. - // - // The reason for this is to will the output buffer before we go into selection - // phase. This will make sure the pipe is full (in which case our next wake up - // will be the queue becoming writable). - writeAndFlush(); - } - - @Override - public String toString() { - return String.format("Channel %s queue [flushing=%s]", parent.getChannel(), flushScheduled.get()); - } - - void ensureFlushing() { - // If the channel is not writable, there's no point in waking up, - // once we become writable, we will run a full flush - if (!parent.getChannel().isWritable()) { - return; - } - - // We are currently reading something, just a quick sync to ensure we will in fact - // flush state. - final PipelineState localState = state; - LOG.debug("Synchronize on pipeline state {}", localState); - switch (localState) { - case READING: - // Netty thread is currently reading, it will flush the pipeline once it - // finishes reading. This is a no-op situation. - break; - case WRITING: - case IDLE: - default: - // We cannot rely on the change being flushed, schedule a request - scheduleFlush(); - } - } - - void onEchoRequest(final EchoRequestMessage message) { - final EchoReplyInput reply = new EchoReplyInputBuilder().setData(message.getData()) - .setVersion(message.getVersion()).setXid(message.getXid()).build(); - parent.getChannel().writeAndFlush(makeMessageListenerWrapper(reply)); - } - /** * Write a message into the underlying channel. * @@ -377,10 +104,9 @@ void onEchoRequest(final EchoRequestMessage message) { * measure System.nanoTime() for each barrier -- needlessly * adding overhead. */ + @Override void writeMessage(final OfHeader message, final long now) { - final Object wrapper = makeMessageListenerWrapper(message); - parent.getChannel().write(wrapper); - + super.writeMessage(message, now); if (message instanceof BarrierInput) { LOG.trace("Barrier message seen, resetting counters"); nonBarrierMessages = 0; @@ -395,33 +121,4 @@ void writeMessage(final OfHeader message, final long now) { } } } - - /** - * Wraps outgoing message and includes listener attached to this message - * which is send to OFEncoder for serialization. Correct wrapper is - * selected by communication pipeline. - * - * @return - */ - private Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { - Preconditions.checkArgument(msg != null); - - if (address == null) { - return new MessageListenerWrapper(msg, LOG_ENCODER_LISTENER); - } - return new UdpMessageListenerWrapper(msg, LOG_ENCODER_LISTENER, address); - } - - /* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */ - private static final GenericFutureListener> LOG_ENCODER_LISTENER = new GenericFutureListener>() { - - private final Logger LOGGER = LoggerFactory.getLogger("LogEncoderListener"); - - @Override - public void operationComplete(final Future future) throws Exception { - if (future.cause() != null) { - LOGGER.warn("Message encoding fail !", future.cause()); - } - } - }; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index efe71aa7..1da6dd3d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -34,7 +34,7 @@ final class StackedOutboundQueue implements OutboundQueue { private final List unflushedSegments = new ArrayList<>(2); @GuardedBy("unflushedSegments") private final List uncompletedSegments = new ArrayList<>(2); - private final OutboundQueueManager manager; + private final AbstractOutboundQueueManager manager; private volatile long allocatedXid = -1; private volatile long barrierXid = -1; @@ -46,7 +46,7 @@ final class StackedOutboundQueue implements OutboundQueue { // Accessed from Netty only private int flushOffset; - StackedOutboundQueue(final OutboundQueueManager manager) { + StackedOutboundQueue(final AbstractOutboundQueueManager manager) { this.manager = Preconditions.checkNotNull(manager); firstSegment = StackedSegment.create(0L); uncompletedSegments.add(firstSegment); @@ -243,9 +243,8 @@ Long reserveBarrierIfNeeded() { if (bXid >= fXid) { LOG.debug("Barrier found at XID {} (currently at {})", bXid, fXid); return null; - } else { - return reserveEntry(); } + return reserveEntry(); } boolean pairRequest(final OfHeader message) { From 0be233687a9253f8ffc6c3054a2e10b25063f095 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Sun, 27 Sep 2015 01:55:53 +0200 Subject: [PATCH 211/285] Barrier turn on/off - StackedOutboundQueue definition * add abstract definition for StackedOutboundQueue to allow mor variability for possible child implementation Change-Id: I04d8658e0ede049fb0b9265b57a5f7f528998442 Signed-off-by: Vaclav Demcak (cherry picked from commit 3545506a79947dec9b4ded9afe51388dadb16e27) --- .../AbstractOutboundQueueManager.java | 15 +- .../AbstractStackedOutboundQueue.java | 128 ++++++++++++++++++ .../core/connection/OutboundQueueManager.java | 7 +- .../core/connection/StackedOutboundQueue.java | 101 +------------- 4 files changed, 151 insertions(+), 100 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 49c6ddfa..99bec867 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -29,7 +29,8 @@ * Class capsulate basic processing for stacking requests for netty channel * and provide functionality for pairing request/response device message communication. */ -abstract class AbstractOutboundQueueManager extends ChannelInboundHandlerAdapter +abstract class AbstractOutboundQueueManager + extends ChannelInboundHandlerAdapter implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(AbstractOutboundQueueManager.class); @@ -67,7 +68,7 @@ private static enum PipelineState { private final AtomicBoolean flushScheduled = new AtomicBoolean(); protected final ConnectionAdapterImpl parent; protected final InetSocketAddress address; - protected final StackedOutboundQueue currentQueue; + protected final O currentQueue; private final T handler; // Accessed concurrently @@ -89,12 +90,20 @@ public void run() { this.parent = Preconditions.checkNotNull(parent); this.handler = Preconditions.checkNotNull(handler); this.address = address; - currentQueue = new StackedOutboundQueue(this); + /* Note: don't wish to use reflection here */ + currentQueue = initializeStackedOutboudnqueue(); LOG.debug("Queue manager instantiated with queue {}", currentQueue); handler.onConnectionQueueChanged(currentQueue); } + /** + * Method has to initialize some child of {@link AbstractStackedOutboundQueue} + * + * @return correct implementation of StacketOutboundqueue + */ + protected abstract O initializeStackedOutboudnqueue(); + @Override public void close() { handler.onConnectionQueueChanged(null); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java new file mode 100644 index 00000000..332f318d --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.base.Preconditions; +import io.netty.channel.Channel; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import javax.annotation.Nonnull; +import javax.annotation.concurrent.GuardedBy; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +abstract class AbstractStackedOutboundQueue implements OutboundQueue { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractStackedOutboundQueue.class); + + protected static final AtomicLongFieldUpdater LAST_XID_UPDATER = AtomicLongFieldUpdater + .newUpdater(AbstractStackedOutboundQueue.class, "lastXid"); + + @GuardedBy("unflushedSegments") + protected volatile StackedSegment firstSegment; + @GuardedBy("unflushedSegments") + protected final List unflushedSegments = new ArrayList<>(2); + @GuardedBy("unflushedSegments") + protected final List uncompletedSegments = new ArrayList<>(2); + + private volatile long lastXid = -1; + + @GuardedBy("unflushedSegments") + protected Integer shutdownOffset; + + // Accessed from Netty only + protected int flushOffset; + + protected final AbstractOutboundQueueManager manager; + + AbstractStackedOutboundQueue(final AbstractOutboundQueueManager manager) { + this.manager = Preconditions.checkNotNull(manager); + firstSegment = StackedSegment.create(0L); + uncompletedSegments.add(firstSegment); + unflushedSegments.add(firstSegment); + } + + /** + * Write some entries from the queue to the channel. Guaranteed to run + * in the corresponding EventLoop. + * + * @param channel Channel onto which we are writing + * @param now + * @return Number of entries written out + */ + abstract int writeEntries(@Nonnull final Channel channel, final long now); + + abstract boolean pairRequest(final OfHeader message); + + boolean needsFlush() { + // flushOffset always points to the first entry, which can be changed only + // from Netty, so we are fine here. + if (firstSegment.getBaseXid() + flushOffset > lastXid) { + return false; + } + + if (shutdownOffset != null && flushOffset >= shutdownOffset) { + return false; + } + + return firstSegment.getEntry(flushOffset).isCommitted(); + } + + long startShutdown(final Channel channel) { + /* + * We are dealing with a multi-threaded shutdown, as the user may still + * be reserving entries in the queue. We are executing in a netty thread, + * so neither flush nor barrier can be running, which is good news. + * We will eat up all the slots in the queue here and mark the offset first + * reserved offset and free up all the cached queues. We then schedule + * the flush task, which will deal with the rest of the shutdown process. + */ + synchronized (unflushedSegments) { + // Increment the offset by the segment size, preventing fast path allocations, + // since we are holding the slow path lock, any reservations will see the queue + // in shutdown and fail accordingly. + final long xid = LAST_XID_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); + shutdownOffset = (int) (xid - firstSegment.getBaseXid() - StackedSegment.SEGMENT_SIZE); + + return lockedShutdownFlush(); + } + } + + boolean finishShutdown() { + synchronized (unflushedSegments) { + lockedShutdownFlush(); + } + + return !needsFlush(); + } + + @GuardedBy("unflushedSegments") + private long lockedShutdownFlush() { + long entries = 0; + + // Fail all queues + final Iterator it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment segment = it.next(); + + entries += segment.failAll(OutboundQueueException.DEVICE_DISCONNECTED); + if (segment.isComplete()) { + LOG.trace("Cleared segment {}", segment); + it.remove(); + } + } + + return entries; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 6b90daae..90db23da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -16,7 +16,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -final class OutboundQueueManager extends AbstractOutboundQueueManager { +final class OutboundQueueManager extends + AbstractOutboundQueueManager { private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueManager.class); private final int maxNonBarrierMessages; @@ -44,6 +45,10 @@ public void run() { this.maxBarrierNanos = maxBarrierNanos; } + @Override + protected StackedOutboundQueue initializeStackedOutboudnqueue() { + return new StackedOutboundQueue(this); + } private void scheduleBarrierTimer(final long now) { long next = lastBarrierNanos + maxBarrierNanos; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index 1da6dd3d..46039904 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -11,46 +11,23 @@ import com.google.common.base.Verify; import com.google.common.util.concurrent.FutureCallback; import io.netty.channel.Channel; -import java.util.ArrayList; import java.util.Iterator; -import java.util.List; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; -import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -final class StackedOutboundQueue implements OutboundQueue { +final class StackedOutboundQueue extends AbstractStackedOutboundQueue { private static final Logger LOG = LoggerFactory.getLogger(StackedOutboundQueue.class); private static final AtomicLongFieldUpdater BARRIER_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "barrierXid"); - private static final AtomicLongFieldUpdater LAST_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "lastXid"); - - @GuardedBy("unflushedSegments") - private volatile StackedSegment firstSegment; - @GuardedBy("unflushedSegments") - private final List unflushedSegments = new ArrayList<>(2); - @GuardedBy("unflushedSegments") - private final List uncompletedSegments = new ArrayList<>(2); - private final AbstractOutboundQueueManager manager; private volatile long allocatedXid = -1; private volatile long barrierXid = -1; - private volatile long lastXid = -1; - @GuardedBy("unflushedSegments") - private Integer shutdownOffset; - - // Accessed from Netty only - private int flushOffset; - - StackedOutboundQueue(final AbstractOutboundQueueManager manager) { - this.manager = Preconditions.checkNotNull(manager); - firstSegment = StackedSegment.create(0L); - uncompletedSegments.add(firstSegment); - unflushedSegments.add(firstSegment); + StackedOutboundQueue(final AbstractOutboundQueueManager manager) { + super(manager); } @GuardedBy("unflushedSegments") @@ -163,14 +140,7 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall manager.ensureFlushing(); } - /** - * Write some entries from the queue to the channel. Guaranteed to run - * in the corresponding EventLoop. - * - * @param channel Channel onto which we are writing - * @param now - * @return Number of entries written out - */ + @Override int writeEntries(@Nonnull final Channel channel, final long now) { // Local cache StackedSegment segment = firstSegment; @@ -247,6 +217,7 @@ Long reserveBarrierIfNeeded() { return reserveEntry(); } + @Override boolean pairRequest(final OfHeader message) { Iterator it = uncompletedSegments.iterator(); while (it.hasNext()) { @@ -292,66 +263,4 @@ boolean pairRequest(final OfHeader message) { LOG.debug("Failed to find completion for message {}", message); return false; } - - long startShutdown(final Channel channel) { - /* - * We are dealing with a multi-threaded shutdown, as the user may still - * be reserving entries in the queue. We are executing in a netty thread, - * so neither flush nor barrier can be running, which is good news. - * - * We will eat up all the slots in the queue here and mark the offset first - * reserved offset and free up all the cached queues. We then schedule - * the flush task, which will deal with the rest of the shutdown process. - */ - synchronized (unflushedSegments) { - // Increment the offset by the segment size, preventing fast path allocations, - // since we are holding the slow path lock, any reservations will see the queue - // in shutdown and fail accordingly. - final long xid = LAST_XID_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); - shutdownOffset = (int) (xid - firstSegment.getBaseXid() - StackedSegment.SEGMENT_SIZE); - - return lockedShutdownFlush(); - } - } - - @GuardedBy("unflushedSegments") - private long lockedShutdownFlush() { - long entries = 0; - - // Fail all queues - final Iterator it = uncompletedSegments.iterator(); - while (it.hasNext()) { - final StackedSegment segment = it.next(); - - entries += segment.failAll(OutboundQueueException.DEVICE_DISCONNECTED); - if (segment.isComplete()) { - LOG.trace("Cleared segment {}", segment); - it.remove(); - } - } - - return entries; - } - - boolean finishShutdown() { - synchronized (unflushedSegments) { - lockedShutdownFlush(); - } - - return !needsFlush(); - } - - boolean needsFlush() { - // flushOffset always points to the first entry, which can be changed only - // from Netty, so we are fine here. - if (firstSegment.getBaseXid() + flushOffset > lastXid) { - return false; - } - - if (shutdownOffset != null && flushOffset >= shutdownOffset) { - return false; - } - - return firstSegment.getEntry(flushOffset).isCommitted(); - } } From d75d0db7b88b7d0a506286ee125883042f49455a Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Wed, 7 Oct 2015 17:43:58 +0200 Subject: [PATCH 212/285] Barrier turn on/off - move more functionality from StackedOutboundQueue * move more functionality for reusing to AbstractStackedOutboundQueue * add general methods for Channel msg wrapper * fix NPE from OFEncoder Change-Id: I351300c4af40693ba444d3c10a1121e76d004d1b Signed-off-by: Vaclav Demcak (cherry picked from commit 05ab0ada9e8c590102caf34b462c8d989f09d72f) --- .../AbstractStackedOutboundQueue.java | 127 +++++++++++++++++- .../core/connection/StackedOutboundQueue.java | 126 ----------------- 2 files changed, 124 insertions(+), 129 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index 332f318d..77cb688d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.base.Preconditions; +import com.google.common.base.Verify; import io.netty.channel.Channel; import java.util.ArrayList; import java.util.Iterator; @@ -26,7 +27,7 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue { private static final Logger LOG = LoggerFactory.getLogger(AbstractStackedOutboundQueue.class); - protected static final AtomicLongFieldUpdater LAST_XID_UPDATER = AtomicLongFieldUpdater + protected static final AtomicLongFieldUpdater LAST_XID_OFFSET_UPDATER = AtomicLongFieldUpdater .newUpdater(AbstractStackedOutboundQueue.class, "lastXid"); @GuardedBy("unflushedSegments") @@ -37,6 +38,7 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue { protected final List uncompletedSegments = new ArrayList<>(2); private volatile long lastXid = -1; + private volatile long allocatedXid = -1; @GuardedBy("unflushedSegments") protected Integer shutdownOffset; @@ -53,6 +55,61 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue { unflushedSegments.add(firstSegment); } + @GuardedBy("unflushedSegments") + protected void ensureSegment(final StackedSegment first, final int offset) { + final int segmentOffset = offset / StackedSegment.SEGMENT_SIZE; + LOG.debug("Queue {} slow offset {} maps to {} segments {}", this, offset, segmentOffset, unflushedSegments.size()); + + for (int i = unflushedSegments.size(); i <= segmentOffset; ++i) { + final StackedSegment newSegment = StackedSegment.create(first.getBaseXid() + (StackedSegment.SEGMENT_SIZE * i)); + LOG.debug("Adding segment {}", newSegment); + unflushedSegments.add(newSegment); + } + + allocatedXid = uncompletedSegments.get(uncompletedSegments.size() - 1).getEndXid(); + } + + /* + * This method is expected to be called from multiple threads concurrently. + */ + @Override + public Long reserveEntry() { + final long xid = LAST_XID_OFFSET_UPDATER.incrementAndGet(this); + final StackedSegment fastSegment = firstSegment; + + if (xid >= fastSegment.getBaseXid() + StackedSegment.SEGMENT_SIZE) { + if (xid >= allocatedXid) { + // Multiple segments, this a slow path + LOG.debug("Queue {} falling back to slow reservation for XID {}", this, xid); + + synchronized (unflushedSegments) { + LOG.debug("Queue {} executing slow reservation for XID {}", this, xid); + + // Shutdown was scheduled, need to fail the reservation + if (shutdownOffset != null) { + LOG.debug("Queue {} is being shutdown, failing reservation", this); + return null; + } + + // Ensure we have the appropriate segment for the specified XID + final StackedSegment slowSegment = firstSegment; + final int slowOffset = (int) (xid - slowSegment.getBaseXid()); + Verify.verify(slowOffset >= 0); + + // Now, we let's see if we need to allocate a new segment + ensureSegment(slowSegment, slowOffset); + + LOG.debug("Queue {} slow reservation finished", this); + } + } else { + LOG.debug("Queue {} XID {} is already backed", this, xid); + } + } + + LOG.trace("Queue {} allocated XID {}", this, xid); + return xid; + } + /** * Write some entries from the queue to the channel. Guaranteed to run * in the corresponding EventLoop. @@ -61,7 +118,71 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue { * @param now * @return Number of entries written out */ - abstract int writeEntries(@Nonnull final Channel channel, final long now); + int writeEntries(@Nonnull final Channel channel, final long now) { + // Local cache + StackedSegment segment = firstSegment; + int entries = 0; + + while (channel.isWritable()) { + final OutboundQueueEntry entry = segment.getEntry(flushOffset); + if (!entry.isCommitted()) { + LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset); + break; + } + + LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset); + final OfHeader message = entry.takeMessage(); + flushOffset++; + entries++; + + if (message != null) { + manager.writeMessage(message, now); + } else { + entry.complete(null); + } + + if (flushOffset >= StackedSegment.SEGMENT_SIZE) { + /* + * Slow path: purge the current segment unless it's the last one. + * If it is, we leave it for replacement when a new reservation + * is run on it. + * + * This costs us two slow paths, but hey, this should be very rare, + * so let's keep things simple. + */ + synchronized (unflushedSegments) { + LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size()); + + // We may have raced ahead of reservation code and need to allocate a segment + ensureSegment(segment, flushOffset); + + // Remove the segment, update the firstSegment and reset flushOffset + final StackedSegment oldSegment = unflushedSegments.remove(0); + if (oldSegment.isComplete()) { + uncompletedSegments.remove(oldSegment); + oldSegment.recycle(); + } + + // Reset the first segment and add it to the uncompleted list + segment = unflushedSegments.get(0); + uncompletedSegments.add(segment); + + // Update the shutdown offset + if (shutdownOffset != null) { + shutdownOffset -= StackedSegment.SEGMENT_SIZE; + } + + // Allow reservations back on the fast path by publishing the new first segment + firstSegment = segment; + + flushOffset = 0; + LOG.debug("Queue {} flush moved to segment {}", this, segment); + } + } + } + + return entries; + } abstract boolean pairRequest(final OfHeader message); @@ -92,7 +213,7 @@ long startShutdown(final Channel channel) { // Increment the offset by the segment size, preventing fast path allocations, // since we are holding the slow path lock, any reservations will see the queue // in shutdown and fail accordingly. - final long xid = LAST_XID_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); + final long xid = LAST_XID_OFFSET_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); shutdownOffset = (int) (xid - firstSegment.getBaseXid() - StackedSegment.SEGMENT_SIZE); return lockedShutdownFlush(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index 46039904..f19d9aa1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -10,11 +10,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Verify; import com.google.common.util.concurrent.FutureCallback; -import io.netty.channel.Channel; import java.util.Iterator; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.GuardedBy; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,68 +20,12 @@ final class StackedOutboundQueue extends AbstractStackedOutboundQueue { private static final Logger LOG = LoggerFactory.getLogger(StackedOutboundQueue.class); private static final AtomicLongFieldUpdater BARRIER_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "barrierXid"); - private volatile long allocatedXid = -1; private volatile long barrierXid = -1; StackedOutboundQueue(final AbstractOutboundQueueManager manager) { super(manager); } - @GuardedBy("unflushedSegments") - private void ensureSegment(final StackedSegment first, final int offset) { - final int segmentOffset = offset / StackedSegment.SEGMENT_SIZE; - LOG.debug("Queue {} slow offset {} maps to {} segments {}", this, offset, segmentOffset, unflushedSegments.size()); - - for (int i = unflushedSegments.size(); i <= segmentOffset; ++i) { - final StackedSegment newSegment = StackedSegment.create(first.getBaseXid() + (StackedSegment.SEGMENT_SIZE * i)); - LOG.debug("Adding segment {}", newSegment); - unflushedSegments.add(newSegment); - } - - allocatedXid = uncompletedSegments.get(uncompletedSegments.size() - 1).getEndXid(); - } - - /* - * This method is expected to be called from multiple threads concurrently. - */ - @Override - public Long reserveEntry() { - final long xid = LAST_XID_UPDATER.incrementAndGet(this); - final StackedSegment fastSegment = firstSegment; - - if (xid >= fastSegment.getBaseXid() + StackedSegment.SEGMENT_SIZE) { - if (xid >= allocatedXid) { - // Multiple segments, this a slow path - LOG.debug("Queue {} falling back to slow reservation for XID {}", this, xid); - - synchronized (unflushedSegments) { - LOG.debug("Queue {} executing slow reservation for XID {}", this, xid); - - // Shutdown was scheduled, need to fail the reservation - if (shutdownOffset != null) { - LOG.debug("Queue {} is being shutdown, failing reservation", this); - return null; - } - - // Ensure we have the appropriate segment for the specified XID - final StackedSegment slowSegment = firstSegment; - final int slowOffset = (int) (xid - slowSegment.getBaseXid()); - Verify.verify(slowOffset >= 0); - - // Now, we let's see if we need to allocate a new segment - ensureSegment(slowSegment, slowOffset); - - LOG.debug("Queue {} slow reservation finished", this); - } - } else { - LOG.debug("Queue {} XID {} is already backed", this, xid); - } - } - - LOG.trace("Queue {} allocated XID {}", this, xid); - return xid; - } - /* * This method is expected to be called from multiple threads concurrently */ @@ -140,73 +81,6 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall manager.ensureFlushing(); } - @Override - int writeEntries(@Nonnull final Channel channel, final long now) { - // Local cache - StackedSegment segment = firstSegment; - int entries = 0; - - while (channel.isWritable()) { - final OutboundQueueEntry entry = segment.getEntry(flushOffset); - if (!entry.isCommitted()) { - LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset); - break; - } - - LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset); - final OfHeader message = entry.takeMessage(); - flushOffset++; - entries++; - - if (message != null) { - manager.writeMessage(message, now); - } else { - entry.complete(null); - } - - if (flushOffset >= StackedSegment.SEGMENT_SIZE) { - /* - * Slow path: purge the current segment unless it's the last one. - * If it is, we leave it for replacement when a new reservation - * is run on it. - * - * This costs us two slow paths, but hey, this should be very rare, - * so let's keep things simple. - */ - synchronized (unflushedSegments) { - LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size()); - - // We may have raced ahead of reservation code and need to allocate a segment - ensureSegment(segment, flushOffset); - - // Remove the segment, update the firstSegment and reset flushOffset - final StackedSegment oldSegment = unflushedSegments.remove(0); - if (oldSegment.isComplete()) { - uncompletedSegments.remove(oldSegment); - oldSegment.recycle(); - } - - // Reset the first segment and add it to the uncompleted list - segment = unflushedSegments.get(0); - uncompletedSegments.add(segment); - - // Update the shutdown offset - if (shutdownOffset != null) { - shutdownOffset -= StackedSegment.SEGMENT_SIZE; - } - - // Allow reservations back on the fast path by publishing the new first segment - firstSegment = segment; - - flushOffset = 0; - LOG.debug("Queue {} flush moved to segment {}", this, segment); - } - } - } - - return entries; - } - Long reserveBarrierIfNeeded() { final long bXid = barrierXid; final long fXid = firstSegment.getBaseXid() + flushOffset; From 423d6faad0b906453fde66cbe3a219dc25eeeab9 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Thu, 8 Oct 2015 03:07:06 +0200 Subject: [PATCH 213/285] Barrier turn on/off - PacketOut bypass Note: PacketOut doesn't need to wait for any response so it's marked as completed during the process of flushing Change-Id: Ib7372e77cefbafe921f28d48bc6c63d9ff12388c Signed-off-by: Vaclav Demcak (cherry picked from commit 381841508961dcb1587680cdd96437b75383a13b) --- .../impl/core/connection/OutboundQueueEntry.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 4b8820bd..a97a50e9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -13,6 +13,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,10 +58,18 @@ boolean isCompleted() { OfHeader takeMessage() { final OfHeader ret = message; + checkCompletionNeed(); message = null; return ret; } + private void checkCompletionNeed() { + if (callback == null || PacketOutInput.class.isInstance(message)) { + completed = true; + callback = null; + } + } + boolean complete(final OfHeader response) { Preconditions.checkState(!completed, "Attempted to complete a completed message with response %s", response); From d61ef13aa0016d99bb07e27e8e2fe094e805809e Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Thu, 8 Oct 2015 03:30:45 +0200 Subject: [PATCH 214/285] Barrier turn on/off - no Barrier pipeline * impl noBarrier OutboundQueueManager and StackedOutboundQueue Change-Id: I02abcd3618337a9a9373eb59f98565ce61d90ad6 Signed-off-by: Vaclav Demcak (cherry picked from commit 64aebad95b27a6f903a7f65e419cd41df1816c90) --- .../AbstractOutboundQueueManager.java | 2 +- .../AbstractStackedOutboundQueue.java | 76 +++++++++++- .../connection/ConnectionAdapterImpl.java | 9 +- .../core/connection/OutboundQueueEntry.java | 12 +- .../OutboundQueueManagerNoBarrier.java | 30 +++++ .../core/connection/StackedOutboundQueue.java | 80 +----------- .../StackedOutboundQueueNoBarrier.java | 114 ++++++++++++++++++ .../impl/core/connection/StackedSegment.java | 16 ++- 8 files changed, 248 insertions(+), 91 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManagerNoBarrier.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 99bec867..520d145d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -258,7 +258,7 @@ void writeMessage(final OfHeader message, final long now) { * * @return */ - private Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { + protected Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { Preconditions.checkArgument(msg != null); if (address == null) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index 77cb688d..54e779ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -184,7 +184,51 @@ int writeEntries(@Nonnull final Channel channel, final long now) { return entries; } - abstract boolean pairRequest(final OfHeader message); + boolean pairRequest(final OfHeader message) { + Iterator it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment queue = it.next(); + final OutboundQueueEntry entry = queue.pairRequest(message); + if (entry == null) { + continue; + } + + LOG.trace("Queue {} accepted response {}", queue, message); + + // This has been a barrier request, we need to flush all + // previous queues + if (entry.isBarrier() && uncompletedSegments.size() > 1) { + LOG.trace("Queue {} indicated request was a barrier", queue); + + it = uncompletedSegments.iterator(); + while (it.hasNext()) { + final StackedSegment q = it.next(); + + // We want to complete all queues before the current one, we will + // complete the current queue below + if (!queue.equals(q)) { + LOG.trace("Queue {} is implied finished", q); + q.completeAll(); + it.remove(); + q.recycle(); + } else { + break; + } + } + } + + if (queue.isComplete()) { + LOG.trace("Queue {} is finished", queue); + it.remove(); + queue.recycle(); + } + + return true; + } + + LOG.debug("Failed to find completion for message {}", message); + return false; + } boolean needsFlush() { // flushOffset always points to the first entry, which can be changed only @@ -228,6 +272,36 @@ boolean finishShutdown() { return !needsFlush(); } + protected OutboundQueueEntry getEntry(final Long xid) { + final StackedSegment fastSegment = firstSegment; + final long calcOffset = xid - fastSegment.getBaseXid(); + Preconditions.checkArgument(calcOffset >= 0, "Commit of XID %s does not match up with base XID %s", xid, fastSegment.getBaseXid()); + + Verify.verify(calcOffset <= Integer.MAX_VALUE); + final int fastOffset = (int) calcOffset; + + if (fastOffset >= StackedSegment.SEGMENT_SIZE) { + LOG.debug("Queue {} falling back to slow commit of XID {} at offset {}", this, xid, fastOffset); + + final StackedSegment segment; + final int slowOffset; + synchronized (unflushedSegments) { + final StackedSegment slowSegment = firstSegment; + final long slowCalcOffset = xid - slowSegment.getBaseXid(); + Verify.verify(slowCalcOffset >= 0 && slowCalcOffset <= Integer.MAX_VALUE); + slowOffset = (int) slowCalcOffset; + + LOG.debug("Queue {} recalculated offset of XID {} to {}", this, xid, slowOffset); + segment = unflushedSegments.get(slowOffset / StackedSegment.SEGMENT_SIZE); + } + + final int segOffset = slowOffset % StackedSegment.SEGMENT_SIZE; + LOG.debug("Queue {} slow commit of XID {} completed at offset {} (segment {} offset {})", this, xid, slowOffset, segment, segOffset); + return segment.getEntry(segOffset); + } + return fastSegment.getEntry(fastOffset); + } + @GuardedBy("unflushedSegments") private long lockedShutdownFlush() { long entries = 0; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index d22f2f06..37635c03 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -47,7 +47,7 @@ public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics i private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; private SystemNotificationsListener systemListener; - private OutboundQueueManager outputManager; + private AbstractOutboundQueueManager outputManager; private OFVersionDetector versionDetector; private final boolean useBarrier; @@ -192,11 +192,14 @@ public OutboundQueueHandlerRegistration regi final T handler, final int maxQueueDepth, final long maxBarrierNanos) { Preconditions.checkState(outputManager == null, "Manager %s already registered", outputManager); + final AbstractOutboundQueueManager ret; if (useBarrier) { - + ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); + } else { + LOG.warn("OutboundQueueManager without barrier is started."); + ret = new OutboundQueueManagerNoBarrier<>(this, address, handler); } - final OutboundQueueManager ret = new OutboundQueueManager<>(this, address, handler, maxQueueDepth, maxBarrierNanos); outputManager = ret; /* we don't need it anymore */ channel.pipeline().remove(output); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index a97a50e9..70900cad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -58,15 +58,21 @@ boolean isCompleted() { OfHeader takeMessage() { final OfHeader ret = message; - checkCompletionNeed(); + if (!barrier) { + checkCompletionNeed(); + } message = null; return ret; } private void checkCompletionNeed() { - if (callback == null || PacketOutInput.class.isInstance(message)) { + if (callback == null || (message instanceof PacketOutInput)) { completed = true; - callback = null; + if (callback != null) { + callback.onSuccess(null); + callback = null; + } + committed = false; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManagerNoBarrier.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManagerNoBarrier.java new file mode 100644 index 00000000..1fc51473 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManagerNoBarrier.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import java.net.InetSocketAddress; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; + +/** + * + * @param + */ +public class OutboundQueueManagerNoBarrier extends + AbstractOutboundQueueManager { + + OutboundQueueManagerNoBarrier(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler) { + super(parent, address, handler); + } + + @Override + protected StackedOutboundQueueNoBarrier initializeStackedOutboudnqueue() { + return new StackedOutboundQueueNoBarrier(this); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index f19d9aa1..a9876d99 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -7,10 +7,7 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; import com.google.common.util.concurrent.FutureCallback; -import java.util.Iterator; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.slf4j.Logger; @@ -31,35 +28,7 @@ final class StackedOutboundQueue extends AbstractStackedOutboundQueue { */ @Override public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { - final StackedSegment fastSegment = firstSegment; - final long calcOffset = xid - fastSegment.getBaseXid(); - Preconditions.checkArgument(calcOffset >= 0, "Commit of XID %s does not match up with base XID %s", xid, fastSegment.getBaseXid()); - - Verify.verify(calcOffset <= Integer.MAX_VALUE); - final int fastOffset = (int) calcOffset; - - final OutboundQueueEntry entry; - if (fastOffset >= StackedSegment.SEGMENT_SIZE) { - LOG.debug("Queue {} falling back to slow commit of XID {} at offset {}", this, xid, fastOffset); - - final StackedSegment segment; - final int slowOffset; - synchronized (unflushedSegments) { - final StackedSegment slowSegment = firstSegment; - final long slowCalcOffset = xid - slowSegment.getBaseXid(); - Verify.verify(slowCalcOffset >= 0 && slowCalcOffset <= Integer.MAX_VALUE); - slowOffset = (int) slowCalcOffset; - - LOG.debug("Queue {} recalculated offset of XID {} to {}", this, xid, slowOffset); - segment = unflushedSegments.get(slowOffset / StackedSegment.SEGMENT_SIZE); - } - - final int segOffset = slowOffset % StackedSegment.SEGMENT_SIZE; - entry = segment.getEntry(segOffset); - LOG.debug("Queue {} slow commit of XID {} completed at offset {} (segment {} offset {})", this, xid, slowOffset, segment, segOffset); - } else { - entry = fastSegment.getEntry(fastOffset); - } + final OutboundQueueEntry entry = getEntry(xid); entry.commit(message, callback); if (entry.isBarrier()) { @@ -90,51 +59,4 @@ Long reserveBarrierIfNeeded() { } return reserveEntry(); } - - @Override - boolean pairRequest(final OfHeader message) { - Iterator it = uncompletedSegments.iterator(); - while (it.hasNext()) { - final StackedSegment queue = it.next(); - final OutboundQueueEntry entry = queue.pairRequest(message); - if (entry == null) { - continue; - } - - LOG.trace("Queue {} accepted response {}", queue, message); - - // This has been a barrier request, we need to flush all - // previous queues - if (entry.isBarrier() && uncompletedSegments.size() > 1) { - LOG.trace("Queue {} indicated request was a barrier", queue); - - it = uncompletedSegments.iterator(); - while (it.hasNext()) { - final StackedSegment q = it.next(); - - // We want to complete all queues before the current one, we will - // complete the current queue below - if (!queue.equals(q)) { - LOG.trace("Queue {} is implied finished", q); - q.completeAll(); - it.remove(); - q.recycle(); - } else { - break; - } - } - } - - if (queue.isComplete()) { - LOG.trace("Queue {} is finished", queue); - it.remove(); - queue.recycle(); - } - - return true; - } - - LOG.debug("Failed to find completion for message {}", message); - return false; - } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java new file mode 100644 index 00000000..2917631a --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.util.concurrent.FutureCallback; +import io.netty.channel.Channel; +import javax.annotation.Nonnull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class is designed for stacking Statistics and propagate immediate response for all + * another requests. + */ +public class StackedOutboundQueueNoBarrier extends AbstractStackedOutboundQueue { + + private static final Logger LOG = LoggerFactory.getLogger(StackedOutboundQueueNoBarrier.class); + + StackedOutboundQueueNoBarrier(final AbstractOutboundQueueManager manager) { + super(manager); + } + + /* + * This method is expected to be called from multiple threads concurrently + */ + @Override + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + final OutboundQueueEntry entry = getEntry(xid); + + if (message instanceof FlowModInput) { + callback.onSuccess(null); + entry.commit(message, null); + } else { + entry.commit(message, callback); + } + + LOG.trace("Queue {} committed XID {}", this, xid); + manager.ensureFlushing(); + } + + @Override + int writeEntries(@Nonnull final Channel channel, final long now) { + // Local cache + StackedSegment segment = firstSegment; + int entries = 0; + + while (channel.isWritable()) { + final OutboundQueueEntry entry = segment.getEntry(flushOffset); + if (!entry.isCommitted()) { + LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + + flushOffset, segment, flushOffset); + break; + } + + LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset); + final OfHeader message = entry.takeMessage(); + flushOffset++; + entries++; + + if (message != null) { + manager.writeMessage(message, now); + } else { + entry.complete(null); + } + + if (flushOffset >= StackedSegment.SEGMENT_SIZE) { + /* + * Slow path: purge the current segment unless it's the last one. + * If it is, we leave it for replacement when a new reservation + * is run on it. + * This costs us two slow paths, but hey, this should be very rare, + * so let's keep things simple. + */ + synchronized (unflushedSegments) { + LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size()); + + // We may have raced ahead of reservation code and need to allocate a segment + ensureSegment(segment, flushOffset); + + // Remove the segment, update the firstSegment and reset flushOffset + final StackedSegment oldSegment = unflushedSegments.remove(0); + oldSegment.completeAll(); + uncompletedSegments.remove(oldSegment); + oldSegment.recycle(); + + // Reset the first segment and add it to the uncompleted list + segment = unflushedSegments.get(0); + uncompletedSegments.add(segment); + + // Update the shutdown offset + if (shutdownOffset != null) { + shutdownOffset -= StackedSegment.SEGMENT_SIZE; + } + + // Allow reservations back on the fast path by publishing the new first segment + firstSegment = segment; + + flushOffset = 0; + LOG.debug("Queue {} flush moved to segment {}", this, segment); + } + } + } + + return entries; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java index b9030b81..c971c663 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java @@ -109,9 +109,17 @@ private static boolean completeEntry(final OutboundQueueEntry entry, final OfHea LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString()); entry.fail(new DeviceRequestFailedException("Device-side failure", err)); return true; - } else { - return entry.complete(response); } + return entry.complete(response); + } + + OutboundQueueEntry findEntry(final long xid) { + if (! xidInRange(xid)) { + LOG.debug("Queue {} {}/{} ignoring XID {}", this, baseXid, entries.length, xid); + return null; + } + final int offset = (int)(xid - baseXid); + return entries[offset]; } OutboundQueueEntry pairRequest(final OfHeader response) { @@ -122,7 +130,7 @@ OutboundQueueEntry pairRequest(final OfHeader response) { return null; } - final int offset = (int)(xid - baseXid); + final int offset = (int) (xid - baseXid); final OutboundQueueEntry entry = entries[offset]; if (entry.isCompleted()) { LOG.debug("Entry {} already is completed, not accepting response {}", entry, response); @@ -184,7 +192,7 @@ boolean isComplete() { } void recycle() { - for (OutboundQueueEntry e : entries) { + for (final OutboundQueueEntry e : entries) { e.reset(); } From 5946b29760593d24da1dc4f474e4e1b8bab59760 Mon Sep 17 00:00:00 2001 From: Mohamed El-Serngawy Date: Mon, 14 Dec 2015 15:41:25 -0500 Subject: [PATCH 215/285] Add get configuration function to be able to access the openflow connection config from other bundle Change-Id: I2f0b12f1649771226d032ff2644230895e10191b Signed-off-by: Mohamed El-Serngawy --- .../protocol/impl/core/SwitchConnectionProviderImpl.java | 5 +++++ .../protocol/spi/connection/SwitchConnectionProvider.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index f5a39eab..aa79e6a3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -277,4 +277,9 @@ public void initiateConnection(final String host, final int port) { connectionInitializer.initiateConnection(host, port); } + @Override + public ConnectionConfiguration getConfiguration() { + return this.connConfig; + } + } diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index c6910b14..b013471f 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -29,6 +29,12 @@ public interface SwitchConnectionProvider extends AutoCloseable, */ void setConfiguration(ConnectionConfiguration configuration); + /** + * return the connection configuration + * @return configuration [protocol, port, address and supported features] + */ + ConnectionConfiguration getConfiguration(); + /** * start listening to switches, but please don't forget to do * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first From aaae56ee1d7d209100939606c8d98752304ddf29 Mon Sep 17 00:00:00 2001 From: peppepetra Date: Tue, 15 Dec 2015 13:48:25 +0000 Subject: [PATCH 216/285] Extend openflow-protocol-impl serialization - Add new serializers/deserializers for OF1.0/1.3 - Register new MessageFactory's - Register new TypeToClass's - Add relevant unit tests for each factory Change-Id: I9a711aef3d7c4a934369ed1d9e9edfdd0d995f98 Signed-off-by: peppepetra --- ...itionalMessageDeserializerInitializer.java | 103 ++ .../DeserializationFactory.java | 12 +- .../DeserializerRegistryImpl.java | 25 +- .../MessageDeserializerInitializer.java | 9 +- .../TypeToClassMapInitializer.java | 60 +- .../factories/BarrierInputMessageFactory.java | 30 + .../factories/FlowModInputMessageFactory.java | 83 + .../GetAsyncRequestMessageFactory.java | 29 + .../GetConfigInputMessageFactory.java | 30 + .../GetFeaturesInputMessageFactory.java | 25 + .../GetQueueConfigInputMessageFactory.java | 32 + .../GroupModInputMessageFactory.java | 73 + .../MeterModInputMessageFactory.java | 108 ++ .../MultipartRequestInputMessageFactory.java | 433 +++++ .../OF10BarrierInputMessageFactory.java | 30 + .../OF10FeaturesRequestMessageFactory.java | 29 + .../OF10FlowModInputMessageFactory.java | 75 + .../OF10GetConfigInputMessageFactory.java | 29 + ...OF10GetQueueConfigInputMessageFactory.java | 31 + .../OF10PacketOutInputMessageFactory.java | 59 + .../OF10PortModInputMessageFactory.java | 70 + .../OF10SetConfigMessageFactory.java | 32 + .../OF10StatsRequestInputFactory.java | 170 ++ .../PacketOutInputMessageFactory.java | 52 + .../factories/PortModInputMessageFactory.java | 77 + .../RoleRequestInputMessageFactory.java | 38 + .../SetAsyncInputMessageFactory.java | 123 ++ .../SetConfigInputMessageFactory.java | 33 + .../TableModInputMessageFactory.java | 41 + .../AdditionalMessageFactoryInitializer.java | 105 ++ .../MessageFactoryInitializer.java | 7 +- .../serialization/SerializerRegistryImpl.java | 18 +- .../factories/BarrierReplyMessageFactory.java | 30 + .../factories/EchoOutputMessageFactory.java | 36 + .../factories/EchoRequestMessageFactory.java | 35 + .../factories/ErrorMessageFactory.java | 37 + .../factories/ExperimenterMessageFactory.java | 37 + .../factories/FlowRemovedMessageFactory.java | 53 + .../GetAsyncReplyMessageFactory.java | 107 ++ .../GetConfigReplyMessageFactory.java | 32 + .../factories/GetFeaturesOutputFactory.java | 62 + .../factories/HelloMessageFactory.java | 29 + .../MultipartReplyMessageFactory.java | 799 +++++++++ .../OF10BarrierReplyMessageFactory.java | 29 + .../OF10FeaturesReplyMessageFactory.java | 151 ++ .../OF10FlowRemovedMessageFactory.java | 58 + .../factories/OF10PacketInMessageFactory.java | 40 + .../OF10PortStatusMessageFactory.java | 121 ++ ...OF10QueueGetConfigReplyMessageFactory.java | 63 + .../OF10StatsReplyMessageFactory.java | 284 ++++ .../factories/PacketInMessageFactory.java | 54 + .../factories/PortStatusMessageFactory.java | 123 ++ .../QueueGetConfigReplyMessageFactory.java | 88 + .../factories/RoleReplyMessageFactory.java | 33 + .../TypeToClassMapInitializerTest.java | 51 +- .../BarrierInputMessageFactoryTest.java | 42 + .../FlowModInputMessageFactoryTest.java | 163 ++ .../GetAsyncRequestMessageFactoryTest.java | 43 + .../GetConfigInputMessageFactoryTest.java | 42 + .../GetFeaturesInputFactoryTest.java | 42 + ...GetQueueConfigInputMessageFactoryTest.java | 46 + .../GroupModInputMessageFactoryTest.java | 59 + .../MeterModInputMessageFactoryTest.java | 85 + ...questAggregateInputMessageFactoryTest.java | 71 + ...artRequestDescInputMessageFactoryTest.java | 62 + ...artRequestFlowInputMessageFactoryTest.java | 71 + ...rtRequestGroupInputMessageFactoryTest.java | 63 + ...estMeterConfigInputMessageFactoryTest.java | 63 + ...rtRequestMeterInputMessageFactoryTest.java | 61 + ...questPortStatsInputMessageFactoryTest.java | 61 + ...rtRequestQueueInputMessageFactoryTest.java | 62 + ...tTableFeaturesInputMessageFactoryTest.java | 184 ++ ...rtRequestTableInputMessageFactoryTest.java | 49 + .../OF10BarrierInputMessageFactoryTest.java | 42 + ...OF10FeaturesRequestMessageFactoryTest.java | 42 + .../OF10FlowModInputMessageFactoryTest.java | 113 ++ .../OF10GetConfigInputMessageFactoryTest.java | 42 + ...GetQueueConfigInputMessageFactoryTest.java | 45 + .../OF10PacketOutInputMessageFactoryTest.java | 77 + .../OF10PortModInputMessageFactoryTest.java | 57 + .../OF10SetConfigMessageFactoryTest.java | 45 + ...StatsRequestInputAggregateFactoryTest.java | 84 + .../OF10StatsRequestInputDescFactoryTest.java | 59 + .../OF10StatsRequestInputFlowFactoryTest.java | 83 + ...StatsRequestInputPortStatsFactoryTest.java | 59 + ...OF10StatsRequestInputQueueFactoryTest.java | 60 + ...OF10StatsRequestInputTableFactoryTest.java | 59 + .../PacketOutInputMessageFactoryTest.java | 88 + .../PortModInputMessageFactoryTest.java | 58 + .../RoleRequestInputMessageFactoryTest.java | 51 + .../SetAsyncInputMessageFactoryTest.java | 129 ++ .../SetConfigMessageFactoryTest.java | 49 + .../TableModInputMessageFactoryTest.java | 51 + .../BarrierReplyMessageFactoryTest.java | 48 + .../EchoOutputMessageFactoryTest.java | 53 + .../EchoRequestMessageFactoryTest.java | 55 + .../factories/ErrorMessageFactoryTest.java | 58 + .../FlowRemovedMessageFactoryTest.java | 128 ++ .../GetAsyncReplyMessageFactoryTest.java | 145 ++ .../GetConfigReplyMessageFactoryTest.java | 55 + .../GetFeaturesOutputFactoryTest.java | 76 + .../factories/HelloMessageFactoryTest.java | 49 + .../MultipartReplyMessageFactoryTest.java | 1496 +++++++++++++++++ .../OF10BarrierReplyMessageFactoryTest.java | 48 + .../OF10FeaturesReplyMessageFactoryTest.java | 188 +++ .../OF10FlowRemovedMessageFactoryTest.java | 114 ++ .../OF10PacketInMessageFactoryTest.java | 64 + .../OF10PortStatusMessageFactoryTest.java | 129 ++ ...QueueGetConfigReplyMessageFactoryTest.java | 98 ++ .../OF10StatsReplyMessageFactoryTest.java | 413 +++++ .../factories/PacketInMessageFactoryTest.java | 128 ++ .../PortStatusMessageFactoryTest.java | 135 ++ ...QueueGetConfigReplyMessageFactoryTest.java | 123 ++ .../RoleReplyMessageFactoryTest.java | 61 + 114 files changed, 10618 insertions(+), 31 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java new file mode 100644 index 00000000..adbec25c --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.FlowModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetAsyncRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetFeaturesInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetQueueConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GroupModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MeterModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetQueueConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketOutInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10SetConfigMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketOutInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.RoleRequestInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetAsyncInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetConfigInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.TableModInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class AdditionalMessageDeserializerInitializer { + private AdditionalMessageDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers additional message deserializers. + * + * @param registry + * registry to be filled with deserializers + */ + public static void registerMessageDeserializers(DeserializerRegistry registry) { + + SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, + registry); + + // register OF v1.0 message deserializers + helper.registerDeserializer(5, null, GetFeaturesInput.class, new OF10FeaturesRequestMessageFactory()); + helper.registerDeserializer(7, null, GetConfigInput.class, new OF10GetConfigInputMessageFactory()); + helper.registerDeserializer(9, null, SetConfigInput.class, new OF10SetConfigMessageFactory()); + helper.registerDeserializer(13, null, PacketOutInput.class, new OF10PacketOutInputMessageFactory()); + helper.registerDeserializer(14, null, FlowModInput.class, new OF10FlowModInputMessageFactory()); + helper.registerDeserializer(15, null, PortModInput.class, new OF10PortModInputMessageFactory()); + helper.registerDeserializer(16, null, MultipartRequestInput.class, new OF10StatsRequestInputFactory()); + helper.registerDeserializer(18, null, BarrierInput.class, new OF10BarrierInputMessageFactory()); + helper.registerDeserializer(20, null, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory()); + + // register Of v1.3 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(5, null, GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(13, null, PacketOutInput.class, new PacketOutInputMessageFactory()); + helper.registerDeserializer(14, null, FlowModInput.class, new FlowModInputMessageFactory()); + helper.registerDeserializer(15, null, GroupModInput.class, new GroupModInputMessageFactory()); + helper.registerDeserializer(16, null, PortModInput.class, new PortModInputMessageFactory()); + helper.registerDeserializer(17, null, TableModInput.class, new TableModInputMessageFactory()); + helper.registerDeserializer(18, null, MultipartRequestInput.class, new MultipartRequestInputMessageFactory()); + helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); + helper.registerDeserializer(22, null, GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); + helper.registerDeserializer(24, null, RoleRequestInput.class, new RoleRequestInputMessageFactory()); + helper.registerDeserializer(26, null, GetAsyncInput.class, new GetAsyncRequestMessageFactory()); + helper.registerDeserializer(28, null, SetAsyncInput.class, new SetAsyncInputMessageFactory()); + helper.registerDeserializer(29, null, MeterModInput.class, new MeterModInputMessageFactory()); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index 51e1ff6f..bf535b2d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -22,6 +22,7 @@ /** * @author michal.polkorab * @author timotej.kubas + * @author giuseppex.petralia@intel.com */ public class DeserializationFactory { @@ -34,13 +35,19 @@ public class DeserializationFactory { public DeserializationFactory() { final Map> temp = new HashMap<>(); TypeToClassMapInitializer.initializeTypeToClassMap(temp); + + // Register type to class map for additional deserializers + TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(temp); + messageClassMap = ImmutableMap.copyOf(temp); } /** * Transforms ByteBuf into correct POJO message + * * @param rawMessage - * @param version version decoded from OpenFlow protocol message + * @param version + * version decoded from OpenFlow protocol message * @return correct POJO as DataObject */ public DataObject deserialize(final ByteBuf rawMessage, final short version) { @@ -48,8 +55,7 @@ public DataObject deserialize(final ByteBuf rawMessage, final short version) { int type = rawMessage.readUnsignedByte(); Class clazz = messageClassMap.get(new TypeToClassKey(version, type)); rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - OFDeserializer deserializer = registry.getDeserializer( - new MessageCodeKey(version, type, clazz)); + OFDeserializer deserializer = registry.getDeserializer(new MessageCodeKey(version, type, clazz)); dataObject = deserializer.deserialize(rawMessage); return dataObject; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index bbbb0681..6ee48183 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -24,6 +24,7 @@ /** * Stores and registers deserializers + * * @author michal.polkorab */ public class DeserializerRegistryImpl implements DeserializerRegistry { @@ -37,14 +38,20 @@ public class DeserializerRegistryImpl implements DeserializerRegistry { @Override public void init() { registry = new HashMap<>(); + // register message deserializers MessageDeserializerInitializer.registerMessageDeserializers(this); + // register additional message deserializers + AdditionalMessageDeserializerInitializer.registerMessageDeserializers(this); + // register common structure deserializers - registerDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, - EncodeConstants.EMPTY_VALUE, MatchV10.class), new OF10MatchDeserializer()); - registerDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EMPTY_VALUE, Match.class), new MatchDeserializer()); + registerDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class), + new OF10MatchDeserializer()); + registerDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class), + new MatchDeserializer()); // register match entry deserializers MatchEntryDeserializerInitializer.registerMatchEntryDeserializers(this); @@ -56,8 +63,7 @@ public void init() { @Override @SuppressWarnings("unchecked") - public T getDeserializer( - MessageCodeKey key) { + public T getDeserializer(MessageCodeKey key) { OFGeneralDeserializer deserializer = registry.get(key); if (deserializer == null) { throw new IllegalStateException("Deserializer for key: " + key @@ -67,15 +73,14 @@ public T getDeserializer( } @Override - public void registerDeserializer(MessageCodeKey key, - OFGeneralDeserializer deserializer) { + public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) { if ((key == null) || (deserializer == null)) { throw new IllegalArgumentException("MessageCodeKey or Deserializer is null"); } OFGeneralDeserializer desInRegistry = registry.put(key, deserializer); if (desInRegistry != null) { - LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", - key, desInRegistry.getClass().getName(), deserializer.getClass().getName()); + LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key, + desInRegistry.getClass().getName(), deserializer.getClass().getName()); } if (deserializer instanceof DeserializerRegistryInjector) { ((DeserializerRegistryInjector) deserializer).injectDeserializerRegistry(this); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 37f3a71f..0e672024 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -66,12 +66,14 @@ private MessageDeserializerInitializer() { /** * Registers message deserializers - * @param registry registry to be filled with deserializers + * + * @param registry + * registry to be filled with deserializers */ public static void registerMessageDeserializers(DeserializerRegistry registry) { // register OF v1.0 message deserializers - SimpleDeserializerRegistryHelper helper = - new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, + registry); helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); @@ -85,6 +87,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + // register Of v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 9ed52140..97ae5364 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -8,28 +8,43 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import java.util.Map; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** * @author michal.polkorab + * @author giuseppex.petralia@intel.com * */ public final class TypeToClassMapInitializer { @@ -40,12 +55,12 @@ private TypeToClassMapInitializer() { /** * Initializes type to class map + * * @param messageClassMap */ public static void initializeTypeToClassMap(Map> messageClassMap) { // init OF v1.0 mapping - TypeToClassInitHelper helper = - new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 1, ErrorMessage.class); helper.registerTypeToClass((short) 2, EchoRequestMessage.class); @@ -59,7 +74,7 @@ public static void initializeTypeToClassMap(Map> messag helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); helper.registerTypeToClass((short) 19, BarrierOutput.class); helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); - // init OF v1.0 mapping + // init OF v1.3 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 1, ErrorMessage.class); @@ -77,4 +92,41 @@ public static void initializeTypeToClassMap(Map> messag helper.registerTypeToClass((short) 25, RoleRequestOutput.class); helper.registerTypeToClass((short) 27, GetAsyncOutput.class); } + + /** + * Initializes type to class map to associate OF code to Java Class for + * messages for additional deserializers. + * + * @param messageClassMap + */ + public static void initializeAdditionalTypeToClassMap(Map> messageClassMap) { + // init OF v1.0 mapping + TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 5, GetFeaturesInput.class); + helper.registerTypeToClass((short) 7, GetConfigInput.class); + helper.registerTypeToClass((short) 9, SetConfigInput.class); + helper.registerTypeToClass((short) 13, PacketOutInput.class); + helper.registerTypeToClass((short) 14, FlowModInput.class); + helper.registerTypeToClass((short) 15, PortModInput.class); + helper.registerTypeToClass((short) 16, MultipartRequestInput.class); + helper.registerTypeToClass((short) 18, BarrierInput.class); + helper.registerTypeToClass((short) 20, GetQueueConfigInput.class); + // init OF v1.3 mapping + helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 5, GetFeaturesInput.class); + helper.registerTypeToClass((short) 7, GetConfigInput.class); + helper.registerTypeToClass((short) 9, SetConfigInput.class); + helper.registerTypeToClass((short) 13, PacketOutInput.class); + helper.registerTypeToClass((short) 14, FlowModInput.class); + helper.registerTypeToClass((short) 15, GroupModInput.class); + helper.registerTypeToClass((short) 16, PortModInput.class); + helper.registerTypeToClass((short) 17, TableModInput.class); + helper.registerTypeToClass((short) 18, MultipartRequestInput.class); + helper.registerTypeToClass((short) 20, BarrierInput.class); + helper.registerTypeToClass((short) 22, GetQueueConfigInput.class); + helper.registerTypeToClass((short) 24, RoleRequestInput.class); + helper.registerTypeToClass((short) 26, GetAsyncInput.class); + helper.registerTypeToClass((short) 28, SetAsyncInput.class); + helper.registerTypeToClass((short) 29, MeterModInput.class); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java new file mode 100644 index 00000000..fd3af02e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class BarrierInputMessageFactory implements OFDeserializer{ + + @Override + public BarrierInput deserialize(ByteBuf rawMessage) { + BarrierInputBuilder builder = new BarrierInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java new file mode 100644 index 00000000..1531c8eb --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactory.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; + +/** + * Translates FlowModInput messages + */ +public class FlowModInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + + private static final byte PADDING = 2; + private DeserializerRegistry registry; + + @Override + public FlowModInput deserialize(ByteBuf rawMessage) { + FlowModInputBuilder builder = new FlowModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(cookie); + builder.setCookie(new BigInteger(1, cookie)); + byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(cookie_mask); + builder.setCookieMask(new BigInteger(1, cookie_mask)); + builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); + builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedByte())); + builder.setIdleTimeout(rawMessage.readUnsignedShort()); + builder.setHardTimeout(rawMessage.readUnsignedShort()); + builder.setPriority(rawMessage.readUnsignedShort()); + builder.setBufferId(rawMessage.readUnsignedInt()); + builder.setOutPort(new PortNumber(rawMessage.readUnsignedInt())); + builder.setOutGroup(rawMessage.readUnsignedInt()); + builder.setFlags(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort())); + rawMessage.skipBytes(PADDING); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); + builder.setMatch(matchDeserializer.deserialize(rawMessage)); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + rawMessage.readableBytes(), rawMessage, keyMaker, registry); + builder.setInstruction(instructions); + return builder.build(); + } + + private static FlowModFlags createFlowModFlagsFromBitmap(int input) { + final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0; + final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0; + final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; + final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0; + final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0; + return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, + _oFPFFSENDFLOWREM); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java new file mode 100644 index 00000000..6a3485ec --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetAsyncRequestMessageFactory implements OFDeserializer { + + @Override + public GetAsyncInput deserialize(ByteBuf rawMessage) { + GetAsyncInputBuilder builder = new GetAsyncInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid((rawMessage.readUnsignedInt())); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java new file mode 100644 index 00000000..5c6fd0b6 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetConfigInputMessageFactory implements OFDeserializer { + + @Override + public GetConfigInput deserialize(ByteBuf rawMessage) { + GetConfigInputBuilder builder = new GetConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java new file mode 100644 index 00000000..4295644c --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder; + +public class GetFeaturesInputMessageFactory implements OFDeserializer { + + @Override + public GetFeaturesInput deserialize(ByteBuf rawMessage) { + GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java new file mode 100644 index 00000000..8b63dac5 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetQueueConfigInputMessageFactory implements OFDeserializer { + + @Override + public GetQueueConfigInput deserialize(ByteBuf rawMessage) { + GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid((rawMessage.readUnsignedInt())); + builder.setPort(new PortNumber(rawMessage.readUnsignedInt())); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java new file mode 100644 index 00000000..5d7de02b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactory.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GroupModInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + + private DeserializerRegistry registry; + private static final byte PADDING = 1; + private static final byte PADDING_IN_BUCKETS_HEADER = 4; + private static final byte BUCKETS_HEADER_LENGTH = 16; + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } + + @Override + public GroupModInput deserialize(ByteBuf rawMessage) { + GroupModInputBuilder builder = new GroupModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setCommand(GroupModCommand.forValue(rawMessage.readUnsignedShort())); + builder.setType(GroupType.forValue(rawMessage.readUnsignedByte())); + rawMessage.skipBytes(PADDING); + builder.setGroupId(new GroupId(rawMessage.readUnsignedInt())); + List bucketsList = new ArrayList<>(); + while (rawMessage.readableBytes() > 0) { + BucketsListBuilder bucketsBuilder = new BucketsListBuilder(); + int bucketsLength = rawMessage.readUnsignedShort(); + bucketsBuilder.setWeight(rawMessage.readUnsignedShort()); + bucketsBuilder.setWatchPort(new PortNumber(rawMessage.readUnsignedInt())); + bucketsBuilder.setWatchGroup(rawMessage.readUnsignedInt()); + rawMessage.skipBytes(PADDING_IN_BUCKETS_HEADER); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + bucketsLength - BUCKETS_HEADER_LENGTH, rawMessage, keyMaker, registry); + bucketsBuilder.setAction(actions); + bucketsList.add(bucketsBuilder.build()); + } + builder.setBucketsList(bucketsList); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java new file mode 100644 index 00000000..0196b4b4 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MeterModInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + + private DeserializerRegistry registry; + private static final byte PADDING_IN_METER_BAND_DROP_HEADER = 4; + private static final byte PADDING_IN_METER_BAND_DSCP_HEADER = 3; + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } + + @Override + public MeterModInput deserialize(ByteBuf rawMessage) { + MeterModInputBuilder builder = new MeterModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setCommand(MeterModCommand.forValue(rawMessage.readUnsignedShort())); + builder.setFlags(createMeterFlags(rawMessage.readUnsignedShort())); + builder.setMeterId(new MeterId(rawMessage.readUnsignedInt())); + List bandsList = new ArrayList<>(); + while (rawMessage.readableBytes() > 0) { + BandsBuilder bandsBuilder = new BandsBuilder(); + int bandStartIndex = rawMessage.readerIndex(); + int bandType = rawMessage.readUnsignedShort(); + switch (bandType) { + case 1: + MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder(); + MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder(); + bandDropBuilder.setType(MeterBandType.forValue(bandType)); + rawMessage.readUnsignedShort(); + bandDropBuilder.setRate(rawMessage.readUnsignedInt()); + bandDropBuilder.setBurstSize(rawMessage.readUnsignedInt()); + rawMessage.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER); + bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build()); + bandsBuilder.setMeterBand(bandDropCaseBuilder.build()); + break; + case 2: + MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); + MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder(); + bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType)); + rawMessage.readUnsignedShort(); + bandDscpRemarkBuilder.setRate(rawMessage.readUnsignedInt()); + bandDscpRemarkBuilder.setBurstSize(rawMessage.readUnsignedInt()); + bandDscpRemarkBuilder.setPrecLevel(rawMessage.readUnsignedByte()); + rawMessage.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER); + bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build()); + bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build()); + break; + case 0xFFFF: + long expId = rawMessage + .getUnsignedInt(rawMessage.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES); + rawMessage.readerIndex(bandStartIndex); + OFDeserializer deserializer = registry + .getDeserializer(ExperimenterDeserializerKeyFactory + .createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId)); + bandsBuilder.setMeterBand(deserializer.deserialize(rawMessage)); + break; + } + bandsList.add(bandsBuilder.build()); + } + builder.setBands(bandsList); + return builder.build(); + } + + private static MeterFlags createMeterFlags(int input) { + final Boolean mfKBPS = (input & (1 << 0)) != 0; + final Boolean mfPKTPS = (input & (1 << 1)) != 0; + final Boolean mfBURST = (input & (1 << 2)) != 0; + final Boolean mfSTATS = (input & (1 << 3)) != 0; + return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java new file mode 100644 index 00000000..008b22c3 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java @@ -0,0 +1,433 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestInputMessageFactory + implements OFDeserializer, DeserializerRegistryInjector { + private DeserializerRegistry registry; + private static final byte PADDING = 4; + private static final byte FLOW_PADDING_1 = 3; + private static final byte FLOW_PADDING_2 = 4; + private static final byte AGGREGATE_PADDING_1 = 3; + private static final byte AGGREGATE_PADDING_2 = 4; + private static final byte PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES = 5; + private static final byte MAX_TABLE_NAME_LENGTH = 32; + private static final byte MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH = 64; + private static final byte COMMON_PROPERTY_LENGTH = 4; + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } + + @Override + public MultipartRequestInput deserialize(ByteBuf rawMessage) { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + int type = rawMessage.readUnsignedShort(); + builder.setType(getMultipartType(type)); + builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort())); + rawMessage.skipBytes(PADDING); + switch (MultipartType.forValue(type)) { + case OFPMPDESC: + builder.setMultipartRequestBody(setDesc(rawMessage)); + break; + case OFPMPFLOW: + builder.setMultipartRequestBody(setFlow(rawMessage)); + break; + case OFPMPAGGREGATE: + builder.setMultipartRequestBody(setAggregate(rawMessage)); + break; + case OFPMPTABLE: + builder.setMultipartRequestBody(setTable(rawMessage)); + break; + case OFPMPTABLEFEATURES: + builder.setMultipartRequestBody(setTableFeatures(rawMessage)); + break; + case OFPMPPORTSTATS: + builder.setMultipartRequestBody(setPortStats(rawMessage)); + break; + case OFPMPPORTDESC: + builder.setMultipartRequestBody(setPortDesc(rawMessage)); + break; + case OFPMPQUEUE: + builder.setMultipartRequestBody(setQueue(rawMessage)); + break; + case OFPMPGROUP: + builder.setMultipartRequestBody(setGroup(rawMessage)); + break; + case OFPMPGROUPDESC: + builder.setMultipartRequestBody(setGroupDesc(rawMessage)); + break; + case OFPMPGROUPFEATURES: + builder.setMultipartRequestBody(setGroupFeatures(rawMessage)); + break; + case OFPMPMETER: + builder.setMultipartRequestBody(setMeter(rawMessage)); + break; + case OFPMPMETERCONFIG: + builder.setMultipartRequestBody(setMeterConfig(rawMessage)); + break; + case OFPMPMETERFEATURES: + builder.setMultipartRequestBody(setMeterFeatures(rawMessage)); + break; + case OFPMPEXPERIMENTER: + builder.setMultipartRequestBody(setExperimenter(rawMessage)); + break; + default: + break; + } + + return builder.build(); + } + + private static MultipartType getMultipartType(int input) { + return MultipartType.forValue(input); + } + + private static MultipartRequestFlags getMultipartRequestFlags(int input) { + final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0; + MultipartRequestFlags flag = new MultipartRequestFlags(_oFPMPFREQMORE); + return flag; + } + + private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) { + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder(); + List features = new ArrayList<>(); + while (input.readableBytes() > 0) { + TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder(); + int length = input.readUnsignedShort(); + featuresBuilder.setTableId(input.readUnsignedByte()); + input.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES); + featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataMatch); + featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch)); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataWrite); + featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite)); + featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt())); + featuresBuilder.setMaxEntries(input.readUnsignedInt()); + featuresBuilder.setTableFeatureProperties( + createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH)); + features.add(featuresBuilder.build()); + } + tableFeaturesBuilder.setTableFeatures(features); + caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build()); + return caseBuilder.build(); + } + + private List createTableFeaturesProperties(ByteBuf input, int length) { + List properties = new ArrayList<>(); + int tableFeaturesLength = length; + while (tableFeaturesLength > 0) { + int propStartIndex = input.readerIndex(); + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + TableFeaturesPropType type = TableFeaturesPropType.forValue(input.readUnsignedShort()); + builder.setType(type); + int propertyLength = input.readUnsignedShort(); + int paddingRemainder = propertyLength % EncodeConstants.PADDING; + tableFeaturesLength -= propertyLength; + if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS) + || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) { + InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List instructions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); + insBuilder.setInstruction(instructions); + builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build()); + } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES) + || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) { + propertyLength -= COMMON_PROPERTY_LENGTH; + NextTableRelatedTableFeaturePropertyBuilder tableBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + List ids = new ArrayList<>(); + while (propertyLength > 0) { + NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder(); + nextTableIdsBuilder.setTableId(input.readUnsignedByte()); + ids.add(nextTableIdsBuilder.build()); + propertyLength--; + } + tableBuilder.setNextTableIds(ids); + builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, tableBuilder.build()); + } else if (type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONS) + || type.equals(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS) + || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS) + || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) { + ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); + actionBuilder.setAction(actions); + builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build()); + } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH) + || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS) + || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELD) + || type.equals(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS) + || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD) + || type.equals(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS)) { + OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + List entries = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + propertyLength - COMMON_PROPERTY_LENGTH, input, keyMaker, registry); + oxmBuilder.setMatchEntry(entries); + builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + } else if (type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTER) + || type.equals(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS)) { + long expId = input.readUnsignedInt(); + input.readerIndex(propStartIndex); + OFDeserializer propDeserializer = registry + .getDeserializer(ExperimenterDeserializerKeyFactory + .createMultipartReplyTFDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId)); + TableFeatureProperties expProp = propDeserializer.deserialize(input); + properties.add(expProp); + continue; + } + if (paddingRemainder != 0) { + input.skipBytes(EncodeConstants.PADDING - paddingRemainder); + tableFeaturesLength -= EncodeConstants.PADDING - paddingRemainder; + } + properties.add(builder.build()); + } + return properties; + } + + private static TableConfig createTableConfig(long input) { + boolean deprecated = (input & 3) != 0; + return new TableConfig(deprecated); + } + + private MultipartRequestDescCase setDesc(ByteBuf input) { + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestDesc(descBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestFlowCase setFlow(ByteBuf input) { + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + flowBuilder.setTableId(input.readUnsignedByte()); + input.skipBytes(FLOW_PADDING_1); + flowBuilder.setOutPort(input.readUnsignedInt()); + flowBuilder.setOutGroup(input.readUnsignedInt()); + input.skipBytes(FLOW_PADDING_2); + byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(cookie); + flowBuilder.setCookie(new BigInteger(1, cookie)); + byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(cookie_mask); + flowBuilder.setCookieMask(new BigInteger(1, cookie_mask)); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); + flowBuilder.setMatch(matchDeserializer.deserialize(input)); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestAggregateCase setAggregate(ByteBuf input) { + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder(); + aggregateBuilder.setTableId(input.readUnsignedByte()); + input.skipBytes(AGGREGATE_PADDING_1); + aggregateBuilder.setOutPort(input.readUnsignedInt()); + aggregateBuilder.setOutGroup(input.readUnsignedInt()); + input.skipBytes(AGGREGATE_PADDING_2); + byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(cookie); + aggregateBuilder.setCookie(new BigInteger(1, cookie)); + byte[] cookie_mask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(cookie_mask); + aggregateBuilder.setCookieMask(new BigInteger(1, cookie_mask)); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); + aggregateBuilder.setMatch(matchDeserializer.deserialize(input)); + caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestPortDescCase setPortDesc(ByteBuf input) { + MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); + MultipartRequestPortDescBuilder portBuilder = new MultipartRequestPortDescBuilder(); + portBuilder.setEmpty(true); + caseBuilder.setMultipartRequestPortDesc(portBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestPortStatsCase setPortStats(ByteBuf input) { + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); + portBuilder.setPortNo(input.readUnsignedInt()); + caseBuilder.setMultipartRequestPortStats(portBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestQueueCase setQueue(ByteBuf input) { + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); + queueBuilder.setPortNo(input.readUnsignedInt()); + queueBuilder.setQueueId(input.readUnsignedInt()); + caseBuilder.setMultipartRequestQueue(queueBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestGroupCase setGroup(ByteBuf input) { + MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder(); + MultipartRequestGroupBuilder groupBuilder = new MultipartRequestGroupBuilder(); + groupBuilder.setGroupId(new GroupId(input.readUnsignedInt())); + caseBuilder.setMultipartRequestGroup(groupBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestGroupDescCase setGroupDesc(ByteBuf input) { + MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); + MultipartRequestGroupDescBuilder groupBuilder = new MultipartRequestGroupDescBuilder(); + groupBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupDesc(groupBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestGroupFeaturesCase setGroupFeatures(ByteBuf input) { + MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); + MultipartRequestGroupFeaturesBuilder groupBuilder = new MultipartRequestGroupFeaturesBuilder(); + groupBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupFeatures(groupBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestMeterCase setMeter(ByteBuf input) { + MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder(); + MultipartRequestMeterBuilder meterBuilder = new MultipartRequestMeterBuilder(); + meterBuilder.setMeterId(new MeterId(input.readUnsignedInt())); + caseBuilder.setMultipartRequestMeter(meterBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestMeterConfigCase setMeterConfig(ByteBuf input) { + MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder(); + MultipartRequestMeterConfigBuilder meterBuilder = new MultipartRequestMeterConfigBuilder(); + meterBuilder.setMeterId(new MeterId(input.readUnsignedInt())); + caseBuilder.setMultipartRequestMeterConfig(meterBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestMeterFeaturesCase setMeterFeatures(ByteBuf input) { + MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); + MultipartRequestMeterFeaturesBuilder meterBuilder = new MultipartRequestMeterFeaturesBuilder(); + meterBuilder.setEmpty(true); + caseBuilder.setMultipartRequestMeterFeatures(meterBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestTableCase setTable(ByteBuf input) { + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); + tableBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tableBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) { + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder(); + caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java new file mode 100644 index 00000000..ab08ea30 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10BarrierInputMessageFactory implements OFDeserializer { + + @Override + public BarrierInput deserialize(ByteBuf rawMessage) { + BarrierInputBuilder builder = new BarrierInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java new file mode 100644 index 00000000..1ff8c7a1 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FeaturesRequestMessageFactory implements OFDeserializer { + + @Override + public GetFeaturesInput deserialize(ByteBuf rawMessage) { + GetFeaturesInputBuilder builder = new GetFeaturesInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java new file mode 100644 index 00000000..3357995a --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactory.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FlowModInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } + + @Override + public FlowModInput deserialize(ByteBuf rawMessage) { + FlowModInputBuilder builder = new FlowModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); + builder.setMatchV10(matchDeserializer.deserialize(rawMessage)); + byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(cookie); + builder.setCookie(new BigInteger(1, cookie)); + builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedShort())); + builder.setIdleTimeout(rawMessage.readUnsignedShort()); + builder.setHardTimeout(rawMessage.readUnsignedShort()); + builder.setPriority(rawMessage.readUnsignedShort()); + builder.setBufferId(rawMessage.readUnsignedInt()); + builder.setOutPort(new PortNumber((long) rawMessage.readUnsignedShort())); + builder.setFlagsV10(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort())); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); + + List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, + rawMessage.readableBytes(), rawMessage, keyMaker, registry); + builder.setAction(actions); + return builder.build(); + } + + private static FlowModFlagsV10 createFlowModFlagsFromBitmap(int input) { + final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0; + final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0; + final Boolean _oFPFFEMERG = (input & (1 << 2)) > 0; + return new FlowModFlagsV10(_oFPFFCHECKOVERLAP, _oFPFFEMERG, _oFPFFSENDFLOWREM); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java new file mode 100644 index 00000000..d46dcac1 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10GetConfigInputMessageFactory implements OFDeserializer { + + @Override + public GetConfigInput deserialize(ByteBuf rawMessage) { + GetConfigInputBuilder builder = new GetConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java new file mode 100644 index 00000000..7584a734 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10GetQueueConfigInputMessageFactory implements OFDeserializer { + + @Override + public GetQueueConfigInput deserialize(ByteBuf rawMessage) { + GetQueueConfigInputBuilder builder = new GetQueueConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid((rawMessage.readUnsignedInt())); + builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort())); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java new file mode 100644 index 00000000..1f4d2c1e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PacketOutInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } + + @Override + public PacketOutInput deserialize(ByteBuf rawMessage) { + PacketOutInputBuilder builder = new PacketOutInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setBufferId(rawMessage.readUnsignedInt()); + builder.setInPort(new PortNumber((long) rawMessage.readUnsignedShort())); + int actions_len = rawMessage.readShort(); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, actions_len, + rawMessage, keyMaker, registry); + builder.setAction(actions); + + byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array(); + + if (data != null) { + + builder.setData(data); + } + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java new file mode 100644 index 00000000..1e869eb0 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactory.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PortModInputMessageFactory implements OFDeserializer { + + @Override + public PortModInput deserialize(ByteBuf rawMessage) { + PortModInputBuilder builder = new PortModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort())); + byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + rawMessage.readBytes(hwAddress); + builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); + builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); + builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt())); + builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt())); + return builder.build(); + } + + private static PortConfigV10 createPortConfig(long input) { + final Boolean _portDown = ((input) & (1 << 0)) > 0; + final Boolean _noStp = ((input) & (1 << 1)) > 0; + final Boolean _noRecv = ((input) & (1 << 2)) > 0; + final Boolean _noRecvStp = ((input) & (1 << 3)) > 0; + final Boolean _noFlood = ((input) & (1 << 4)) > 0; + final Boolean _noFwd = ((input) & (1 << 5)) > 0; + final Boolean _noPacketIn = ((input) & (1 << 6)) > 0; + return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); + } + + private static PortFeaturesV10 createPortFeatures(long input) { + final Boolean _10mbHd = ((input) & (1 << 0)) > 0; + final Boolean _10mbFd = ((input) & (1 << 1)) > 0; + final Boolean _100mbHd = ((input) & (1 << 2)) > 0; + final Boolean _100mbFd = ((input) & (1 << 3)) > 0; + final Boolean _1gbHd = ((input) & (1 << 4)) > 0; + final Boolean _1gbFd = ((input) & (1 << 5)) > 0; + final Boolean _10gbFd = ((input) & (1 << 6)) > 0; + final Boolean _copper = ((input) & (1 << 7)) > 0; + final Boolean _fiber = ((input) & (1 << 8)) > 0; + final Boolean _autoneg = ((input) & (1 << 9)) > 0; + final Boolean _pause = ((input) & (1 << 10)) > 0; + final Boolean _pauseAsym = ((input) & (1 << 11)) > 0; + return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper, + _fiber, _pause, _pauseAsym); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java new file mode 100644 index 00000000..23c4de21 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10SetConfigMessageFactory implements OFDeserializer { + + @Override + public SetConfigInput deserialize(ByteBuf rawMessage) { + SetConfigInputBuilder builder = new SetConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); + builder.setMissSendLen(rawMessage.readUnsignedShort()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java new file mode 100644 index 00000000..4f49f195 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputFactory + implements OFDeserializer, DeserializerRegistryInjector { + private DeserializerRegistry registry; + private static final byte FLOW_PADDING_1 = 1; + private static final byte AGGREGATE_PADDING_1 = 1; + + @Override + public MultipartRequestInput deserialize(ByteBuf rawMessage) { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + int type = rawMessage.readUnsignedShort(); + builder.setType(getMultipartType(type)); + builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort())); + switch (getMultipartType(type)) { + case OFPMPDESC: + builder.setMultipartRequestBody(setDesc(rawMessage)); + break; + case OFPMPFLOW: + builder.setMultipartRequestBody(setFlow(rawMessage)); + break; + case OFPMPAGGREGATE: + builder.setMultipartRequestBody(setAggregate(rawMessage)); + break; + case OFPMPTABLE: + builder.setMultipartRequestBody(setTable(rawMessage)); + break; + case OFPMPPORTSTATS: + builder.setMultipartRequestBody(setPortStats(rawMessage)); + break; + case OFPMPQUEUE: + builder.setMultipartRequestBody(setQueue(rawMessage)); + break; + case OFPMPEXPERIMENTER: + builder.setMultipartRequestBody(setExperimenter(rawMessage)); + break; + default: + break; + } + return builder.build(); + } + + private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) { + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder(); + caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestQueueCase setQueue(ByteBuf input) { + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); + queueBuilder.setPortNo((long) input.readUnsignedShort()); + input.skipBytes(2); + queueBuilder.setQueueId(input.readUnsignedInt()); + caseBuilder.setMultipartRequestQueue(queueBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestPortStatsCase setPortStats(ByteBuf input) { + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); + portBuilder.setPortNo((long) input.readUnsignedShort()); + caseBuilder.setMultipartRequestPortStats(portBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestTableCase setTable(ByteBuf input) { + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); + tableBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tableBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestAggregateCase setAggregate(ByteBuf input) { + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder(); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); + aggregateBuilder.setMatchV10(matchDeserializer.deserialize(input)); + aggregateBuilder.setTableId(input.readUnsignedByte()); + input.skipBytes(AGGREGATE_PADDING_1); + aggregateBuilder.setOutPort((long) input.readUnsignedShort()); + caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestFlowCase setFlow(ByteBuf input) { + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + OFDeserializer matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); + flowBuilder.setMatchV10(matchDeserializer.deserialize(input)); + flowBuilder.setTableId(input.readUnsignedByte()); + input.skipBytes(FLOW_PADDING_1); + flowBuilder.setOutPort((long) input.readUnsignedShort()); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + return caseBuilder.build(); + } + + private MultipartRequestDescCase setDesc(ByteBuf input) { + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestDesc(descBuilder.build()); + return caseBuilder.build(); + } + + private static MultipartRequestFlags getMultipartRequestFlags(int input) { + final Boolean _oFPMPFREQMORE = (input & (1 << 0)) > 0; + MultipartRequestFlags flag = new MultipartRequestFlags(_oFPMPFREQMORE); + return flag; + } + + private static MultipartType getMultipartType(int input) { + return MultipartType.forValue(input); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java new file mode 100644 index 00000000..6b1ddc94 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder; + +public class PacketOutInputMessageFactory implements OFDeserializer, DeserializerRegistryInjector { + private DeserializerRegistry registry; + private final byte PADDING = 6; + + @Override + public PacketOutInput deserialize(ByteBuf rawMessage) { + PacketOutInputBuilder builder = new PacketOutInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setBufferId(rawMessage.readUnsignedInt()); + builder.setInPort(new PortNumber(rawMessage.readUnsignedInt())); + int actions_len = rawMessage.readShort(); + rawMessage.skipBytes(PADDING); + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len, + rawMessage, keyMaker, registry); + builder.setAction(actions); + byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array(); + if (data != null) { + builder.setData(data); + } + return builder.build(); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + registry = deserializerRegistry; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java new file mode 100644 index 00000000..37bfd722 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactory.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PortModInputMessageFactory implements OFDeserializer { + + private static final byte PADDING_IN_PORT_MOD_MESSAGE_1 = 4; + private static final byte PADDING_IN_PORT_MOD_MESSAGE_2 = 2; + private static final byte PADDING_IN_PORT_MOD_MESSAGE_3 = 4; + + @Override + public PortModInput deserialize(ByteBuf rawMessage) { + PortModInputBuilder builder = new PortModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt())); + rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1); + byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + rawMessage.readBytes(hwAddress); + builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); + rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2); + builder.setConfig(createPortConfig(rawMessage.readUnsignedInt())); + builder.setMask(createPortConfig(rawMessage.readUnsignedInt())); + builder.setAdvertise(createPortFeatures(rawMessage.readUnsignedInt())); + rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_3); + return builder.build(); + } + + private static PortConfig createPortConfig(long input) { + final Boolean pcPortDown = ((input) & (1 << 0)) != 0; + final Boolean pcNRecv = ((input) & (1 << 2)) != 0; + final Boolean pcNFwd = ((input) & (1 << 5)) != 0; + final Boolean pcNPacketIn = ((input) & (1 << 6)) != 0; + return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); + } + + private static PortFeatures createPortFeatures(long input) { + final Boolean pf10mbHd = ((input) & (1 << 0)) != 0; + final Boolean pf10mbFd = ((input) & (1 << 1)) != 0; + final Boolean pf100mbHd = ((input) & (1 << 2)) != 0; + final Boolean pf100mbFd = ((input) & (1 << 3)) != 0; + final Boolean pf1gbHd = ((input) & (1 << 4)) != 0; + final Boolean pf1gbFd = ((input) & (1 << 5)) != 0; + final Boolean pf10gbFd = ((input) & (1 << 6)) != 0; + final Boolean pf40gbFd = ((input) & (1 << 7)) != 0; + final Boolean pf100gbFd = ((input) & (1 << 8)) != 0; + final Boolean pf1tbFd = ((input) & (1 << 9)) != 0; + final Boolean pfOther = ((input) & (1 << 10)) != 0; + final Boolean pfCopper = ((input) & (1 << 11)) != 0; + final Boolean pfFiber = ((input) & (1 << 12)) != 0; + final Boolean pfAutoneg = ((input) & (1 << 13)) != 0; + final Boolean pfPause = ((input) & (1 << 14)) != 0; + final Boolean pfPauseAsym = ((input) & (1 << 15)) != 0; + return new PortFeatures(pf100gbFd, pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, pf1gbFd, pf1gbHd, + pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java new file mode 100644 index 00000000..1627f2b5 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class RoleRequestInputMessageFactory implements OFDeserializer { + + private static final byte PADDING = 4; + + @Override + public RoleRequestInput deserialize(ByteBuf rawMessage) { + RoleRequestInputBuilder builder = new RoleRequestInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid((rawMessage.readUnsignedInt())); + builder.setRole(ControllerRole.forValue(rawMessage.readInt())); + rawMessage.skipBytes(PADDING); + byte[] generationId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + rawMessage.readBytes(generationId); + builder.setGenerationId(new BigInteger(1, generationId)); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java new file mode 100644 index 00000000..af18069e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactory.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class SetAsyncInputMessageFactory implements OFDeserializer { + + private static final byte SEPARATE_ROLES = 2; + + @Override + public SetAsyncInput deserialize(ByteBuf rawMessage) { + SetAsyncInputBuilder builder = new SetAsyncInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setPacketInMask(decodePacketInMask(rawMessage)); + builder.setPortStatusMask(decodePortStatusMask(rawMessage)); + builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage)); + return builder.build(); + } + + private static List decodePacketInMask(ByteBuf input) { + List inMasks = new ArrayList<>(); + PacketInMaskBuilder maskBuilder; + for (int i = 0; i < SEPARATE_ROLES; i++) { + maskBuilder = new PacketInMaskBuilder(); + maskBuilder.setMask(decodePacketInReasons(input.readUnsignedInt())); + inMasks.add(maskBuilder.build()); + } + return inMasks; + } + + private static List decodePacketInReasons(long input) { + List reasons = new ArrayList<>(); + if ((input & (1 << 0)) != 0) { + reasons.add(PacketInReason.OFPRNOMATCH); + } + if ((input & (1 << 1)) != 0) { + reasons.add(PacketInReason.OFPRACTION); + } + if ((input & (1 << 2)) != 0) { + reasons.add(PacketInReason.OFPRINVALIDTTL); + } + return reasons; + } + + private static List decodePortStatusMask(ByteBuf input) { + List inMasks = new ArrayList<>(); + PortStatusMaskBuilder maskBuilder; + for (int i = 0; i < SEPARATE_ROLES; i++) { + maskBuilder = new PortStatusMaskBuilder(); + maskBuilder.setMask(decodePortReasons(input.readUnsignedInt())); + inMasks.add(maskBuilder.build()); + } + return inMasks; + } + + private static List decodePortReasons(long input) { + List reasons = new ArrayList<>(); + if ((input & (1 << 0)) != 0) { + reasons.add(PortReason.OFPPRADD); + } + if ((input & (1 << 1)) != 0) { + reasons.add(PortReason.OFPPRDELETE); + } + if ((input & (1 << 2)) != 0) { + reasons.add(PortReason.OFPPRMODIFY); + } + return reasons; + } + + private static List decodeFlowRemovedMask(ByteBuf input) { + List inMasks = new ArrayList<>(); + FlowRemovedMaskBuilder maskBuilder; + for (int i = 0; i < SEPARATE_ROLES; i++) { + maskBuilder = new FlowRemovedMaskBuilder(); + maskBuilder.setMask(decodeFlowRemovedReasons(input.readUnsignedInt())); + inMasks.add(maskBuilder.build()); + } + return inMasks; + } + + private static List decodeFlowRemovedReasons(long input) { + List reasons = new ArrayList<>(); + if ((input & (1 << 0)) != 0) { + reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT); + } + if ((input & (1 << 1)) != 0) { + reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + } + if ((input & (1 << 2)) != 0) { + reasons.add(FlowRemovedReason.OFPRRDELETE); + } + if ((input & (1 << 3)) != 0) { + reasons.add(FlowRemovedReason.OFPRRGROUPDELETE); + } + return reasons; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java new file mode 100644 index 00000000..a0a8e36b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class SetConfigInputMessageFactory implements OFDeserializer { + + @Override + public SetConfigInput deserialize(ByteBuf rawMessage) { + SetConfigInputBuilder builder = new SetConfigInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); + builder.setMissSendLen(rawMessage.readUnsignedShort()); + return builder.build(); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java new file mode 100644 index 00000000..425bc579 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class TableModInputMessageFactory implements OFDeserializer { + + private static final byte PADDING_IN_TABLE_MOD_MESSAGE = 3; + + @Override + public TableModInput deserialize(ByteBuf rawMessage) { + TableModInputBuilder builder = new TableModInputBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(rawMessage.readUnsignedInt()); + builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); + rawMessage.skipBytes(PADDING_IN_TABLE_MOD_MESSAGE); + builder.setConfig(createTableConfig(rawMessage.readUnsignedInt())); + return builder.build(); + } + + private static TableConfig createTableConfig(long input) { + boolean deprecated = (input & 3) != 0; + return new TableConfig(deprecated); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java new file mode 100644 index 00000000..85bcbda6 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/AdditionalMessageFactoryInitializer.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoOutputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoRequestMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ErrorMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowRemovedMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesOutputFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowRemovedMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketInMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortStatusMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketInMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortStatusMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.QueueGetConfigReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class AdditionalMessageFactoryInitializer { + private AdditionalMessageFactoryInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers message serializers implemented within NetIde project into + * provided registry + * + * @param serializerRegistry + * registry to be initialized with message serializers + */ + public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.0 message serializers + short version = EncodeConstants.OF10_VERSION_ID; + CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(ErrorMessage.class, new ErrorMessageFactory()); + registryHelper.registerSerializer(EchoRequestMessage.class, new EchoRequestMessageFactory()); + registryHelper.registerSerializer(EchoOutput.class, new EchoOutputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); + registryHelper.registerSerializer(GetConfigOutput.class, new GetConfigReplyMessageFactory()); + registryHelper.registerSerializer(PacketInMessage.class, new OF10PacketInMessageFactory()); + registryHelper.registerSerializer(FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); + registryHelper.registerSerializer(PortStatusMessage.class, new OF10PortStatusMessageFactory()); + registryHelper.registerSerializer(MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); + registryHelper.registerSerializer(BarrierOutput.class, new OF10BarrierReplyMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + + // register OF v1.3 message serializers + version = EncodeConstants.OF13_VERSION_ID; + registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(EchoOutput.class, new EchoOutputMessageFactory()); + registryHelper.registerSerializer(PacketInMessage.class, new PacketInMessageFactory()); + registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesOutput.class, new GetFeaturesOutputFactory()); + registryHelper.registerSerializer(EchoRequestMessage.class, new EchoRequestMessageFactory()); + registryHelper.registerSerializer(MultipartReplyMessage.class, new MultipartReplyMessageFactory()); + registryHelper.registerSerializer(HelloMessage.class, new HelloMessageFactory()); + registryHelper.registerSerializer(ErrorMessage.class, new ErrorMessageFactory()); + registryHelper.registerSerializer(ExperimenterMessage.class, new ExperimenterMessageFactory()); + registryHelper.registerSerializer(GetConfigOutput.class, new GetConfigReplyMessageFactory()); + registryHelper.registerSerializer(FlowRemovedMessage.class, new FlowRemovedMessageFactory()); + registryHelper.registerSerializer(PortStatusMessage.class, new PortStatusMessageFactory()); + registryHelper.registerSerializer(BarrierOutput.class, new BarrierReplyMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); + registryHelper.registerSerializer(RoleRequestOutput.class, new RoleReplyMessageFactory()); + registryHelper.registerSerializer(GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 95303409..a150de89 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -69,7 +69,9 @@ private MessageFactoryInitializer() { /** * Registers message serializers into provided registry - * @param serializerRegistry registry to be initialized with message serializers + * + * @param serializerRegistry + * registry to be initialized with message serializers */ public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { // register OF v1.0 message serializers @@ -88,6 +90,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory()); registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory()); registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); + // register OF v1.3 message serializers version = EncodeConstants.OF13_VERSION_ID; registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); @@ -108,7 +111,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory()); registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory()); registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); - registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory()); + registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 5756352c..96307fa2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -10,7 +10,6 @@ import java.util.HashMap; import java.util.Map; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; @@ -27,8 +26,11 @@ * Stores and handles serializers
          * K - {@link MessageTypeKey} type
          * S - returned serializer type + * * @author michal.polkorab * @author timotej.kubas + * @author giuseppex.petralia@intel.com + * */ public class SerializerRegistryImpl implements SerializerRegistry { @@ -37,13 +39,15 @@ public class SerializerRegistryImpl implements SerializerRegistry { private static final short OF13 = EncodeConstants.OF13_VERSION_ID; private Map, OFGeneralSerializer> registry; - @Override public void init() { registry = new HashMap<>(); // Openflow message type serializers MessageFactoryInitializer.registerMessageSerializers(this); + // Register Additional serializers + AdditionalMessageFactoryInitializer.registerMessageSerializers(this); + // match structure serializers registerSerializer(new MessageTypeKey<>(OF10, MatchV10.class), new OF10MatchSerializer()); registerSerializer(new MessageTypeKey<>(OF13, Match.class), new OF13MatchSerializer()); @@ -62,8 +66,7 @@ public void init() { */ @Override @SuppressWarnings("unchecked") - public S getSerializer( - MessageTypeKey msgTypeKey) { + public S getSerializer(MessageTypeKey msgTypeKey) { OFGeneralSerializer serializer = registry.get(msgTypeKey); if (serializer == null) { throw new IllegalStateException("Serializer for key: " + msgTypeKey @@ -74,15 +77,14 @@ public S getSerializer( } @Override - public void registerSerializer( - MessageTypeKey msgTypeKey, OFGeneralSerializer serializer) { + public void registerSerializer(MessageTypeKey msgTypeKey, OFGeneralSerializer serializer) { if ((msgTypeKey == null) || (serializer == null)) { throw new IllegalArgumentException("MessageTypeKey or Serializer is null"); } OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer); if (serInRegistry != null) { - LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", - msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName()); + LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey, + serInRegistry.getClass().getName(), serializer.getClass().getName()); } if (serializer instanceof SerializerRegistryInjector) { ((SerializerRegistryInjector) serializer).injectSerializerRegistry(this); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java new file mode 100644 index 00000000..3212f784 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class BarrierReplyMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 21; + + @Override + public void serialize(BarrierOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java new file mode 100644 index 00000000..3a244db3 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class EchoOutputMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 3; + + @Override + public void serialize(EchoOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + byte[] data = message.getData(); + + if (data != null) { + outBuffer.writeBytes(data); + } + + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java new file mode 100644 index 00000000..9f5076cd --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactory.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class EchoRequestMessageFactory implements OFSerializer { + private static final byte MESSAGE_TYPE = 2; + + @Override + public void serialize(EchoRequestMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + byte[] data = message.getData(); + + if (data != null) { + outBuffer.writeBytes(data); + } + + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java new file mode 100644 index 00000000..2eeaf76e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactory.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class ErrorMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 1; + + @Override + public void serialize(ErrorMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(message.getType()); + outBuffer.writeShort(message.getCode()); + byte[] data = message.getData(); + + if (data != null) { + outBuffer.writeBytes(data); + } + + ByteBufUtils.updateOFHeaderLength(outBuffer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java new file mode 100644 index 00000000..dc6e66c8 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterMessageFactory.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class ExperimenterMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 4; + + @Override + public void serialize(ExperimenterMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeInt(message.getExperimenter().getValue().intValue()); + outBuffer.writeInt(message.getExpType().intValue()); + // TODO: Serializer for data field is vendor specific. + byte[] data = null; + + if (data != null) { + outBuffer.writeBytes(data); + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java new file mode 100644 index 00000000..7e7c4848 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class FlowRemovedMessageFactory implements OFSerializer, SerializerRegistryInjector { + + private static final byte MESSAGE_TYPE = 11; + private SerializerRegistry registry; + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } + + @Override + public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeLong(message.getCookie().longValue()); + outBuffer.writeShort(message.getPriority()); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeByte(message.getTableId().getValue().byteValue()); + outBuffer.writeInt(message.getDurationSec().intValue()); + outBuffer.writeInt(message.getDurationNsec().intValue()); + outBuffer.writeShort(message.getIdleTimeout()); + outBuffer.writeShort(message.getHardTimeout()); + outBuffer.writeLong(message.getPacketCount().longValue()); + outBuffer.writeLong(message.getByteCount().longValue()); + OFSerializer matchSerializer = registry + .> getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)); + matchSerializer.serialize(message.getMatch(), outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java new file mode 100644 index 00000000..4ba876c4 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactory.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask; + +/** + * @author giuseppex.petralia@intel.com + * + */ + +public class GetAsyncReplyMessageFactory implements OFSerializer { + private static final byte MESSAGE_TYPE = 27; + + @Override + public void serialize(GetAsyncOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + serializePacketInMask(message.getPacketInMask(), outBuffer); + serializePortStatusMask(message.getPortStatusMask(), outBuffer); + serializeFlowRemovedMask(message.getFlowRemovedMask(), outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private static void serializePacketInMask(List packetInMask, ByteBuf outBuffer) { + if (packetInMask != null) { + for (PacketInMask currentPacketMask : packetInMask) { + List mask = currentPacketMask.getMask(); + if (mask != null) { + Map packetInReasonMap = new HashMap<>(); + for (PacketInReason packetInReason : mask) { + if (PacketInReason.OFPRNOMATCH.equals(packetInReason)) { + packetInReasonMap.put(PacketInReason.OFPRNOMATCH.getIntValue(), true); + } else if (PacketInReason.OFPRACTION.equals(packetInReason)) { + packetInReasonMap.put(PacketInReason.OFPRACTION.getIntValue(), true); + } else if (PacketInReason.OFPRINVALIDTTL.equals(packetInReason)) { + packetInReasonMap.put(PacketInReason.OFPRINVALIDTTL.getIntValue(), true); + } + } + outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(packetInReasonMap)); + } + } + } + } + + private static void serializePortStatusMask(List portStatusMask, ByteBuf outBuffer) { + if (portStatusMask != null) { + for (PortStatusMask currentPortStatusMask : portStatusMask) { + List mask = currentPortStatusMask.getMask(); + if (mask != null) { + Map portStatusReasonMap = new HashMap<>(); + for (PortReason packetInReason : mask) { + if (PortReason.OFPPRADD.equals(packetInReason)) { + portStatusReasonMap.put(PortReason.OFPPRADD.getIntValue(), true); + } else if (PortReason.OFPPRDELETE.equals(packetInReason)) { + portStatusReasonMap.put(PortReason.OFPPRDELETE.getIntValue(), true); + } else if (PortReason.OFPPRMODIFY.equals(packetInReason)) { + portStatusReasonMap.put(PortReason.OFPPRMODIFY.getIntValue(), true); + } + } + outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(portStatusReasonMap)); + } + } + } + } + + private static void serializeFlowRemovedMask(List flowRemovedMask, ByteBuf outBuffer) { + if (flowRemovedMask != null) { + for (FlowRemovedMask currentFlowRemovedMask : flowRemovedMask) { + List mask = currentFlowRemovedMask.getMask(); + if (mask != null) { + Map flowRemovedReasonMap = new HashMap<>(); + for (FlowRemovedReason packetInReason : mask) { + if (FlowRemovedReason.OFPRRIDLETIMEOUT.equals(packetInReason)) { + flowRemovedReasonMap.put(FlowRemovedReason.OFPRRIDLETIMEOUT.getIntValue(), true); + } else if (FlowRemovedReason.OFPRRHARDTIMEOUT.equals(packetInReason)) { + flowRemovedReasonMap.put(FlowRemovedReason.OFPRRHARDTIMEOUT.getIntValue(), true); + } else if (FlowRemovedReason.OFPRRDELETE.equals(packetInReason)) { + flowRemovedReasonMap.put(FlowRemovedReason.OFPRRDELETE.getIntValue(), true); + } else if (FlowRemovedReason.OFPRRGROUPDELETE.equals(packetInReason)) { + flowRemovedReasonMap.put(FlowRemovedReason.OFPRRGROUPDELETE.getIntValue(), true); + } + } + outBuffer.writeInt(ByteBufUtils.fillBitMaskFromMap(flowRemovedReasonMap)); + } + } + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java new file mode 100644 index 00000000..d711b864 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetConfigReplyMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 8; + + @Override + public void serialize(GetConfigOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(message.getFlags().getIntValue()); + outBuffer.writeShort(message.getMissSendLen()); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java new file mode 100644 index 00000000..2a2fdc2a --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactory.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetFeaturesOutputFactory implements OFSerializer, SerializerRegistryInjector { + + @SuppressWarnings("unused") + private SerializerRegistry registry; + private static final byte MESSAGE_TYPE = 6; + private static final byte PADDING = 2; + + @Override + public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeLong(message.getDatapathId().longValue()); + outBuffer.writeInt(message.getBuffers().intValue()); + outBuffer.writeByte(message.getTables().intValue()); + outBuffer.writeByte(message.getAuxiliaryId().intValue()); + outBuffer.writeZero(PADDING); + writeCapabilities(message.getCapabilities(), outBuffer); + outBuffer.writeInt(message.getReserved().intValue()); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } + + private static void writeCapabilities(Capabilities capabilities, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, capabilities.isOFPCFLOWSTATS()); + map.put(1, capabilities.isOFPCTABLESTATS()); + map.put(2, capabilities.isOFPCPORTSTATS()); + map.put(3, capabilities.isOFPCGROUPSTATS()); + map.put(5, capabilities.isOFPCIPREASM()); + map.put(6, capabilities.isOFPCQUEUESTATS()); + map.put(8, capabilities.isOFPCPORTBLOCKED()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java new file mode 100644 index 00000000..b3ccbbe7 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class HelloMessageFactory implements OFSerializer { + private static final byte MESSAGE_TYPE = 0; + + @Override + public void serialize(HelloMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java new file mode 100644 index 00000000..e0393c7b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java @@ -0,0 +1,799 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDrop; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartReplyMessageFactory implements OFSerializer, SerializerRegistryInjector { + + private static final byte MESSAGE_TYPE = 19; + private SerializerRegistry registry; + private static final byte PADDING = 4; + private static final byte PORT_DESC_PADDING_1 = 4; + private static final byte PORT_DESC_PADDING_2 = 2; + private static final int FLOW_STATS_LENGTH_INDEX = 0; + private static final byte FLOW_STATS_PADDING_1 = 1; + private static final byte FLOW_STATS_PADDING_2 = 6; + private static final byte AGGREGATE_PADDING = 4; + private static final byte TABLE_PADDING = 3; + private static final byte PORT_STATS_PADDING = 4; + private static final byte GROUP_STATS_PADDING_1 = 2; + private static final byte GROUP_STATS_PADDING_2 = 4; + private static final int GROUP_STATS_LENGTH_INDEX = 0; + private static final int GROUP_DESC_LENGTH_INDEX = 0; + private static final int BUCKET_LENGTH_INDEX = 0; + private static final byte GROUP_DESC_PADDING = 1; + private static final byte BUCKET_PADDING = 4; + private static final int METER_LENGTH_INDEX = 4; + private static final byte METER_PADDING = 6; + private static final int METER_CONFIG_LENGTH_INDEX = 0; + private static final short LENGTH_OF_METER_BANDS = 16; + private static final byte METER_FEATURES_PADDING = 2; + private static final int TABLE_FEATURES_LENGTH_INDEX = 0; + private static final byte TABLE_FEATURES_PADDING = 5; + private static final byte INSTRUCTIONS_CODE = 0; + private static final byte INSTRUCTIONS_MISS_CODE = 1; + private static final byte NEXT_TABLE_CODE = 2; + private static final byte NEXT_TABLE_MISS_CODE = 3; + private static final byte WRITE_ACTIONS_CODE = 4; + private static final byte WRITE_ACTIONS_MISS_CODE = 5; + private static final byte APPLY_ACTIONS_CODE = 6; + private static final byte APPLY_ACTIONS_MISS_CODE = 7; + private static final byte MATCH_CODE = 8; + private static final byte WILDCARDS_CODE = 10; + private static final byte WRITE_SETFIELD_CODE = 12; + private static final byte WRITE_SETFIELD_MISS_CODE = 13; + private static final byte APPLY_SETFIELD_CODE = 14; + private static final byte APPLY_SETFIELD_MISS_CODE = 15; + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } + + @Override + public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(message.getType().getIntValue()); + writeFlags(message.getFlags(), outBuffer); + outBuffer.writeZero(PADDING); + switch (message.getType()) { + case OFPMPDESC: + serializeDescBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPFLOW: + serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); + break; + case OFPMPAGGREGATE: + serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPTABLE: + serializeTableBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPPORTSTATS: + serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPQUEUE: + serializeQueueBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPGROUP: + serializeGroupBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPGROUPDESC: + serializeGroupDescBody(message.getMultipartReplyBody(), outBuffer, message); + break; + case OFPMPGROUPFEATURES: + serializeGroupFeaturesBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPMETER: + serializeMeterBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPMETERCONFIG: + serializeMeterConfigBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPMETERFEATURES: + serializeMeterFeaturesBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPTABLEFEATURES: + serializeTableFeaturesBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPPORTDESC: + serializePortDescBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPEXPERIMENTER: + serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); + break; + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void serializeExperimenterBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyExperimenterCase experimenterCase = (MultipartReplyExperimenterCase) body; + MultipartReplyExperimenter experimenterBody = experimenterCase.getMultipartReplyExperimenter(); + // TODO: experimenterBody does not have get methods + } + + private void writeFlags(MultipartRequestFlags flags, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, flags.isOFPMPFREQMORE()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeShort(bitmap); + } + + private void serializeTableFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body; + MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures(); + for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) { + ByteBuf tableFeatureBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + tableFeatureBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + tableFeatureBuff.writeByte(tableFeature.getTableId()); + tableFeatureBuff.writeZero(TABLE_FEATURES_PADDING); + write32String(tableFeature.getName(), tableFeatureBuff); + tableFeatureBuff.writeBytes(tableFeature.getMetadataMatch()); + tableFeatureBuff.writeZero(64 - tableFeature.getMetadataMatch().length); + tableFeatureBuff.writeBytes(tableFeature.getMetadataWrite()); + tableFeatureBuff.writeZero(64 - tableFeature.getMetadataWrite().length); + writeTableConfig(tableFeature.getConfig(), tableFeatureBuff); + tableFeatureBuff.writeInt(tableFeature.getMaxEntries().intValue()); + for (TableFeatureProperties tableFeatureProp : tableFeature.getTableFeatureProperties()) { + switch (tableFeatureProp.getType()) { + case OFPTFPTINSTRUCTIONS: + writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_CODE); + break; + case OFPTFPTINSTRUCTIONSMISS: + writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_MISS_CODE); + break; + case OFPTFPTNEXTTABLES: + writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_CODE); + break; + case OFPTFPTNEXTTABLESMISS: + writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_MISS_CODE); + break; + case OFPTFPTWRITEACTIONS: + writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_CODE); + break; + case OFPTFPTWRITEACTIONSMISS: + writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_MISS_CODE); + break; + case OFPTFPTAPPLYACTIONS: + writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_CODE); + break; + case OFPTFPTAPPLYACTIONSMISS: + writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_MISS_CODE); + break; + case OFPTFPTMATCH: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, MATCH_CODE); + break; + case OFPTFPTWILDCARDS: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WILDCARDS_CODE); + break; + case OFPTFPTWRITESETFIELD: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_CODE); + break; + case OFPTFPTWRITESETFIELDMISS: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_MISS_CODE); + break; + case OFPTFPTAPPLYSETFIELD: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_CODE); + break; + case OFPTFPTAPPLYSETFIELDMISS: + writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_MISS_CODE); + break; + case OFPTFPTEXPERIMENTER: + writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp); + break; + case OFPTFPTEXPERIMENTERMISS: + writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp); + break; + } + } + tableFeatureBuff.setShort(TABLE_FEATURES_LENGTH_INDEX, tableFeatureBuff.readableBytes()); + outBuffer.writeBytes(tableFeatureBuff); + } + } + + private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) { + long expId = property.getAugmentation(ExperimenterIdTableFeatureProperty.class).getExperimenter().getValue(); + OFSerializer serializer = registry.getSerializer(ExperimenterSerializerKeyFactory + .createMultipartRequestTFSerializerKey(EncodeConstants.OF13_VERSION_ID, expId)); + serializer.serialize(property, output); + } + + private void writeOxmRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, + final byte code) { + int startIndex = output.writerIndex(); + output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); + List entries = property.getAugmentation(OxmRelatedTableFeatureProperty.class).getMatchEntry(); + if (entries != null) { + TypeKeyMaker keyMaker = TypeKeyMakerFactory + .createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + ListSerializer.serializeHeaderList(entries, keyMaker, registry, output); + } + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); + } + + private void writeActionsRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, + final byte code) { + int startIndex = output.writerIndex(); + output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); + List actions = property.getAugmentation(ActionRelatedTableFeatureProperty.class).getAction(); + if (actions != null) { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + ListSerializer.serializeHeaderList(actions, keyMaker, registry, output); + } + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); + } + + private static void writeNextTableRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, + final byte code) { + int startIndex = output.writerIndex(); + output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); + List nextTableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + if (nextTableIds != null) { + for (NextTableIds next : nextTableIds) { + output.writeByte(next.getTableId()); + } + } + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); + } + + private void writeInstructionRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property, + final byte code) { + int startIndex = output.writerIndex(); + output.writeShort(code); + int lengthIndex = output.writerIndex(); + output.writeShort(EncodeConstants.EMPTY_LENGTH); + List instructions = property.getAugmentation(InstructionRelatedTableFeatureProperty.class) + .getInstruction(); + if (instructions != null) { + TypeKeyMaker keyMaker = TypeKeyMakerFactory + .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + ListSerializer.serializeHeaderList(instructions, keyMaker, registry, output); + } + int length = output.writerIndex() - startIndex; + output.setShort(lengthIndex, length); + output.writeZero(paddingNeeded(length)); + } + + private static int paddingNeeded(final int length) { + int paddingRemainder = length % EncodeConstants.PADDING; + int result = 0; + if (paddingRemainder != 0) { + result = EncodeConstants.PADDING - paddingRemainder; + } + return result; + } + + private void writeTableConfig(TableConfig tableConfig, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, tableConfig.isOFPTCDEPRECATEDMASK()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void serializeMeterFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyMeterFeaturesCase meterFeaturesCase = (MultipartReplyMeterFeaturesCase) body; + MultipartReplyMeterFeatures meterFeatures = meterFeaturesCase.getMultipartReplyMeterFeatures(); + outBuffer.writeInt(meterFeatures.getMaxMeter().intValue()); + writeBandTypes(meterFeatures.getBandTypes(), outBuffer); + writeMeterFlags(meterFeatures.getCapabilities(), outBuffer); + outBuffer.writeByte(meterFeatures.getMaxBands()); + outBuffer.writeByte(meterFeatures.getMaxColor()); + outBuffer.writeZero(METER_FEATURES_PADDING); + } + + private void writeBandTypes(MeterBandTypeBitmap bandTypes, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, bandTypes.isOFPMBTDROP()); + map.put(1, bandTypes.isOFPMBTDSCPREMARK()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void serializeMeterConfigBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyMeterConfigCase meterConfigCase = (MultipartReplyMeterConfigCase) body; + MultipartReplyMeterConfig meter = meterConfigCase.getMultipartReplyMeterConfig(); + for (MeterConfig meterConfig : meter.getMeterConfig()) { + ByteBuf meterConfigBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + meterConfigBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + writeMeterFlags(meterConfig.getFlags(), meterConfigBuff); + meterConfigBuff.writeInt(meterConfig.getMeterId().getValue().intValue()); + for (Bands currentBand : meterConfig.getBands()) { + MeterBand meterBand = currentBand.getMeterBand(); + if (meterBand instanceof MeterBandDropCase) { + MeterBandDropCase dropBandCase = (MeterBandDropCase) meterBand; + MeterBandDrop dropBand = dropBandCase.getMeterBandDrop(); + writeBandCommonFields(dropBand, meterConfigBuff); + } else if (meterBand instanceof MeterBandDscpRemarkCase) { + MeterBandDscpRemarkCase dscpRemarkBandCase = (MeterBandDscpRemarkCase) meterBand; + MeterBandDscpRemark dscpRemarkBand = dscpRemarkBandCase.getMeterBandDscpRemark(); + writeBandCommonFields(dscpRemarkBand, meterConfigBuff); + } else if (meterBand instanceof MeterBandExperimenterCase) { + MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand; + MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter(); + writeBandCommonFields(experimenterBand, meterConfigBuff); + } + } + meterConfigBuff.setShort(METER_CONFIG_LENGTH_INDEX, meterConfigBuff.readableBytes()); + outBuffer.writeBytes(meterConfigBuff); + } + } + + private static void writeBandCommonFields(final MeterBandCommons meterBand, final ByteBuf outBuffer) { + outBuffer.writeShort(meterBand.getType().getIntValue()); + outBuffer.writeShort(LENGTH_OF_METER_BANDS); + outBuffer.writeInt(meterBand.getRate().intValue()); + outBuffer.writeInt(meterBand.getBurstSize().intValue()); + } + + private void writeMeterFlags(MeterFlags flags, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, flags.isOFPMFKBPS()); + map.put(1, flags.isOFPMFPKTPS()); + map.put(2, flags.isOFPMFBURST()); + map.put(3, flags.isOFPMFSTATS()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeShort(bitmap); + } + + private void serializeMeterBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyMeterCase meterCase = (MultipartReplyMeterCase) body; + MultipartReplyMeter meter = meterCase.getMultipartReplyMeter(); + for (MeterStats meterStats : meter.getMeterStats()) { + ByteBuf meterStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + meterStatsBuff.writeInt(meterStats.getMeterId().getValue().intValue()); + meterStatsBuff.writeInt(EncodeConstants.EMPTY_LENGTH); + meterStatsBuff.writeZero(METER_PADDING); + meterStatsBuff.writeInt(meterStats.getFlowCount().intValue()); + meterStatsBuff.writeLong(meterStats.getPacketInCount().longValue()); + meterStatsBuff.writeLong(meterStats.getByteInCount().longValue()); + meterStatsBuff.writeInt(meterStats.getDurationSec().intValue()); + meterStatsBuff.writeInt(meterStats.getDurationNsec().intValue()); + for (MeterBandStats meterBandStats : meterStats.getMeterBandStats()) { + meterStatsBuff.writeLong(meterBandStats.getPacketBandCount().longValue()); + meterStatsBuff.writeLong(meterBandStats.getByteBandCount().longValue()); + } + meterStatsBuff.setInt(METER_LENGTH_INDEX, meterStatsBuff.readableBytes()); + outBuffer.writeBytes(meterStatsBuff); + } + } + + private void serializeGroupFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyGroupFeaturesCase groupFeaturesCase = (MultipartReplyGroupFeaturesCase) body; + MultipartReplyGroupFeatures groupFeatures = groupFeaturesCase.getMultipartReplyGroupFeatures(); + writeGroupTypes(groupFeatures.getTypes(), outBuffer); + writeGroupCapabilities(groupFeatures.getCapabilities(), outBuffer); + for (Long maxGroups : groupFeatures.getMaxGroups()) { + outBuffer.writeInt(maxGroups.intValue()); + } + for (ActionType action : groupFeatures.getActionsBitmap()) { + writeActionType(action, outBuffer); + } + } + + private void writeActionType(ActionType action, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, action.isOFPATOUTPUT()); + map.put(1, action.isOFPATCOPYTTLOUT()); + map.put(2, action.isOFPATCOPYTTLIN()); + map.put(3, action.isOFPATSETMPLSTTL()); + map.put(4, action.isOFPATDECMPLSTTL()); + map.put(5, action.isOFPATPUSHVLAN()); + map.put(6, action.isOFPATPOPVLAN()); + map.put(7, action.isOFPATPUSHMPLS()); + map.put(8, action.isOFPATPOPMPLS()); + map.put(9, action.isOFPATSETQUEUE()); + map.put(10, action.isOFPATGROUP()); + map.put(11, action.isOFPATSETNWTTL()); + map.put(12, action.isOFPATDECNWTTL()); + map.put(13, action.isOFPATSETFIELD()); + map.put(14, action.isOFPATPUSHPBB()); + map.put(15, action.isOFPATPOPPBB()); + map.put(16, action.isOFPATEXPERIMENTER()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writeGroupCapabilities(GroupCapabilities capabilities, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, capabilities.isOFPGFCSELECTWEIGHT()); + map.put(1, capabilities.isOFPGFCSELECTLIVENESS()); + map.put(2, capabilities.isOFPGFCCHAINING()); + map.put(3, capabilities.isOFPGFCCHAININGCHECKS()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writeGroupTypes(GroupTypes types, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, types.isOFPGTALL()); + map.put(1, types.isOFPGTSELECT()); + map.put(2, types.isOFPGTINDIRECT()); + map.put(3, types.isOFPGTFF()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void serializeGroupDescBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { + MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body; + MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc(); + for (GroupDesc groupDesc : group.getGroupDesc()) { + ByteBuf groupDescBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + groupDescBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + groupDescBuff.writeByte(groupDesc.getType().getIntValue()); + groupDescBuff.writeZero(GROUP_DESC_PADDING); + groupDescBuff.writeInt(groupDesc.getGroupId().getValue().intValue()); + for (BucketsList bucket : groupDesc.getBucketsList()) { + ByteBuf bucketBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + bucketBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + bucketBuff.writeShort(bucket.getWeight()); + bucketBuff.writeInt(bucket.getWatchPort().getValue().intValue()); + bucketBuff.writeInt(bucket.getWatchGroup().intValue()); + bucketBuff.writeZero(BUCKET_PADDING); + ListSerializer.serializeList(bucket.getAction(), + TypeKeyMakerFactory.createActionKeyMaker(message.getVersion()), registry, bucketBuff); + bucketBuff.setShort(BUCKET_LENGTH_INDEX, bucketBuff.readableBytes()); + groupDescBuff.writeBytes(bucketBuff); + } + groupDescBuff.setShort(GROUP_DESC_LENGTH_INDEX, groupDescBuff.readableBytes()); + outBuffer.writeBytes(groupDescBuff); + } + } + + private void serializeGroupBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyGroupCase groupCase = (MultipartReplyGroupCase) body; + MultipartReplyGroup group = groupCase.getMultipartReplyGroup(); + for (GroupStats groupStats : group.getGroupStats()) { + ByteBuf groupStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + groupStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + groupStatsBuff.writeZero(GROUP_STATS_PADDING_1); + groupStatsBuff.writeInt(groupStats.getGroupId().getValue().intValue()); + groupStatsBuff.writeInt(groupStats.getRefCount().intValue()); + groupStatsBuff.writeZero(GROUP_STATS_PADDING_2); + groupStatsBuff.writeLong(groupStats.getPacketCount().longValue()); + groupStatsBuff.writeLong(groupStats.getByteCount().longValue()); + groupStatsBuff.writeInt(groupStats.getDurationSec().intValue()); + groupStatsBuff.writeInt(groupStats.getDurationNsec().intValue()); + for (BucketStats bucketStats : groupStats.getBucketStats()) { + groupStatsBuff.writeLong(bucketStats.getPacketCount().longValue()); + groupStatsBuff.writeLong(bucketStats.getByteCount().longValue()); + } + groupStatsBuff.setShort(GROUP_STATS_LENGTH_INDEX, groupStatsBuff.readableBytes()); + outBuffer.writeBytes(groupStatsBuff); + } + } + + private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body; + MultipartReplyQueue queue = queueCase.getMultipartReplyQueue(); + for (QueueStats queueStats : queue.getQueueStats()) { + outBuffer.writeInt(queueStats.getPortNo().intValue()); + outBuffer.writeInt(queueStats.getQueueId().intValue()); + outBuffer.writeLong(queueStats.getTxBytes().longValue()); + outBuffer.writeLong(queueStats.getTxPackets().longValue()); + outBuffer.writeLong(queueStats.getTxErrors().longValue()); + outBuffer.writeInt(queueStats.getDurationSec().intValue()); + outBuffer.writeInt(queueStats.getDurationNsec().intValue()); + } + } + + private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body; + MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats(); + for (PortStats portStat : portStats.getPortStats()) { + outBuffer.writeInt(portStat.getPortNo().intValue()); + outBuffer.writeZero(PORT_STATS_PADDING); + outBuffer.writeLong(portStat.getRxPackets().longValue()); + outBuffer.writeLong(portStat.getTxPackets().longValue()); + outBuffer.writeLong(portStat.getRxBytes().longValue()); + outBuffer.writeLong(portStat.getTxBytes().longValue()); + outBuffer.writeLong(portStat.getRxDropped().longValue()); + outBuffer.writeLong(portStat.getTxDropped().longValue()); + outBuffer.writeLong(portStat.getRxErrors().longValue()); + outBuffer.writeLong(portStat.getTxErrors().longValue()); + outBuffer.writeLong(portStat.getRxFrameErr().longValue()); + outBuffer.writeLong(portStat.getRxOverErr().longValue()); + outBuffer.writeLong(portStat.getRxCrcErr().longValue()); + outBuffer.writeLong(portStat.getCollisions().longValue()); + outBuffer.writeInt(portStat.getDurationSec().intValue()); + outBuffer.writeInt(portStat.getDurationNsec().intValue()); + } + } + + private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body; + MultipartReplyTable table = tableCase.getMultipartReplyTable(); + for (TableStats tableStats : table.getTableStats()) { + outBuffer.writeByte(tableStats.getTableId()); + outBuffer.writeZero(TABLE_PADDING); + outBuffer.writeInt(tableStats.getActiveCount().intValue()); + outBuffer.writeLong(tableStats.getLookupCount().longValue()); + outBuffer.writeLong(tableStats.getMatchedCount().longValue()); + } + } + + private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body; + MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate(); + outBuffer.writeLong(aggregate.getPacketCount().longValue()); + outBuffer.writeLong(aggregate.getByteCount().longValue()); + outBuffer.writeInt(aggregate.getFlowCount().intValue()); + outBuffer.writeZero(AGGREGATE_PADDING); + } + + private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { + MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; + MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); + for (FlowStats flowStats : flow.getFlowStats()) { + ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue()); + flowStatsBuff.writeZero(FLOW_STATS_PADDING_1); + flowStatsBuff.writeInt(flowStats.getDurationSec().intValue()); + flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue()); + flowStatsBuff.writeShort(flowStats.getPriority()); + flowStatsBuff.writeShort(flowStats.getIdleTimeout()); + flowStatsBuff.writeShort(flowStats.getHardTimeout()); + flowStatsBuff.writeZero(FLOW_STATS_PADDING_2); + flowStatsBuff.writeLong(flowStats.getCookie().longValue()); + flowStatsBuff.writeLong(flowStats.getPacketCount().longValue()); + flowStatsBuff.writeLong(flowStats.getByteCount().longValue()); + OFSerializer matchSerializer = registry.> getSerializer( + new MessageTypeKey<>(message.getVersion(), Match.class)); + matchSerializer.serialize(flowStats.getMatch(), flowStatsBuff); + ListSerializer.serializeList(flowStats.getInstruction(), + TypeKeyMakerFactory.createInstructionKeyMaker(message.getVersion()), registry, flowStatsBuff); + + flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes()); + outBuffer.writeBytes(flowStatsBuff); + } + } + + private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyDescCase descCase = (MultipartReplyDescCase) body; + MultipartReplyDesc desc = descCase.getMultipartReplyDesc(); + write256String(desc.getMfrDesc(), outBuffer); + write256String(desc.getHwDesc(), outBuffer); + write256String(desc.getSwDesc(), outBuffer); + write32String(desc.getSerialNum(), outBuffer); + write256String(desc.getDpDesc(), outBuffer); + } + + private void write256String(String toWrite, ByteBuf outBuffer) { + byte[] nameBytes = toWrite.getBytes(); + if (nameBytes.length < 256) { + byte[] nameBytesPadding = new byte[256]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 256; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + } + + private void write32String(String toWrite, ByteBuf outBuffer) { + byte[] nameBytes = toWrite.getBytes(); + if (nameBytes.length < 32) { + byte[] nameBytesPadding = new byte[32]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 32; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + } + + private void serializePortDescBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body; + MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc(); + for (Ports port : portDesc.getPorts()) { + outBuffer.writeInt(port.getPortNo().intValue()); // Assuming PortNo + // = PortId + outBuffer.writeZero(PORT_DESC_PADDING_1); + writeMacAddress(port.getHwAddr().getValue(), outBuffer); + outBuffer.writeZero(PORT_DESC_PADDING_2); + writeName(port.getName(), outBuffer); + writePortConfig(port.getConfig(), outBuffer); + writePortState(port.getState(), outBuffer); + writePortFeatures(port.getCurrentFeatures(), outBuffer); + writePortFeatures(port.getAdvertisedFeatures(), outBuffer); + writePortFeatures(port.getSupportedFeatures(), outBuffer); + writePortFeatures(port.getPeerFeatures(), outBuffer); + outBuffer.writeInt(port.getCurrSpeed().intValue()); + outBuffer.writeInt(port.getMaxSpeed().intValue()); + } + } + + private void writeName(String name, ByteBuf outBuffer) { + byte[] nameBytes = name.getBytes(); + if (nameBytes.length < 16) { + byte[] nameBytesPadding = new byte[16]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 16; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + + } + + private void writeMacAddress(String macAddress, ByteBuf outBuffer) { + String[] macAddressParts = macAddress.split(":"); + byte[] macAddressBytes = new byte[6]; + for (int i = 0; i < 6; i++) { + Integer hex = Integer.parseInt(macAddressParts[i], 16); + macAddressBytes[i] = hex.byteValue(); + } + outBuffer.writeBytes(macAddressBytes); + } + + private void writePortConfig(PortConfig config, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, config.isPortDown()); + map.put(2, config.isNoRecv()); + map.put(5, config.isNoFwd()); + map.put(6, config.isNoPacketIn()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortState(PortState state, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, state.isLinkDown()); + map.put(1, state.isBlocked()); + map.put(2, state.isLive()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, features.is_10mbHd()); + map.put(1, features.is_10mbFd()); + map.put(2, features.is_100mbHd()); + map.put(3, features.is_100mbFd()); + map.put(4, features.is_1gbHd()); + map.put(5, features.is_1gbFd()); + map.put(6, features.is_10gbFd()); + map.put(7, features.is_40gbFd()); + map.put(8, features.is_100gbFd()); + map.put(9, features.is_1tbFd()); + map.put(10, features.isOther()); + map.put(11, features.isCopper()); + map.put(12, features.isFiber()); + map.put(13, features.isAutoneg()); + map.put(14, features.isPause()); + map.put(15, features.isPauseAsym()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java new file mode 100644 index 00000000..2e317a1d --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10BarrierReplyMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 19; + + @Override + public void serialize(BarrierOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java new file mode 100644 index 00000000..8edf30ca --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FeaturesReplyMessageFactory implements OFSerializer { + + private static final byte PADDING = 3; + private static final byte MESSAGE_TYPE = 6; + + @Override + public void serialize(GetFeaturesOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeLong(message.getDatapathId().longValue()); + outBuffer.writeInt(message.getBuffers().intValue()); + outBuffer.writeByte(message.getTables().intValue()); + outBuffer.writeZero(PADDING); + outBuffer.writeInt(createCapabilities(message.getCapabilitiesV10())); + outBuffer.writeInt(createActionsV10(message.getActionsV10())); + for (PhyPort port : message.getPhyPort()) { + outBuffer.writeShort(port.getPortNo().intValue()); + writeMacAddress(port.getHwAddr().getValue(), outBuffer); + writeName(port.getName(), outBuffer); + writePortConfig(port.getConfigV10(), outBuffer); + writePortState(port.getStateV10(), outBuffer); + writePortFeature(port.getCurrentFeaturesV10(), outBuffer); + writePortFeature(port.getAdvertisedFeaturesV10(), outBuffer); + writePortFeature(port.getSupportedFeaturesV10(), outBuffer); + writePortFeature(port.getPeerFeaturesV10(), outBuffer); + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, feature.is_10mbHd()); + map.put(1, feature.is_10mbFd()); + map.put(2, feature.is_100mbHd()); + map.put(3, feature.is_100mbFd()); + map.put(4, feature.is_1gbHd()); + map.put(5, feature.is_1gbFd()); + map.put(6, feature.is_10gbFd()); + map.put(7, feature.isCopper()); + map.put(8, feature.isFiber()); + map.put(9, feature.isAutoneg()); + map.put(10, feature.isPause()); + map.put(11, feature.isPauseAsym()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortState(PortStateV10 state, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, state.isLinkDown()); + map.put(1, state.isBlocked()); + map.put(2, state.isLive()); + map.put(3, state.isStpListen()); + map.put(4, state.isStpLearn()); + map.put(5, state.isStpForward()); + map.put(6, state.isStpBlock()); + map.put(7, state.isStpMask()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, config.isPortDown()); + map.put(1, config.isNoStp()); + map.put(2, config.isNoRecv()); + map.put(3, config.isNoRecvStp()); + map.put(4, config.isNoFlood()); + map.put(5, config.isNoFwd()); + map.put(6, config.isNoPacketIn()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private static int createCapabilities(CapabilitiesV10 capabilities) { + Map map = new HashMap<>(); + map.put(0, capabilities.isOFPCFLOWSTATS()); + map.put(1, capabilities.isOFPCTABLESTATS()); + map.put(2, capabilities.isOFPCPORTSTATS()); + map.put(3, capabilities.isOFPCSTP()); + map.put(4, capabilities.isOFPCRESERVED()); + map.put(5, capabilities.isOFPCIPREASM()); + map.put(6, capabilities.isOFPCQUEUESTATS()); + map.put(7, capabilities.isOFPCARPMATCHIP()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + return bitmap; + } + + private static int createActionsV10(final ActionTypeV10 action) { + return ByteBufUtils.fillBitMask(0, action.isOFPATOUTPUT(), action.isOFPATSETVLANVID(), + action.isOFPATSETVLANPCP(), action.isOFPATSTRIPVLAN(), action.isOFPATSETDLSRC(), + action.isOFPATSETDLDST(), action.isOFPATSETNWSRC(), action.isOFPATSETNWDST(), action.isOFPATSETNWTOS(), + action.isOFPATSETTPSRC(), action.isOFPATSETTPDST(), action.isOFPATENQUEUE(), action.isOFPATVENDOR()); + + } + + private void writeMacAddress(String macAddress, ByteBuf outBuffer) { + String[] macAddressParts = macAddress.split(":"); + byte[] macAddressBytes = new byte[6]; + for (int i = 0; i < 6; i++) { + Integer hex = Integer.parseInt(macAddressParts[i], 16); + macAddressBytes[i] = hex.byteValue(); + } + outBuffer.writeBytes(macAddressBytes); + } + + private void writeName(String name, ByteBuf outBuffer) { + byte[] nameBytes = name.getBytes(); + if (nameBytes.length < 16) { + byte[] nameBytesPadding = new byte[16]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 16; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java new file mode 100644 index 00000000..71b5a28b --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactory.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FlowRemovedMessageFactory implements OFSerializer, SerializerRegistryInjector { + + private static final byte MESSAGE_TYPE = 11; + private SerializerRegistry registry; + private static final byte PADDING = 1; + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + + @Override + public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + + OFSerializer matchSerializer = registry + .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); + + matchSerializer.serialize(message.getMatchV10(), outBuffer); + + outBuffer.writeLong(message.getCookie().longValue()); + outBuffer.writeShort(message.getPriority()); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeZero(PADDING); + outBuffer.writeInt(message.getDurationSec().intValue()); + outBuffer.writeInt(message.getDurationNsec().intValue()); + outBuffer.writeShort(message.getIdleTimeout()); + outBuffer.writeZero(PADDING); + outBuffer.writeZero(PADDING); + outBuffer.writeLong(message.getPacketCount().longValue()); + outBuffer.writeLong(message.getByteCount().longValue()); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java new file mode 100644 index 00000000..d2a1812f --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactory.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PacketInMessageFactory implements OFSerializer { + private static final byte MESSAGE_TYPE = 10; + private static final byte PADDING = 1; + + @Override + public void serialize(PacketInMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeInt(message.getBufferId().intValue()); + outBuffer.writeShort(message.getTotalLen().intValue()); + outBuffer.writeShort(message.getInPort()); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeZero(PADDING); + byte[] data = message.getData(); + + if (data != null) { + outBuffer.writeBytes(data); + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java new file mode 100644 index 00000000..376d0bd9 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PortStatusMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 12; + private static final byte PADDING = 7; + + @Override + public void serialize(PortStatusMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeZero(PADDING); + outBuffer.writeShort(message.getPortNo().intValue()); + writeMacAddress(message.getHwAddr().getValue(), outBuffer); + writeName(message.getName(), outBuffer); + writePortConfig(message.getConfigV10(), outBuffer); + writePortState(message.getStateV10(), outBuffer); + writePortFeature(message.getCurrentFeaturesV10(), outBuffer); + writePortFeature(message.getAdvertisedFeaturesV10(), outBuffer); + writePortFeature(message.getSupportedFeaturesV10(), outBuffer); + writePortFeature(message.getPeerFeaturesV10(), outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, feature.is_10mbHd()); + map.put(1, feature.is_10mbFd()); + map.put(2, feature.is_100mbHd()); + map.put(3, feature.is_100mbFd()); + map.put(4, feature.is_1gbHd()); + map.put(5, feature.is_1gbFd()); + map.put(6, feature.is_10gbFd()); + map.put(7, feature.isCopper()); + map.put(8, feature.isFiber()); + map.put(9, feature.isAutoneg()); + map.put(10, feature.isPause()); + map.put(11, feature.isPauseAsym()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortState(PortStateV10 state, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, state.isLinkDown()); + map.put(1, state.isBlocked()); + map.put(2, state.isLive()); + map.put(3, state.isStpListen()); + map.put(4, state.isStpLearn()); + map.put(5, state.isStpForward()); + map.put(6, state.isStpBlock()); + map.put(7, state.isStpMask()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, config.isPortDown()); + map.put(1, config.isNoStp()); + map.put(2, config.isNoRecv()); + map.put(3, config.isNoRecvStp()); + map.put(4, config.isNoFlood()); + map.put(5, config.isNoFwd()); + map.put(6, config.isNoPacketIn()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writeMacAddress(String macAddress, ByteBuf outBuffer) { + String[] macAddressParts = macAddress.split(":"); + byte[] macAddressBytes = new byte[6]; + for (int i = 0; i < 6; i++) { + Integer hex = Integer.parseInt(macAddressParts[i], 16); + macAddressBytes[i] = hex.byteValue(); + } + outBuffer.writeBytes(macAddressBytes); + } + + private void writeName(String name, ByteBuf outBuffer) { + byte[] nameBytes = name.getBytes(); + if (nameBytes.length < 16) { + byte[] nameBytesPadding = new byte[16]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 16; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java new file mode 100644 index 00000000..85044479 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactory.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10QueueGetConfigReplyMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 21; + private static final byte PADDING = 6; + private static final int QUEUE_LENGTH_INDEX = 4; + private static final byte QUEUE_PADDING = 2; + private static final byte QUEUE_PROPERTY_PADDING = 6; + private static final int QUEUE_PROPERTY_LENGTH_INDEX = 2; + + @Override + public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(message.getPort().getValue().intValue()); + outBuffer.writeZero(PADDING); + for (Queues queue : message.getQueues()) { + ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + queueBuff.writeInt(queue.getQueueId().getValue().intValue()); + queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + queueBuff.writeZero(QUEUE_PADDING); + for (QueueProperty queueProperty : queue.getQueueProperty()) { + ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue()); + queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + queuePropertyBuff.writeZero(4); + if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) { + RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class); + queuePropertyBuff.writeShort(body.getRate().intValue()); + queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING); + } + queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes()); + queueBuff.writeBytes(queuePropertyBuff); + } + queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); + outBuffer.writeBytes(queueBuff); + } + + ByteBufUtils.updateOFHeaderLength(outBuffer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java new file mode 100644 index 00000000..268f7f06 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactory.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsReplyMessageFactory implements OFSerializer, SerializerRegistryInjector { + + private SerializerRegistry registry; + private static final byte MESSAGE_TYPE = 17; + private static final byte FLOW_STATS_PADDING_1 = 1; + private static final byte FLOW_STATS_PADDING_2 = 6; + private static final TypeKeyMaker ACTION_KEY_MAKER = TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID); + private static final int FLOW_STATS_LENGTH_INDEX = 0; + private static final int QUEUE_STATS_LENGTH_INDEX = 0; + private static final byte AGGREGATE_PADDING = 4; + private static final byte TABLE_PADDING = 3; + private static final byte QUEUE_PADDING = 2; + private static final byte PORT_STATS_PADDING = 6; + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + + @Override + public void serialize(MultipartReplyMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeShort(message.getType().getIntValue()); + writeFlags(message.getFlags(), outBuffer); + switch (message.getType()) { + case OFPMPDESC: + serializeDescBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPFLOW: + serializeFlowBody(message.getMultipartReplyBody(), outBuffer, message); + break; + case OFPMPAGGREGATE: + serializeAggregateBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPTABLE: + serializeTableBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPPORTSTATS: + serializePortStatsBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPQUEUE: + serializeQueueBody(message.getMultipartReplyBody(), outBuffer); + break; + case OFPMPEXPERIMENTER: + serializeExperimenterBody(message.getMultipartReplyBody(), outBuffer); + break; + default: + break; + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void serializeExperimenterBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyExperimenterCase experimenterCase = (MultipartReplyExperimenterCase) body; + MultipartReplyExperimenter experimenterBody = experimenterCase.getMultipartReplyExperimenter(); + // TODO: experimenterBody does not have get methods + } + + private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body; + MultipartReplyQueue queue = queueCase.getMultipartReplyQueue(); + for (QueueStats queueStats : queue.getQueueStats()) { + ByteBuf queueStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + queueStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + queueStatsBuff.writeZero(QUEUE_PADDING); + queueStatsBuff.writeInt(queueStats.getQueueId().intValue()); + queueStatsBuff.writeLong(queueStats.getTxBytes().longValue()); + queueStatsBuff.writeLong(queueStats.getTxPackets().longValue()); + queueStatsBuff.writeLong(queueStats.getTxErrors().longValue()); + queueStatsBuff.setShort(QUEUE_STATS_LENGTH_INDEX, queueStatsBuff.readableBytes()); + outBuffer.writeBytes(queueStatsBuff); + } + } + + private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body; + MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats(); + for (PortStats portStat : portStats.getPortStats()) { + outBuffer.writeInt(portStat.getPortNo().intValue()); + outBuffer.writeZero(PORT_STATS_PADDING); + outBuffer.writeLong(portStat.getRxPackets().longValue()); + outBuffer.writeLong(portStat.getTxPackets().longValue()); + outBuffer.writeLong(portStat.getRxBytes().longValue()); + outBuffer.writeLong(portStat.getTxBytes().longValue()); + outBuffer.writeLong(portStat.getRxDropped().longValue()); + outBuffer.writeLong(portStat.getTxDropped().longValue()); + outBuffer.writeLong(portStat.getRxErrors().longValue()); + outBuffer.writeLong(portStat.getTxErrors().longValue()); + outBuffer.writeLong(portStat.getRxFrameErr().longValue()); + outBuffer.writeLong(portStat.getRxOverErr().longValue()); + outBuffer.writeLong(portStat.getRxCrcErr().longValue()); + outBuffer.writeLong(portStat.getCollisions().longValue()); + } + } + + private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body; + MultipartReplyTable table = tableCase.getMultipartReplyTable(); + for (TableStats tableStats : table.getTableStats()) { + outBuffer.writeByte(tableStats.getTableId()); + outBuffer.writeZero(TABLE_PADDING); + write16String(tableStats.getName(), outBuffer); + writeFlowWildcardsV10(tableStats.getWildcards(), outBuffer); + outBuffer.writeInt(tableStats.getMaxEntries().intValue()); + outBuffer.writeInt(tableStats.getActiveCount().intValue()); + outBuffer.writeLong(tableStats.getLookupCount().longValue()); + outBuffer.writeLong(tableStats.getMatchedCount().longValue()); + } + } + + private void writeFlowWildcardsV10(FlowWildcardsV10 feature, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, feature.isINPORT()); + map.put(1, feature.isDLVLAN()); + map.put(2, feature.isDLSRC()); + map.put(3, feature.isDLDST()); + map.put(4, feature.isDLTYPE()); + map.put(5, feature.isNWPROTO()); + map.put(6, feature.isTPSRC()); + map.put(7, feature.isTPDST()); + map.put(20, feature.isDLVLANPCP()); + map.put(21, feature.isNWTOS()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body; + MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate(); + outBuffer.writeLong(aggregate.getPacketCount().longValue()); + outBuffer.writeLong(aggregate.getByteCount().longValue()); + outBuffer.writeInt(aggregate.getFlowCount().intValue()); + outBuffer.writeZero(AGGREGATE_PADDING); + } + + private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { + MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; + MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); + for (FlowStats flowStats : flow.getFlowStats()) { + ByteBuf flowStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + flowStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + flowStatsBuff.writeByte(new Long(flowStats.getTableId()).byteValue()); + flowStatsBuff.writeZero(FLOW_STATS_PADDING_1); + OFSerializer matchSerializer = registry + .getSerializer(new MessageTypeKey<>(message.getVersion(), MatchV10.class)); + matchSerializer.serialize(flowStats.getMatchV10(), flowStatsBuff); + flowStatsBuff.writeInt(flowStats.getDurationSec().intValue()); + flowStatsBuff.writeInt(flowStats.getDurationNsec().intValue()); + flowStatsBuff.writeShort(flowStats.getPriority()); + flowStatsBuff.writeShort(flowStats.getIdleTimeout()); + flowStatsBuff.writeShort(flowStats.getHardTimeout()); + flowStatsBuff.writeZero(FLOW_STATS_PADDING_2); + flowStatsBuff.writeLong(flowStats.getCookie().longValue()); + flowStatsBuff.writeLong(flowStats.getPacketCount().longValue()); + flowStatsBuff.writeLong(flowStats.getByteCount().longValue()); + ListSerializer.serializeList(flowStats.getAction(), ACTION_KEY_MAKER, registry, flowStatsBuff); + flowStatsBuff.setShort(FLOW_STATS_LENGTH_INDEX, flowStatsBuff.readableBytes()); + outBuffer.writeBytes(flowStatsBuff); + } + } + + private void writeFlags(MultipartRequestFlags flags, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, flags.isOFPMPFREQMORE()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeShort(bitmap); + } + + private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) { + MultipartReplyDescCase descCase = (MultipartReplyDescCase) body; + MultipartReplyDesc desc = descCase.getMultipartReplyDesc(); + write256String(desc.getMfrDesc(), outBuffer); + write256String(desc.getHwDesc(), outBuffer); + write256String(desc.getSwDesc(), outBuffer); + write32String(desc.getSerialNum(), outBuffer); + write256String(desc.getDpDesc(), outBuffer); + } + + private void write256String(String toWrite, ByteBuf outBuffer) { + byte[] nameBytes = toWrite.getBytes(); + if (nameBytes.length < 256) { + byte[] nameBytesPadding = new byte[256]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 256; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + } + + private void write16String(String toWrite, ByteBuf outBuffer) { + byte[] nameBytes = toWrite.getBytes(); + if (nameBytes.length < 16) { + byte[] nameBytesPadding = new byte[16]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 16; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + } + + private void write32String(String toWrite, ByteBuf outBuffer) { + byte[] nameBytes = toWrite.getBytes(); + if (nameBytes.length < 32) { + byte[] nameBytesPadding = new byte[32]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 32; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java new file mode 100644 index 00000000..713e8eda --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactory.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; + +/** + * Translates PacketIn messages + */ +public class PacketInMessageFactory implements OFSerializer, SerializerRegistryInjector { + private static final byte PADDING = 2; + private static final byte MESSAGE_TYPE = 10; + private SerializerRegistry registry; + + @Override + public void serialize(PacketInMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeInt(message.getBufferId().intValue()); + outBuffer.writeShort(message.getTotalLen().intValue()); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeByte(message.getTableId().getValue().byteValue()); + outBuffer.writeLong(message.getCookie().longValue()); + OFSerializer matchSerializer = registry + .> getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)); + matchSerializer.serialize(message.getMatch(), outBuffer); + outBuffer.writeZero(PADDING); + + byte[] data = message.getData(); + + if (data != null) { + outBuffer.writeBytes(data); + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + this.registry = serializerRegistry; + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java new file mode 100644 index 00000000..897db17f --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PortStatusMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 12; + private static final byte PADDING = 7; + private static final byte PORT_PADDING_1 = 4; + private static final byte PORT_PADDING_2 = 2; + + @Override + public void serialize(PortStatusMessage message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeByte(message.getReason().getIntValue()); + outBuffer.writeZero(PADDING); + outBuffer.writeInt(message.getPortNo().intValue()); + outBuffer.writeZero(PORT_PADDING_1); + writeMacAddress(message.getHwAddr().getValue(), outBuffer); + outBuffer.writeZero(PORT_PADDING_2); + writeName(message.getName(), outBuffer); + writePortConfig(message.getConfig(), outBuffer); + writePortState(message.getState(), outBuffer); + writePortFeatures(message.getCurrentFeatures(), outBuffer); + writePortFeatures(message.getAdvertisedFeatures(), outBuffer); + writePortFeatures(message.getSupportedFeatures(), outBuffer); + writePortFeatures(message.getPeerFeatures(), outBuffer); + outBuffer.writeInt(message.getCurrSpeed().intValue()); + outBuffer.writeInt(message.getMaxSpeed().intValue()); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void writePortConfig(PortConfig config, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, config.isPortDown()); + map.put(2, config.isNoRecv()); + map.put(5, config.isNoFwd()); + map.put(6, config.isNoPacketIn()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writeMacAddress(String macAddress, ByteBuf outBuffer) { + String[] macAddressParts = macAddress.split(":"); + byte[] macAddressBytes = new byte[6]; + for (int i = 0; i < 6; i++) { + Integer hex = Integer.parseInt(macAddressParts[i], 16); + macAddressBytes[i] = hex.byteValue(); + } + outBuffer.writeBytes(macAddressBytes); + } + + private void writeName(String name, ByteBuf outBuffer) { + byte[] nameBytes = name.getBytes(); + if (nameBytes.length < 16) { + byte[] nameBytesPadding = new byte[16]; + int i = 0; + for (byte b : nameBytes) { + nameBytesPadding[i] = b; + i++; + } + for (; i < 16; i++) { + nameBytesPadding[i] = 0x0; + } + outBuffer.writeBytes(nameBytesPadding); + } else { + outBuffer.writeBytes(nameBytes); + } + + } + + private void writePortState(PortState state, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, state.isLinkDown()); + map.put(1, state.isBlocked()); + map.put(2, state.isLive()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + + private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) { + Map map = new HashMap<>(); + map.put(0, features.is_10mbHd()); + map.put(1, features.is_10mbFd()); + map.put(2, features.is_100mbHd()); + map.put(3, features.is_100mbFd()); + map.put(4, features.is_1gbHd()); + map.put(5, features.is_1gbFd()); + map.put(6, features.is_10gbFd()); + map.put(7, features.is_40gbFd()); + map.put(8, features.is_100gbFd()); + map.put(9, features.is_1tbFd()); + map.put(10, features.isOther()); + map.put(11, features.isCopper()); + map.put(12, features.isFiber()); + map.put(13, features.isAutoneg()); + map.put(14, features.isPause()); + map.put(15, features.isPauseAsym()); + int bitmap = ByteBufUtils.fillBitMaskFromMap(map); + outBuffer.writeInt(bitmap); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java new file mode 100644 index 00000000..3a15aacc --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactory.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class QueueGetConfigReplyMessageFactory implements OFSerializer { + + private static final byte MESSAGE_TYPE = 23; + private static final byte PADDING = 4; + public static final int QUEUE_LENGTH_INDEX = 8; + public static final int PROPERTY_LENGTH_INDEX = 2; + private static final byte QUEUE_PADDING = 6; + private static final byte PROPERTY_HEADER_PADDING = 4; + private static final byte PROPERTY_RATE_PADDING = 6; + private static final byte PROPERTY_EXPERIMENTER_PADDING = 4; + + @Override + public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeInt(message.getPort().getValue().intValue()); + outBuffer.writeZero(PADDING); + for (Queues queue : message.getQueues()) { + ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + queueBuff.writeInt(queue.getQueueId().getValue().intValue()); + queueBuff.writeInt(queue.getPort().getValue().intValue()); + queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + queueBuff.writeZero(QUEUE_PADDING); + + for (QueueProperty property : queue.getQueueProperty()) { + ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer(); + propertyBuff.writeShort(property.getProperty().getIntValue()); + propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH); + propertyBuff.writeZero(PROPERTY_HEADER_PADDING); + switch (property.getProperty()) { + case OFPQTMINRATE: + serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); + break; + case OFPQTMAXRATE: + serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff); + break; + case OFPQTEXPERIMENTER: + serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), + propertyBuff); + break; + default: + break; + } + propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes()); + queueBuff.writeBytes(propertyBuff); + } + + queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes()); + outBuffer.writeBytes(queueBuff); + } + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + + private void serializeRateBody(RateQueueProperty body, ByteBuf outBuffer) { + outBuffer.writeShort(body.getRate()); + outBuffer.writeZero(PROPERTY_RATE_PADDING); + } + + private void serializeExperimenterBody(ExperimenterIdQueueProperty body, ByteBuf outBuffer) { + // TODO: Experimenter Data is vendor specific that should implement its + // own serializer + outBuffer.writeInt(body.getExperimenter().getValue().intValue()); + outBuffer.writeZero(PROPERTY_EXPERIMENTER_PADDING); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java new file mode 100644 index 00000000..0225665c --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactory.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class RoleReplyMessageFactory implements OFSerializer { + private static final byte MESSAGE_TYPE = 25; + private static final byte PADDING = 4; + + @Override + public void serialize(RoleRequestOutput message, ByteBuf outBuffer) { + ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); + outBuffer.writeInt(message.getRole().getIntValue()); + outBuffer.writeZero(PADDING); + outBuffer.writeLong(message.getGenerationId().longValue()); + ByteBufUtils.updateOFHeaderLength(outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index 65395c16..cef8daa7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -12,28 +12,43 @@ import java.util.HashMap; import java.util.Map; - import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** * @author michal.polkorab + * @author giuseppex.petralia@intel.com * */ public class TypeToClassMapInitializerTest { @@ -78,4 +93,38 @@ public void test() { assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); } + + @Test + public void testAdditionalTypes() { + messageClassMap = new HashMap<>(); + TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; + assertEquals("Wrong class", GetFeaturesInput.class, messageClassMap.get(new TypeToClassKey(version, 5))); + assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); + assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); + assertEquals("Wrong class", PacketOutInput.class, messageClassMap.get(new TypeToClassKey(version, 13))); + assertEquals("Wrong class", FlowModInput.class, messageClassMap.get(new TypeToClassKey(version, 14))); + assertEquals("Wrong class", PortModInput.class, messageClassMap.get(new TypeToClassKey(version, 15))); + assertEquals("Wrong class", MultipartRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 16))); + assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 18))); + assertEquals("Wrong class", GetQueueConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 20))); + + version = EncodeConstants.OF13_VERSION_ID; + assertEquals("Wrong class", GetFeaturesInput.class, messageClassMap.get(new TypeToClassKey(version, 5))); + assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); + assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); + assertEquals("Wrong class", PacketOutInput.class, messageClassMap.get(new TypeToClassKey(version, 13))); + assertEquals("Wrong class", FlowModInput.class, messageClassMap.get(new TypeToClassKey(version, 14))); + assertEquals("Wrong class", GroupModInput.class, messageClassMap.get(new TypeToClassKey(version, 15))); + assertEquals("Wrong class", PortModInput.class, messageClassMap.get(new TypeToClassKey(version, 16))); + assertEquals("Wrong class", TableModInput.class, messageClassMap.get(new TypeToClassKey(version, 17))); + assertEquals("Wrong class", MultipartRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 18))); + assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 20))); + assertEquals("Wrong class", GetQueueConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 22))); + assertEquals("Wrong class", RoleRequestInput.class, messageClassMap.get(new TypeToClassKey(version, 24))); + assertEquals("Wrong class", GetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 26))); + assertEquals("Wrong class", SetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 28))); + assertEquals("Wrong class", MeterModInput.class, messageClassMap.get(new TypeToClassKey(version, 29))); + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java new file mode 100644 index 00000000..1fbcfc1c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class BarrierInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 20, BarrierInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java new file mode 100644 index 00000000..f98564bd --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowModInputMessageFactoryTest.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class FlowModInputMessageFactoryTest { + private OFDeserializer flowFactory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + flowFactory = registry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 14, FlowModInput.class)); + } + + @Test + public void test() throws Exception { + ByteBuf bb = BufferHelper + .buildBuffer("ff 01 04 01 06 00 07 01 ff 05 00 00 09 30 00 30 41 02 00 0c 00 00 00 7e 00 " + + "00 00 02 00 00 11 46 00 00 00 62 00 0b 00 00 00 01 00 11 80 00 02 04 00 00 00 2a 80 00 12 01 04 00 " + + "00 00 00 00 00 00 00 01 00 08 2b 00 00 00 00 02 00 18 00 00 00 00 ff 01 04 01 06 00 07 01 ff 05 00 00 " + + "09 30 00 30 00 04 00 18 00 00 00 00 00 00 00 10 00 00 00 2a 00 34 00 00 00 00 00 00"); + FlowModInput deserializedMessage = BufferHelper.deserialize(flowFactory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; + Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie()); + byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 }; + Assert.assertEquals("Wrong cookie mask", new BigInteger(1, cookieMask), deserializedMessage.getCookieMask()); + Assert.assertEquals("Wrong table id", new TableId(65L), deserializedMessage.getTableId()); + Assert.assertEquals("Wrong command", FlowModCommand.forValue(2), deserializedMessage.getCommand()); + Assert.assertEquals("Wrong idle timeout", 12, deserializedMessage.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hard timeout", 0, deserializedMessage.getHardTimeout().intValue()); + Assert.assertEquals("Wrong priority", 126, deserializedMessage.getPriority().intValue()); + Assert.assertEquals("Wrong buffer id ", 2L, deserializedMessage.getBufferId().longValue()); + Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort()); + Assert.assertEquals("Wrong out group", 98L, deserializedMessage.getOutGroup().longValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), + deserializedMessage.getFlags()); + Assert.assertEquals("Wrong match", createMatch(), deserializedMessage.getMatch()); + Assert.assertEquals("Wrong instructions", createInstructions(), deserializedMessage.getInstruction()); + + } + + private List createInstructions() { + List instructions = new ArrayList<>(); + InstructionBuilder insBuilder = new InstructionBuilder(); + GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder(); + GotoTableBuilder instructionBuilder = new GotoTableBuilder(); + instructionBuilder.setTableId((short) 43); + goToCaseBuilder.setGotoTable(instructionBuilder.build()); + insBuilder.setInstructionChoice(goToCaseBuilder.build()); + instructions.add(insBuilder.build()); + WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder(); + WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder(); + byte[] metadata = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; + metadataBuilder.setMetadata(metadata); + byte[] metadataMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 }; + metadataBuilder.setMetadataMask(metadataMask); + metadataCaseBuilder.setWriteMetadata(metadataBuilder.build()); + insBuilder.setInstructionChoice(metadataCaseBuilder.build()); + instructions.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder(); + ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(52); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + actionsBuilder.setAction(actions); + applyActionsCaseBuilder.setApplyActions(actionsBuilder.build()); + insBuilder.setInstructionChoice(applyActionsCaseBuilder.build()); + instructions.add(insBuilder.build()); + return instructions; + } + + private Match createMatch() { + MatchBuilder matchBuilder = new MatchBuilder(); + matchBuilder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(42L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); + entries.add(entriesBuilder.build()); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 4); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); + entries.add(entriesBuilder.build()); + matchBuilder.setMatchEntry(entries); + return matchBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java new file mode 100644 index 00000000..dba971e3 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncRequestMessageFactoryTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetAsyncRequestMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 26, GetAsyncInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + GetAsyncInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java new file mode 100644 index 00000000..a2c9085a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetConfigInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 7, GetConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java new file mode 100644 index 00000000..0615098c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetFeaturesInputFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 5, GetFeaturesInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + GetFeaturesInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java new file mode 100644 index 00000000..95f5197d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetQueueConfigInputMessageFactoryTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetQueueConfigInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 22, GetQueueConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 00 00 00 00"); + GetQueueConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + Assert.assertEquals("Wrong Port No", new PortNumber(0x00010203L), deserializedMessage.getPort()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java new file mode 100644 index 00000000..0ede670d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GroupModInputMessageFactoryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GroupModInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 15, GroupModInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper + .buildBuffer("00 02 03 00 00 00 01 00 00 10 00 0a 00 " + "00 00 41 00 00 00 16 00 00 00 00"); + GroupModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + // Test Message + Assert.assertEquals("Wrong command", GroupModCommand.forValue(2), deserializedMessage.getCommand()); + Assert.assertEquals("Wrong type", GroupType.forValue(3), deserializedMessage.getType()); + Assert.assertEquals("Wrong group id", new GroupId(256L), deserializedMessage.getGroupId()); + BucketsList bucket = deserializedMessage.getBucketsList().get(0); + Assert.assertEquals("Wrong weight", 10, bucket.getWeight().intValue()); + Assert.assertEquals("Wrong watch port", new PortNumber(65L), bucket.getWatchPort()); + Assert.assertEquals("Wrong watch group", 22L, bucket.getWatchGroup().longValue()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java new file mode 100644 index 00000000..72c02500 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactoryTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MeterModInputMessageFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 29, MeterModInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03 00 00 08 c8 00 " + + "01 00 10 00 00 00 01 00 00 00 02 00 00 00 " + "00 00 02 00 10 00 00 00 01 00 00 00 02 03 00 00 00"); + MeterModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong command", MeterModCommand.forValue(1), deserializedMessage.getCommand()); + Assert.assertEquals("Wrong flags", new MeterFlags(false, true, true, false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong meter id", new MeterId(2248L), deserializedMessage.getMeterId()); + Assert.assertEquals("Wrong band", createBandsList().get(0), deserializedMessage.getBands().get(0)); + Assert.assertEquals("Wrong band", createBandsList().get(1), deserializedMessage.getBands().get(1)); + } + + private static List createBandsList() { + List bandsList = new ArrayList<>(); + BandsBuilder bandsBuilder = new BandsBuilder(); + MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder(); + MeterBandDropBuilder dropBand = new MeterBandDropBuilder(); + dropBand.setType(MeterBandType.OFPMBTDROP); + dropBand.setRate(1L); + dropBand.setBurstSize(2L); + dropCaseBuilder.setMeterBandDrop(dropBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build()); + MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); + MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder(); + dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK); + dscpRemarkBand.setRate(1L); + dscpRemarkBand.setBurstSize(2L); + dscpRemarkBand.setPrecLevel((short) 3); + dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); + return bandsList; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java new file mode 100644 index 00000000..43397a8e --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestAggregateInputMessageFactoryTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestAggregateInputMessageFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 08 00 " + + "00 00 00 00 00 55 00 00 00 5f 00 00 00 00 00 01 01 01 01 01 " + "01 01 00 01 01 01 01 01 01 01"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(2), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestAggregate(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestAggregateCase createRequestAggregate() { + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder builder = new MultipartRequestAggregateBuilder(); + builder.setTableId((short) 8); + builder.setOutPort(85L); + builder.setOutGroup(95L); + byte[] cookie = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; + builder.setCookie(new BigInteger(1, cookie)); + byte[] cookieMask = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; + builder.setCookieMask(new BigInteger(1, cookieMask)); + caseBuilder.setMultipartRequestAggregate(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java new file mode 100644 index 00000000..89aea312 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestDescInputMessageFactoryTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestDescInputMessageFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(0), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestDesc(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestDescCase createRequestDesc() { + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder builder = new MultipartRequestDescBuilder(); + builder.setEmpty(true); + caseBuilder.setMultipartRequestDesc(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java new file mode 100644 index 00000000..d8f9d0a0 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestFlowInputMessageFactoryTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestFlowInputMessageFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 " + "08 00 00 00 00 00 00 55 00 00 00 5f 00 " + + "00 00 00 00 01 01 01 01 01 01 01 00 01 01 01 01 01 01 01"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(1), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong flow", createRequestFlow(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestFlowCase createRequestFlow() { + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder builder = new MultipartRequestFlowBuilder(); + builder.setTableId((short) 8); + builder.setOutPort(85L); + builder.setOutGroup(95L); + byte[] cookie = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; + builder.setCookie(new BigInteger(1, cookie)); + byte[] cookieMask = new byte[] { 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; + builder.setCookieMask(new BigInteger(1, cookieMask)); + caseBuilder.setMultipartRequestFlow(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java new file mode 100644 index 00000000..6f73801c --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestGroupInputMessageFactoryTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestGroupInputMessageFactoryTest { + ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 00 00 08 d2 00 00 00 00"); + MultipartRequestInputMessageFactory factory; + MultipartRequestInput deserializedMessage; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + + } + + @Test + public void test() { + deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(6), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestGroup(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestGroupCase createRequestGroup() { + MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder(); + MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder(); + builder.setGroupId(new GroupId(2258L)); + caseBuilder.setMultipartRequestGroup(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java new file mode 100644 index 00000000..46c3a13b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterConfigInputMessageFactoryTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestMeterConfigInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 0a 00 01 00 00 00 00 00 00 04 6d 00 00 00 00"); + + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + Assert.assertEquals("Wrong type", MultipartType.forValue(10), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestMeterConfig(), + deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestMeterConfigCase createRequestMeterConfig() { + MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder(); + MultipartRequestMeterConfigBuilder builder = new MultipartRequestMeterConfigBuilder(); + builder.setMeterId(new MeterId(1133L)); + caseBuilder.setMultipartRequestMeterConfig(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java new file mode 100644 index 00000000..b4f334f9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestMeterInputMessageFactoryTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestMeterInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 00 00 04 61 00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + Assert.assertEquals("Wrong type", MultipartType.forValue(9), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestMeter(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestMeterCase createRequestMeter() { + MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder(); + MultipartRequestMeterBuilder builder = new MultipartRequestMeterBuilder(); + builder.setMeterId(new MeterId(1121L)); + caseBuilder.setMultipartRequestMeter(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java new file mode 100644 index 00000000..68482e36 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestPortStatsInputMessageFactoryTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestPortStatsInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 00 00 08 cb 00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(4), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestPortStats(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestPortStatsCase createRequestPortStats() { + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder builder = new MultipartRequestPortStatsBuilder(); + builder.setPortNo(2251L); + caseBuilder.setMultipartRequestPortStats(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java new file mode 100644 index 00000000..6a746ead --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestQueueInputMessageFactoryTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestQueueInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 00 00 08 d0 00 00 08 a3"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(5), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong aggregate", createRequestQueue(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestQueueCase createRequestQueue() { + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder builder = new MultipartRequestQueueBuilder(); + builder.setPortNo(2256L); + builder.setQueueId(2211L); + caseBuilder.setMultipartRequestQueue(builder.build()); + return caseBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java new file mode 100644 index 00000000..600a7aaf --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableFeaturesInputMessageFactoryTest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestTableFeaturesInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 0c 00 01 00 00 00 00 00 68 01 00 00 00 00 00 4e 61 6d " + + "65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 10 00 01 " + + "00 04 00 02 00 04 00 04 00 04 00 02 00 05 01 00 00 00 00 04 00 08 00 00 00 04 00 08 00 08 80 00 02 04 "); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + Assert.assertEquals("Wrong type", MultipartType.forValue(12), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createTableFeatures(), deserializedMessage.getMultipartRequestBody()); + } + + public MultipartRequestTableFeaturesCase createTableFeatures() { + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder builder = new MultipartRequestTableFeaturesBuilder(); + builder.setTableFeatures(createTableFeaturesList()); + caseBuilder.setMultipartRequestTableFeatures(builder.build()); + return caseBuilder.build(); + + } + + public List createTableFeaturesList() { + List list = new ArrayList<>(); + TableFeaturesBuilder builder = new TableFeaturesBuilder(); + builder.setTableId((short) 1); + builder.setName("Name"); + builder.setMetadataWrite(new BigInteger("1")); + builder.setMetadataMatch(new BigInteger("1")); + builder.setMaxEntries(1L); + builder.setConfig(new TableConfig(false)); + builder.setTableFeatureProperties(createTableFeatureProperties()); + list.add(builder.build()); + return list; + } + + public List createTableFeatureProperties() { + List list = new ArrayList<>(); + TableFeaturePropertiesBuilder builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.forValue(0)); + InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + insBuilder.setInstruction(createInstructions()); + builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build()); + list.add(builder.build()); + + builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.forValue(2)); + NextTableRelatedTableFeaturePropertyBuilder nextBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + nextBuilder.setNextTableIds(createNextTableIds()); + builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextBuilder.build()); + list.add(builder.build()); + + builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.forValue(4)); + ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actionBuilder.setAction(createAction()); + builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build()); + list.add(builder.build()); + + builder = new TableFeaturePropertiesBuilder(); + builder.setType(TableFeaturesPropType.forValue(8)); + OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + oxmBuilder.setMatchEntry(createMatchEntries()); + builder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + list.add(builder.build()); + + return list; + } + + public List createMatchEntries() { + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + return entries; + } + + public List createAction() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + return actions; + } + + public List createNextTableIds() { + List list = new ArrayList<>(); + NextTableIdsBuilder builder = new NextTableIdsBuilder(); + builder.setTableId((short) 1); + list.add(builder.build()); + return list; + } + + public List createInstructions() { + List instructions = new ArrayList<>(); + InstructionBuilder insBuilder = new InstructionBuilder(); + GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder(); + insBuilder.setInstructionChoice(goToCaseBuilder.build()); + instructions.add(insBuilder.build()); + WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder(); + insBuilder.setInstructionChoice(metadataCaseBuilder.build()); + instructions.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder(); + insBuilder.setInstructionChoice(applyActionsCaseBuilder.build()); + instructions.add(insBuilder.build()); + return instructions; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java new file mode 100644 index 00000000..8719dc2b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestTableInputMessageFactoryTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartRequestTableInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong type", MultipartType.forValue(3), deserializedMessage.getType()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java new file mode 100644 index 00000000..01f51840 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10BarrierInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java new file mode 100644 index 00000000..97682d89 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesRequestMessageFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FeaturesRequestMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 5, GetFeaturesInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + GetFeaturesInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java new file mode 100644 index 00000000..92c16dcb --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlagsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FlowModInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 14, FlowModInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 38 20 ff 00 3a 01 01 01 01 01 01 ff " + + "ff ff ff ff ff 00 12 05 00 00 2a 04 07 00 00 08 08 08 08 10 10 10 10 " + + "19 fd 19 e9 ff 01 04 01 06 00 07 01 00 00 00 0c 00 10 00 01 00 00 00 02 " + + "11 46 00 03 00 07 00 08 02 02 02 02 00 09 00 08 00 2a 00 00 "); + FlowModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong Match", createMatch(), deserializedMessage.getMatchV10()); + byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; + Assert.assertEquals("Wrong cookie", new BigInteger(1, cookie), deserializedMessage.getCookie()); + Assert.assertEquals("Wrong command", FlowModCommand.forValue(0), deserializedMessage.getCommand()); + Assert.assertEquals("Idle Timeout", 12, deserializedMessage.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong Hard Timeout", 16, deserializedMessage.getHardTimeout().intValue()); + Assert.assertEquals("Wrong priority", 1, deserializedMessage.getPriority().intValue()); + Assert.assertEquals("Wrong buffer id", 2L, deserializedMessage.getBufferId().longValue()); + Assert.assertEquals("Wrong out port", new PortNumber(4422L), deserializedMessage.getOutPort()); + Assert.assertEquals("Wrong flags", new FlowModFlagsV10(true, false, true), deserializedMessage.getFlagsV10()); + Assert.assertEquals("Wrong actions", createAction(), deserializedMessage.getAction()); + } + + private static List createAction() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder(); + SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder(); + nwDstBuilder.setIpAddress(new Ipv4Address("2.2.2.2")); + nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build()); + actionBuilder.setActionChoice(nwDstCaseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder(); + SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder(); + tpSrcBuilder.setPort(new PortNumber(42L)); + tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build()); + actionBuilder.setActionChoice(tpSrcCaseBuilder.build()); + actions.add(actionBuilder.build()); + return actions; + } + + private static MatchV10 createMatch() { + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); + matchBuilder.setNwSrcMask((short) 0); + matchBuilder.setNwDstMask((short) 0); + matchBuilder.setInPort(58); + matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01")); + matchBuilder.setDlDst(new MacAddress("FF:FF:FF:FF:FF:FF")); + matchBuilder.setDlVlan(18); + matchBuilder.setDlVlanPcp((short) 5); + matchBuilder.setDlType(42); + matchBuilder.setNwTos((short) 4); + matchBuilder.setNwProto((short) 7); + matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8")); + matchBuilder.setNwDst(new Ipv4Address("16.16.16.16")); + matchBuilder.setTpSrc(6653); + matchBuilder.setTpDst(6633); + return matchBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java new file mode 100644 index 00000000..6ab22829 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10GetConfigInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 7, GetConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer(); + GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java new file mode 100644 index 00000000..15873bd1 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactoryTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10GetQueueConfigInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 20, GetQueueConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("19 fd 00 00"); + GetQueueConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong port", new PortNumber(6653L), deserializedMessage.getPort()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java new file mode 100644 index 00000000..93425026 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PacketOutInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 13, PacketOutInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 01 00 01 01 00 10 00 00 00 08 " + + "00 2a 00 32 00 03 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + + PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong bufferId ", 256L, deserializedMessage.getBufferId().longValue()); + Assert.assertEquals("Wrong inPort ", new PortNumber(257L), deserializedMessage.getInPort()); + Assert.assertEquals("Wrong action ", createActionList().get(0), deserializedMessage.getAction().get(0)); + Assert.assertEquals("Wrong action ", createActionList().get(1), deserializedMessage.getAction().get(1)); + Assert.assertArrayEquals("Wrong data ", + ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"), + deserializedMessage.getData()); + } + + private static List createActionList() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(50); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new StripVlanCaseBuilder().build()); + actions.add(actionBuilder.build()); + return actions; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java new file mode 100644 index 00000000..e4a3a801 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PortModInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 15, PortModInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper + .buildBuffer("19 e9 08 00 27 00 b0 eb " + "00 00 00 15 00 00 00 62 00 00 02 8c 00 00 00 00 "); + PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong port", new PortNumber(6633L), deserializedMessage.getPortNo()); + Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress()); + Assert.assertEquals("Wrong config", new PortConfigV10(true, false, false, true, false, false, true), + deserializedMessage.getConfigV10()); + Assert.assertEquals("Wrong mask", new PortConfigV10(false, true, true, false, false, true, false), + deserializedMessage.getMaskV10()); + Assert.assertEquals("Wrong advertise", + new PortFeaturesV10(true, true, false, false, false, false, false, true, true, false, false, false), + deserializedMessage.getAdvertiseV10()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java new file mode 100644 index 00000000..763210ce --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10SetConfigMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 9, SetConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03"); + SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong switchConfigFlag", 0x01, deserializedMessage.getFlags().getIntValue()); + Assert.assertEquals("Wrong missSendLen", 0x03, deserializedMessage.getMissSendLen().intValue()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java new file mode 100644 index 00000000..1c58e70d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputAggregateFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 02 00 00 00 00 00 00 00 33 00 01 02 " + + "03 04 05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 " + + "0a 00 00 02 00 39 00 3a 2a 00 19 fd"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + + Assert.assertEquals("Wrong type", 2, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards( + new FlowWildcardsV10(false, false, false, false, false, false, false, false, false, false)); + matchBuilder.setNwSrcMask((short) 32); + matchBuilder.setNwDstMask((short) 32); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + aggregateBuilder.setMatchV10(matchBuilder.build()); + aggregateBuilder.setTableId((short) 42); + aggregateBuilder.setOutPort(6653L); + caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java new file mode 100644 index 00000000..545d1d7b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputDescFactoryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputDescFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + + Assert.assertEquals("Wrong type", 0, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestDesc(descBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java new file mode 100644 index 00000000..e9c6dcb0 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputFlowFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 34 18 ff 00 33 00 01 02 03 04 " + + "05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 0a 00 00 02 " + + "00 39 00 3a 01 00 00 2a "); + + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + Assert.assertEquals("Wrong type", 1, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + flowBuilder.setMatchV10(matchBuilder.build()); + flowBuilder.setTableId((short) 1); + flowBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java new file mode 100644 index 00000000..afe70c92 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputPortStatsFactoryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputPortStatsFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 04 00 00 00 0f 00 00 00 00 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + + Assert.assertEquals("Wrong type", 4, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); + portBuilder.setPortNo(15L); + caseBuilder.setMultipartRequestPortStats(portBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java new file mode 100644 index 00000000..39c571cd --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputQueueFactoryTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputQueueFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 00 0f 00 00 00 00 00 10"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + + Assert.assertEquals("Wrong type", 5, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); + queueBuilder.setPortNo(15L); + queueBuilder.setQueueId(16L); + caseBuilder.setMultipartRequestQueue(queueBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java new file mode 100644 index 00000000..bc9bdf77 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputTableFactoryTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.MultipartRequestBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsRequestInputTableFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 16, MultipartRequestInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 03 00 00"); + MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV10(deserializedMessage); + + Assert.assertEquals("Wrong type", 3, deserializedMessage.getType().getIntValue()); + Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); + } + + private static MultipartRequestBody createMultipartRequestBody() { + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); + tableBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tableBuilder.build()); + return caseBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java new file mode 100644 index 00000000..8a2b1e98 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactoryTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PacketOutInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 13, PacketOutInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer( + "00 00 01 00 00 00 01 00 00 28 00 00 00 00 00 00 00 11 00 08 00 19 00 00 00 12 00 08 00 00 00 00 00 12 " + + "00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 12 00 08 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 10 " + + "11 12 13 14"); + PacketOutInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong buffer Id", 256L, deserializedMessage.getBufferId().longValue()); + Assert.assertEquals("Wrong In Port", new PortNumber(256L), deserializedMessage.getInPort()); + Assert.assertEquals("Wrong Numbers of actions", createAction(), deserializedMessage.getAction()); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + Assert.assertArrayEquals("Wrong data", data, deserializedMessage.getData()); + } + + private List createAction() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder(); + pushVlanBuilder.setEthertype(new EtherType(new EtherType(25))); + pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build()); + actionBuilder.setActionChoice(pushVlanCaseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new PopVlanCaseBuilder().build()); + actions.add(actionBuilder.build()); + return actions; + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java new file mode 100644 index 00000000..6c4850c0 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PortModInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() throws Exception { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 16, PortModInput.class)); + } + + @Test + public void test() throws Exception { + ByteBuf bb = BufferHelper.buildBuffer( + "00 00 00 09 00 00 00 00 08 00 27 00 " + "b0 eb 00 00 00 00 00 24 00 00 00 41 00 00 01 10 00 00 00 00"); + PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + // Test Message + Assert.assertEquals("Wrong port", new PortNumber(9L), deserializedMessage.getPortNo()); + Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress()); + Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig()); + Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask()); + Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true, + false, false, false, false, false, false, false, false), deserializedMessage.getAdvertise()); + + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java new file mode 100644 index 00000000..368aca40 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/RoleRequestInputMessageFactoryTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class RoleRequestInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 24, RoleRequestInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 02 00 00 00 00 ff 01 01 01 01 01 01 01"); + RoleRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + Assert.assertEquals("Wrong role", ControllerRole.forValue(2), deserializedMessage.getRole()); + byte[] generationId = new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }; + Assert.assertEquals("Wrong generation Id", new BigInteger(1, generationId), + deserializedMessage.getGenerationId()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java new file mode 100644 index 00000000..e5c1d9af --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetAsyncInputMessageFactoryTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class SetAsyncInputMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 28, SetAsyncInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper + .buildBuffer("00 00 00 07 00 00 00 00 00 00 00 " + "07 00 00 00 00 00 00 00 0f 00 00 00 00"); + SetAsyncInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(0), + deserializedMessage.getPacketInMask().get(0)); + Assert.assertEquals("Wrong packet in mask ", createPacketInMask().get(1), + deserializedMessage.getPacketInMask().get(1)); + Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(0), + deserializedMessage.getPortStatusMask().get(0)); + Assert.assertEquals("Wrong port status mask ", createPortStatusMask().get(1), + deserializedMessage.getPortStatusMask().get(1)); + Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(0), + deserializedMessage.getFlowRemovedMask().get(0)); + Assert.assertEquals("Wrong flow removed mask ", createFlowRemowedMask().get(1), + deserializedMessage.getFlowRemovedMask().get(1)); + + } + + private static List createPacketInMask() { + List masks = new ArrayList<>(); + PacketInMaskBuilder builder; + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + builder = new PacketInMaskBuilder(); + List packetInReasonList = new ArrayList<>(); + packetInReasonList.add(PacketInReason.OFPRNOMATCH); + packetInReasonList.add(PacketInReason.OFPRACTION); + packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); + builder.setMask(packetInReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new PacketInMaskBuilder(); + packetInReasonList = new ArrayList<>(); + builder.setMask(packetInReasonList); + masks.add(builder.build()); + return masks; + } + + private static List createPortStatusMask() { + List masks = new ArrayList<>(); + PortStatusMaskBuilder builder; + builder = new PortStatusMaskBuilder(); + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + List portReasonList = new ArrayList<>(); + portReasonList.add(PortReason.OFPPRADD); + portReasonList.add(PortReason.OFPPRDELETE); + portReasonList.add(PortReason.OFPPRMODIFY); + builder.setMask(portReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new PortStatusMaskBuilder(); + portReasonList = new ArrayList<>(); + builder.setMask(portReasonList); + masks.add(builder.build()); + return masks; + } + + private static List createFlowRemowedMask() { + List masks = new ArrayList<>(); + FlowRemovedMaskBuilder builder; + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + builder = new FlowRemovedMaskBuilder(); + List flowRemovedReasonList = new ArrayList<>(); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); + builder.setMask(flowRemovedReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new FlowRemovedMaskBuilder(); + flowRemovedReasonList = new ArrayList<>(); + builder.setMask(flowRemovedReasonList); + masks.add(builder.build()); + return masks; + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java new file mode 100644 index 00000000..d15b8359 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class SetConfigMessageFactoryTest { + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class)); + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a"); + SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + + // Test Message + Assert.assertEquals("Wrong flags ", SwitchConfigFlag.forValue(2), deserializedMessage.getFlags()); + Assert.assertEquals("Wrong Miss Send len ", 10, deserializedMessage.getMissSendLen().intValue()); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java new file mode 100644 index 00000000..3b63748e --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/TableModInputMessageFactoryTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class TableModInputMessageFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); + desRegistry.init(); + factory = desRegistry + .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 17, TableModInput.class)); + + } + + @Test + public void test() { + ByteBuf bb = BufferHelper.buildBuffer("09 00 00 00 00 00 00 01"); + TableModInput deserializedMessage = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeaderV13(deserializedMessage); + // Test Message + Assert.assertEquals("Wrong table id ", new TableId(9L), deserializedMessage.getTableId()); + Assert.assertEquals("Wrong config ", new TableConfig(true), deserializedMessage.getConfig()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java new file mode 100644 index 00000000..cbe260d5 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/BarrierReplyMessageFactoryTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class BarrierReplyMessageFactoryTest { + private static final byte MESSAGE_TYPE = 21; + private OFSerializer factory; + + @Before + public void startUp() throws Exception { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierOutput.class)); + + } + + @Test + public void testSerialize() throws Exception { + BarrierOutputBuilder builder = new BarrierOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + BarrierOutput message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java new file mode 100644 index 00000000..cc0ba0df --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class EchoOutputMessageFactoryTest { + private static final byte MESSAGE_TYPE = 3; + private OFSerializer factory; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, EchoOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + EchoOutputBuilder builder = new EchoOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + builder.setData(data); + EchoOutput message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); + Assert.assertArrayEquals("Wrong data", message.getData(), + serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java new file mode 100644 index 00000000..20f8b5fc --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class EchoRequestMessageFactoryTest { + private static final byte MESSAGE_TYPE = 2; + EchoRequestMessage message; + private OFSerializer factory; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, EchoRequestMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + builder.setData(data); + EchoRequestMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); + Assert.assertArrayEquals("Wrong data", message.getData(), + serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java new file mode 100644 index 00000000..ff3e70ea --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class ErrorMessageFactoryTest { + private static final byte MESSAGE_TYPE = 1; + private OFSerializer factory; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, ErrorMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + ErrorMessageBuilder builder = new ErrorMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(10); + builder.setCode(20); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + builder.setData(data); + ErrorMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28); + Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort()); + Assert.assertArrayEquals("Wrong data", message.getData(), + serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java new file mode 100644 index 00000000..616b289b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class FlowRemovedMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 11; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, FlowRemovedMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setCookie(BigInteger.valueOf(1234L)); + builder.setPriority(1234); + builder.setReason(FlowRemovedReason.forValue(2)); + builder.setTableId(new TableId(65L)); + builder.setDurationSec(1234L); + builder.setDurationNsec(1234L); + builder.setIdleTimeout(1234); + builder.setHardTimeout(1234); + builder.setPacketCount(BigInteger.valueOf(1234L)); + builder.setByteCount(BigInteger.valueOf(1234L)); + MatchBuilder matchBuilder = new MatchBuilder(); + matchBuilder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(42L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); + entries.add(entriesBuilder.build()); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 4); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); + entries.add(entriesBuilder.build()); + matchBuilder.setMatchEntry(entries); + builder.setMatch(matchBuilder.build()); + FlowRemovedMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72); + Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong priority", message.getPriority().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readByte()); + Assert.assertEquals("Wrong Table ID", message.getTableId().getValue().intValue(), + serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong duration sec", message.getDurationSec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", message.getDurationNsec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong Idle timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong Hard timeout", message.getIdleTimeout().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong Packet count", message.getPacketCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", message.getByteCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); + short fieldAndMask = serializedBuffer.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); + fieldAndMask = serializedBuffer.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(7); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java new file mode 100644 index 00000000..f645944b --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetAsyncReplyMessageFactoryTest.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.FlowRemovedMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PacketInMaskBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMask; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetAsyncReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 27; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetAsyncOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setPacketInMask(createPacketInMask()); + builder.setPortStatusMask(createPortStatusMask()); + builder.setFlowRemovedMask(createFlowRemowedMask()); + GetAsyncOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32); + Assert.assertEquals("Wrong packetInMask", 7, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong packetInMask", 0, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong portStatusMask", 7, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong portStatusMask", 0, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong flowRemovedMask", 15, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong flowRemovedMask", 0, serializedBuffer.readUnsignedInt()); + } + + private static List createPacketInMask() { + List masks = new ArrayList<>(); + PacketInMaskBuilder builder; + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + builder = new PacketInMaskBuilder(); + List packetInReasonList = new ArrayList<>(); + packetInReasonList.add(PacketInReason.OFPRNOMATCH); + packetInReasonList.add(PacketInReason.OFPRACTION); + packetInReasonList.add(PacketInReason.OFPRINVALIDTTL); + builder.setMask(packetInReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new PacketInMaskBuilder(); + packetInReasonList = new ArrayList<>(); + builder.setMask(packetInReasonList); + masks.add(builder.build()); + return masks; + } + + private static List createPortStatusMask() { + List masks = new ArrayList<>(); + PortStatusMaskBuilder builder; + builder = new PortStatusMaskBuilder(); + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + List portReasonList = new ArrayList<>(); + portReasonList.add(PortReason.OFPPRADD); + portReasonList.add(PortReason.OFPPRDELETE); + portReasonList.add(PortReason.OFPPRMODIFY); + builder.setMask(portReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new PortStatusMaskBuilder(); + portReasonList = new ArrayList<>(); + builder.setMask(portReasonList); + masks.add(builder.build()); + return masks; + } + + private static List createFlowRemowedMask() { + List masks = new ArrayList<>(); + FlowRemovedMaskBuilder builder; + // OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER + builder = new FlowRemovedMaskBuilder(); + List flowRemovedReasonList = new ArrayList<>(); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRIDLETIMEOUT); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRHARDTIMEOUT); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRDELETE); + flowRemovedReasonList.add(FlowRemovedReason.OFPRRGROUPDELETE); + builder.setMask(flowRemovedReasonList); + masks.add(builder.build()); + // OFPCR_ROLE_SLAVE + builder = new FlowRemovedMaskBuilder(); + flowRemovedReasonList = new ArrayList<>(); + builder.setMask(flowRemovedReasonList); + masks.add(builder.build()); + return masks; + } + + @Test + public void testSetAsyncInputWithNullMasks() throws Exception { + GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setPacketInMask(null); + builder.setPortStatusMask(null); + builder.setFlowRemovedMask(null); + GetAsyncOutput message = builder.build(); + GetAsyncReplyMessageFactory serializer = new GetAsyncReplyMessageFactory(); + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8); + Assert.assertTrue("Unexpected data", serializedBuffer.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java new file mode 100644 index 00000000..a6d00adf --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetConfigReplyMessageFactoryTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class GetConfigReplyMessageFactoryTest { + private static final byte MESSAGE_TYPE = 8; + private OFSerializer factory; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetConfigOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetConfigOutputBuilder builder = new GetConfigOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(SwitchConfigFlag.forValue(2)); + builder.setMissSendLen(20); + GetConfigOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 12); + Assert.assertEquals("Wrong Type", message.getFlags().getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong Code", message.getMissSendLen().intValue(), serializedBuffer.readShort()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java new file mode 100644 index 00000000..271933d3 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GetFeaturesOutputFactoryTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; + +public class GetFeaturesOutputFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 6; + private static final byte PADDING = 2; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetFeaturesOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setDatapathId(BigInteger.valueOf(1234L)); + builder.setBuffers(1234L); + builder.setTables((short) 12); + builder.setAuxiliaryId((short) 12); + builder.setCapabilities(new Capabilities(true, false, true, false, true, false, true)); + builder.setReserved(1234L); + GetFeaturesOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 32); + Assert.assertEquals("Wrong DatapathId", message.getDatapathId().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Buffer ID", message.getBuffers().longValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong auxiliary ID", message.getAuxiliaryId().shortValue(), + serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(PADDING); + Assert.assertEquals("Wrong Capabilities", message.getCapabilities(), + createCapabilities(serializedBuffer.readInt())); + Assert.assertEquals("Wrong reserved", message.getReserved().longValue(), serializedBuffer.readInt()); + } + + private static Capabilities createCapabilities(int input) { + final Boolean one = (input & (1 << 0)) > 0; + final Boolean two = (input & (1 << 1)) > 0; + final Boolean three = (input & (1 << 2)) > 0; + final Boolean four = (input & (1 << 3)) > 0; + final Boolean five = (input & (1 << 5)) > 0; + final Boolean six = (input & (1 << 6)) > 0; + final Boolean seven = (input & (1 << 8)) > 0; + return new Capabilities(one, four, five, seven, three, six, two); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java new file mode 100644 index 00000000..0db9c8da --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloMessageFactoryTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class HelloMessageFactoryTest { + private static final byte MESSAGE_TYPE = 0; + private OFSerializer factory; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, HelloMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + HelloMessageBuilder builder = new HelloMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + HelloMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 8); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java new file mode 100644 index 00000000..05a106a0 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java @@ -0,0 +1,1496 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class MultipartReplyMessageFactoryTest { + private static final byte MESSAGE_TYPE = 19; + private static final byte PADDING = 4; + + private OFSerializer factory; + + @Before + public void startUp() throws Exception { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartReplyMessage.class)); + } + + @Test + public void testMultipartRequestTableFeaturesMessageFactory() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(12)); + MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder(); + MultipartReplyTableFeaturesBuilder featuresBuilder = new MultipartReplyTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }); + tableFeaturesBuilder.setMetadataWrite(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); + NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + List nextIds = new ArrayList<>(); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); + nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + nextIds = new ArrayList<>(); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); + InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + List insIds = new ArrayList<>(); + InstructionBuilder insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build()); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); + insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + insIds = new ArrayList<>(); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build()); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build()); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new MeterCaseBuilder().build()); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build()); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build()); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + byte[] metadataMatch = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }; + tableFeaturesBuilder.setMetadataMatch(metadataMatch); + byte[] metadataWrite = new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }; + tableFeaturesBuilder.setMetadataWrite(metadataWrite); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(67L); + properties = new ArrayList<>(); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); + ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new OutputActionCaseBuilder().build()); + actions.add(actionBuilder.build()); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); + OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpProto.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntry(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartReplyTableFeatures(featuresBuilder.build()); + builder.setMultipartReplyBody(caseBuilder.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 520); + Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLEFEATURES.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + + Assert.assertEquals("Wrong length", 232, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32)); + byte[] metadataMatchOutput = new byte[metadataMatch.length]; + serializedBuffer.readBytes(metadataMatchOutput); + Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, + metadataMatchOutput); + serializedBuffer.skipBytes(64 - metadataMatch.length); + byte[] metadataWriteOutput = new byte[metadataWrite.length]; + serializedBuffer.readBytes(metadataWriteOutput); + Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, + metadataWriteOutput); + serializedBuffer.skipBytes(64 - metadataWrite.length); + Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 2, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 6, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong next-registry-id", 1, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong next-registry-id", 2, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong property type", 3, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 0, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 3, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 1, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 24, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 2, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 6, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 5, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong length", 272, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32)); + metadataMatchOutput = new byte[metadataMatch.length]; + serializedBuffer.readBytes(metadataMatchOutput); + serializedBuffer.skipBytes(64 - metadataMatch.length); + Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, + metadataMatchOutput); + metadataWriteOutput = new byte[metadataWrite.length]; + serializedBuffer.readBytes(metadataWriteOutput); + serializedBuffer.skipBytes(64 - metadataWrite.length); + Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, + metadataWriteOutput); + Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 67, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 8, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property type", 5, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 6, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 7, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 8, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 2, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 0, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 10, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 12, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 13, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 14, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 20, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 18, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong property type", 15, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(4); + Assert.assertTrue("Unread data", serializedBuffer.readableBytes() == 0); + } + + @Test + public void testPortDescSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(13)); + MultipartReplyPortDescCaseBuilder portDescCase = new MultipartReplyPortDescCaseBuilder(); + MultipartReplyPortDescBuilder portDesc = new MultipartReplyPortDescBuilder(); + portDesc.setPorts(createPortList()); + portDescCase.setMultipartReplyPortDesc(portDesc.build()); + builder.setMultipartReplyBody(portDescCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80); + Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTDESC.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyPortDescCase body = (MultipartReplyPortDescCase) message.getMultipartReplyBody(); + MultipartReplyPortDesc messageOutput = body.getMultipartReplyPortDesc(); + Ports port = messageOutput.getPorts().get(0); + Assert.assertEquals("Wrong PortNo", port.getPortNo().intValue(), serializedBuffer.readUnsignedInt()); + serializedBuffer.skipBytes(4); + byte[] address = new byte[6]; + serializedBuffer.readBytes(address); + Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), + new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); + serializedBuffer.skipBytes(2); + byte[] name = new byte[16]; + serializedBuffer.readBytes(name); + Assert.assertEquals("Wrong name", port.getName(), new String(name).trim()); + Assert.assertEquals("Wrong config", port.getConfig(), createPortConfig(serializedBuffer.readInt())); + Assert.assertEquals("Wrong state", port.getState(), createPortState(serializedBuffer.readInt())); + Assert.assertEquals("Wrong current", port.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong advertised", port.getAdvertisedFeatures(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong supported", port.getSupportedFeatures(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong peer", port.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong Current speed", port.getCurrSpeed().longValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong Max speed", port.getMaxSpeed().longValue(), serializedBuffer.readInt()); + } + + @Test + public void testMeterFeaturesSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(11)); + MultipartReplyMeterFeaturesCaseBuilder meterFeaturesCase = new MultipartReplyMeterFeaturesCaseBuilder(); + MultipartReplyMeterFeaturesBuilder meterFeatures = new MultipartReplyMeterFeaturesBuilder(); + meterFeatures.setMaxMeter(1L); + meterFeatures.setBandTypes(new MeterBandTypeBitmap(true, false)); + meterFeatures.setCapabilities(new MeterFlags(true, false, true, false)); + meterFeatures.setMaxBands((short) 1); + meterFeatures.setMaxColor((short) 1); + meterFeaturesCase.setMultipartReplyMeterFeatures(meterFeatures.build()); + builder.setMultipartReplyBody(meterFeaturesCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 30); + Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERFEATURES.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyMeterFeaturesCase body = (MultipartReplyMeterFeaturesCase) message.getMultipartReplyBody(); + MultipartReplyMeterFeatures messageOutput = body.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong max meter", messageOutput.getMaxMeter().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong band type", messageOutput.getBandTypes(), + createMeterBandTypeBitmap(serializedBuffer.readInt())); + Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), + createMeterFlags(serializedBuffer.readShort())); + Assert.assertEquals("Wrong max bands", messageOutput.getMaxBands().shortValue(), + serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong max color", messageOutput.getMaxColor().shortValue(), + serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(2); + } + + @Test + public void testMeterConfigSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(10)); + MultipartReplyMeterConfigCaseBuilder meterConfigCase = new MultipartReplyMeterConfigCaseBuilder(); + MultipartReplyMeterConfigBuilder meterConfigBuilder = new MultipartReplyMeterConfigBuilder(); + meterConfigBuilder.setMeterConfig(createMeterConfig()); + meterConfigCase.setMultipartReplyMeterConfig(meterConfigBuilder.build()); + builder.setMultipartReplyBody(meterConfigCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 48); + Assert.assertEquals("Wrong type", MultipartType.OFPMPMETERCONFIG.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyMeterConfigCase body = (MultipartReplyMeterConfigCase) message.getMultipartReplyBody(); + MultipartReplyMeterConfig messageOutput = body.getMultipartReplyMeterConfig(); + MeterConfig meterConfig = messageOutput.getMeterConfig().get(0); + Assert.assertEquals("Wrong len", 32, serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", meterConfig.getFlags(), createMeterFlags(serializedBuffer.readShort())); + Assert.assertEquals("Wrong meterId", meterConfig.getMeterId().getValue().intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong bands", meterConfig.getBands(), decodeBandsList(serializedBuffer)); + } + + @Test + public void testMeterSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(9)); + MultipartReplyMeterCaseBuilder meterCase = new MultipartReplyMeterCaseBuilder(); + MultipartReplyMeterBuilder meter = new MultipartReplyMeterBuilder(); + meter.setMeterStats(createMeterStats()); + meterCase.setMultipartReplyMeter(meter.build()); + builder.setMultipartReplyBody(meterCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 74); + Assert.assertEquals("Wrong type", MultipartType.OFPMPMETER.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyMeterCase body = (MultipartReplyMeterCase) message.getMultipartReplyBody(); + MultipartReplyMeter messageOutput = body.getMultipartReplyMeter(); + MeterStats meterStats = messageOutput.getMeterStats().get(0); + Assert.assertEquals("Wrong meterId", meterStats.getMeterId().getValue().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong len", 58, serializedBuffer.readInt()); + serializedBuffer.skipBytes(6); + Assert.assertEquals("Wrong flow count", meterStats.getFlowCount().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong packet in count", meterStats.getPacketInCount().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong byte in count", meterStats.getByteInCount().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong duration sec", meterStats.getDurationSec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", meterStats.getDurationNsec().intValue(), serializedBuffer.readInt()); + MeterBandStats meterBandStats = meterStats.getMeterBandStats().get(0); + Assert.assertEquals("Wrong packet in count", meterBandStats.getPacketBandCount().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong byte in count", meterBandStats.getByteBandCount().longValue(), + serializedBuffer.readLong()); + } + + @Test + public void testGroupFeaturesSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(8)); + MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder(); + MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder(); + feature.setTypes(new GroupTypes(true, false, true, false)); + feature.setCapabilities(new GroupCapabilities(true, false, true, true)); + List maxGroups = new ArrayList<>(); + maxGroups.add(1L); + maxGroups.add(2L); + maxGroups.add(3L); + maxGroups.add(4L); + feature.setMaxGroups(maxGroups); + feature.setActionsBitmap(createActionType()); + featureCase.setMultipartReplyGroupFeatures(feature.build()); + builder.setMultipartReplyBody(featureCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56); + Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody(); + MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt())); + Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), + createGroupCapabilities(serializedBuffer.readInt())); + Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), + createActionType(serializedBuffer.readInt())); + Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), + createActionType(serializedBuffer.readInt())); + Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), + createActionType(serializedBuffer.readInt())); + Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), + createActionType(serializedBuffer.readInt())); + } + + @Test + public void testGroupDescSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(7)); + MultipartReplyGroupDescCaseBuilder groupCase = new MultipartReplyGroupDescCaseBuilder(); + MultipartReplyGroupDescBuilder group = new MultipartReplyGroupDescBuilder(); + group.setGroupDesc(createGroupDesc()); + groupCase.setMultipartReplyGroupDesc(group.build()); + builder.setMultipartReplyBody(groupCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 64); + Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPDESC.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyGroupDescCase body = (MultipartReplyGroupDescCase) message.getMultipartReplyBody(); + MultipartReplyGroupDesc messageOutput = body.getMultipartReplyGroupDesc(); + GroupDesc groupDesc = messageOutput.getGroupDesc().get(0); + Assert.assertEquals("Wrong length", 48, serializedBuffer.readShort()); + Assert.assertEquals("Wrong type", groupDesc.getType().getIntValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertEquals("Wrong group id", groupDesc.getGroupId().getValue().intValue(), serializedBuffer.readInt()); + BucketsList bucketList = groupDesc.getBucketsList().get(0); + Assert.assertEquals("Wrong length", 40, serializedBuffer.readShort()); + Assert.assertEquals("Wrong weight", bucketList.getWeight().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong watch port", bucketList.getWatchPort().getValue().intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong watch group", bucketList.getWatchGroup().intValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(4); + + Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 45, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 55, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(6); + Assert.assertEquals("Wrong action type", 23, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 64, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(3); + Assert.assertTrue("Not all data were read", serializedBuffer.readableBytes() == 0); + } + + @Test + public void testGroupSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(6)); + MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder(); + MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder(); + group.setGroupStats(createGroupStats()); + groupCase.setMultipartReplyGroup(group.build()); + builder.setMultipartReplyBody(groupCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72); + Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUP.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyGroupCase body = (MultipartReplyGroupCase) message.getMultipartReplyBody(); + MultipartReplyGroup messageOutput = body.getMultipartReplyGroup(); + GroupStats groupStats = messageOutput.getGroupStats().get(0); + Assert.assertEquals("Wrong length", 56, serializedBuffer.readShort()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong group id", groupStats.getGroupId().getValue().intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong ref count", groupStats.getRefCount().intValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong Packet count", groupStats.getPacketCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", groupStats.getByteCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong duration sec", groupStats.getDurationSec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", groupStats.getDurationNsec().intValue(), serializedBuffer.readInt()); + BucketStats bucketStats = groupStats.getBucketStats().get(0); + Assert.assertEquals("Wrong Packet count", bucketStats.getPacketCount().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", bucketStats.getByteCount().longValue(), serializedBuffer.readLong()); + } + + @Test + public void testQueueSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(5)); + MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder(); + MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder(); + queue.setQueueStats(createQueueStats()); + queueCase.setMultipartReplyQueue(queue.build()); + builder.setMultipartReplyBody(queueCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56); + Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody(); + MultipartReplyQueue messageOutput = body.getMultipartReplyQueue(); + QueueStats queueStats = messageOutput.getQueueStats().get(0); + Assert.assertEquals("Wrong PortNo", queueStats.getPortNo().intValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong duration sec", queueStats.getDurationSec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", queueStats.getDurationNsec().intValue(), serializedBuffer.readInt()); + } + + @Test + public void testPortStatsSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(4)); + MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder(); + MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder(); + portStats.setPortStats(createPortStats()); + portStatsCase.setMultipartReplyPortStats(portStats.build()); + builder.setMultipartReplyBody(portStatsCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 128); + Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody(); + MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats(); + PortStats portStatsOutput = messageOutput.getPortStats().get(0); + Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(4); + Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong duration sec", portStatsOutput.getDurationSec().intValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", portStatsOutput.getDurationNsec().intValue(), + serializedBuffer.readInt()); + } + + @Test + public void testTableSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(3)); + MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder(); + MultipartReplyTableBuilder table = new MultipartReplyTableBuilder(); + table.setTableStats(createTableStats()); + tableCase.setMultipartReplyTable(table.build()); + builder.setMultipartReplyBody(tableCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40); + Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyTableCase body = (MultipartReplyTableCase) message.getMultipartReplyBody(); + MultipartReplyTable messageOutput = body.getMultipartReplyTable(); + TableStats tableStats = messageOutput.getTableStats().get(0); + Assert.assertEquals("Wrong tableId", tableStats.getTableId().shortValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(3); + Assert.assertEquals("Wrong active count", tableStats.getActiveCount().longValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong lookup count", tableStats.getLookupCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong matched count", tableStats.getMatchedCount().longValue(), + serializedBuffer.readLong()); + } + + @Test + public void testAggregateSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(2)); + MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder(); + MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder(); + aggregate.setPacketCount(BigInteger.valueOf(1L)); + aggregate.setByteCount(BigInteger.valueOf(1L)); + aggregate.setFlowCount(1L); + aggregateCase.setMultipartReplyAggregate(aggregate.build()); + builder.setMultipartReplyBody(aggregateCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40); + Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + MultipartReplyAggregateCase body = (MultipartReplyAggregateCase) message.getMultipartReplyBody(); + MultipartReplyAggregate messageOutput = body.getMultipartReplyAggregate(); + Assert.assertEquals("Wrong Packet count", messageOutput.getPacketCount().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", messageOutput.getByteCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Flow count", messageOutput.getFlowCount().longValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(4); + } + + @Test + public void testFlowSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(1)); + MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder(); + MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder(); + flow.setFlowStats(createFlowStats()); + flowCase.setMultipartReplyFlow(flow.build()); + builder.setMultipartReplyBody(flowCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 192); + Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + testFlowBody(message.getMultipartReplyBody(), serializedBuffer); + } + + @Test + public void testDescSerialize() throws Exception { + MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(0)); + MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder(); + MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder(); + desc.setMfrDesc("Test"); + desc.setHwDesc("Test"); + desc.setSwDesc("Test"); + desc.setSerialNum("12345"); + desc.setDpDesc("Test"); + descCase.setMultipartReplyDesc(desc.build()); + builder.setMultipartReplyBody(descCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 1072); + Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + serializedBuffer.skipBytes(PADDING); + Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer)); + } + + private static void testFlowBody(MultipartReplyBody body, ByteBuf output) { + MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; + MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); + FlowStats flowStats = flow.getFlowStats().get(0); + Assert.assertEquals("Wrong length", 176, output.readShort()); + Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), output.readUnsignedByte()); + output.skipBytes(1); + Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), output.readInt()); + Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), output.readInt()); + Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), output.readShort()); + Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), output.readShort()); + Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), output.readShort()); + output.skipBytes(6); + Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), output.readLong()); + Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), output.readLong()); + Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), output.readLong()); + Assert.assertEquals("Wrong match type", 1, output.readUnsignedShort()); + output.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort()); + short fieldAndMask = output.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1); + output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 42, output.readUnsignedInt()); + Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort()); + fieldAndMask = output.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1); + output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 4, output.readUnsignedByte()); + output.skipBytes(7); + Assert.assertEquals("Wrong instruction type", 1, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction table-id", 5, output.readUnsignedByte()); + output.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 2, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort()); + output.skipBytes(4); + byte[] actual = new byte[8]; + output.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", + ByteBufUtils.bytesToHexString(actual)); + actual = new byte[8]; + output.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", + ByteBufUtils.bytesToHexString(actual)); + Assert.assertEquals("Wrong instruction type", 5, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort()); + output.skipBytes(4); + Assert.assertEquals("Wrong instruction type", 6, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction meter-id", 42, output.readUnsignedInt()); + Assert.assertEquals("Wrong instruction type", 3, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 32, output.readUnsignedShort()); + output.skipBytes(4); + Assert.assertEquals("Wrong action type", 0, output.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, output.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 45, output.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 55, output.readUnsignedShort()); + output.skipBytes(6); + Assert.assertEquals("Wrong action type", 23, output.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 64, output.readUnsignedByte()); + output.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 4, output.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort()); + output.skipBytes(4); + Assert.assertEquals("Wrong action type", 17, output.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 14, output.readUnsignedShort()); + output.skipBytes(2); + Assert.assertEquals("Wrong action type", 27, output.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort()); + output.skipBytes(4); + Assert.assertTrue("Not all data were read", output.readableBytes() == 0); + } + + private static List createPortList() { + PortsBuilder builder = new PortsBuilder(); + builder.setPortNo(1L); + builder.setHwAddr(new MacAddress("94:de:80:a6:61:40")); + builder.setName("Port name"); + builder.setConfig(new PortConfig(true, false, true, false)); + builder.setState(new PortState(true, false, true)); + builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, + false, true, false, true, false)); + builder.setCurrSpeed(1234L); + builder.setMaxSpeed(1234L); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static PortConfig createPortConfig(long input) { + final Boolean _portDown = ((input) & (1 << 0)) > 0; + final Boolean _noRecv = ((input) & (1 << 2)) > 0; + final Boolean _noFwd = ((input) & (1 << 5)) > 0; + final Boolean _noPacketIn = ((input) & (1 << 6)) > 0; + return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown); + } + + private static PortFeatures createPortFeatures(long input) { + final Boolean _10mbHd = ((input) & (1 << 0)) > 0; + final Boolean _10mbFd = ((input) & (1 << 1)) > 0; + final Boolean _100mbHd = ((input) & (1 << 2)) > 0; + final Boolean _100mbFd = ((input) & (1 << 3)) > 0; + final Boolean _1gbHd = ((input) & (1 << 4)) > 0; + final Boolean _1gbFd = ((input) & (1 << 5)) > 0; + final Boolean _10gbFd = ((input) & (1 << 6)) > 0; + final Boolean _40gbFd = ((input) & (1 << 7)) > 0; + final Boolean _100gbFd = ((input) & (1 << 8)) > 0; + final Boolean _1tbFd = ((input) & (1 << 9)) > 0; + final Boolean _other = ((input) & (1 << 10)) > 0; + final Boolean _copper = ((input) & (1 << 11)) > 0; + final Boolean _fiber = ((input) & (1 << 12)) > 0; + final Boolean _autoneg = ((input) & (1 << 13)) > 0; + final Boolean _pause = ((input) & (1 << 14)) > 0; + final Boolean _pauseAsym = ((input) & (1 << 15)) > 0; + return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd, + _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym); + } + + private static PortState createPortState(long input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + return new PortState(two, one, three); + } + + private static List decodeBandsList(ByteBuf input) { + List bandsList = new ArrayList<>(); + BandsBuilder bandsBuilder = new BandsBuilder(); + MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder(); + MeterBandDropBuilder dropBand = new MeterBandDropBuilder(); + dropBand.setType(MeterBandType.forValue(input.readUnsignedShort())); + input.skipBytes(Short.SIZE / Byte.SIZE); + dropBand.setRate(input.readUnsignedInt()); + dropBand.setBurstSize(input.readUnsignedInt()); + dropCaseBuilder.setMeterBandDrop(dropBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build()); + MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); + MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder(); + dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort())); + input.skipBytes(Short.SIZE / Byte.SIZE); + dscpRemarkBand.setRate(input.readUnsignedInt()); + dscpRemarkBand.setBurstSize(input.readUnsignedInt()); + dscpRemarkBand.setPrecLevel((short) 3); + dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); + return bandsList; + } + + private static List createMeterConfig() { + MeterConfigBuilder builder = new MeterConfigBuilder(); + builder.setFlags(new MeterFlags(true, false, true, false)); + builder.setMeterId(new MeterId(1L)); + builder.setBands(createBandsList()); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static MeterBandTypeBitmap createMeterBandTypeBitmap(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + return new MeterBandTypeBitmap(one, two); + } + + private static List createBandsList() { + List bandsList = new ArrayList<>(); + BandsBuilder bandsBuilder = new BandsBuilder(); + MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder(); + MeterBandDropBuilder dropBand = new MeterBandDropBuilder(); + dropBand.setType(MeterBandType.OFPMBTDROP); + dropBand.setRate(1L); + dropBand.setBurstSize(2L); + dropCaseBuilder.setMeterBandDrop(dropBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build()); + MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder(); + MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder(); + dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK); + dscpRemarkBand.setRate(1L); + dscpRemarkBand.setBurstSize(2L); + dscpRemarkBand.setPrecLevel((short) 3); + dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build()); + bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build()); + return bandsList; + } + + private static MeterFlags createMeterFlags(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + final Boolean four = ((input) & (1 << 3)) > 0; + return new MeterFlags(three, one, two, four); + } + + private static List createMeterStats() { + MeterStatsBuilder builder = new MeterStatsBuilder(); + builder.setMeterId(new MeterId(1L)); + builder.setFlowCount(1L); + builder.setPacketInCount(BigInteger.valueOf(1L)); + builder.setByteInCount(BigInteger.valueOf(1L)); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + builder.setMeterBandStats(createMeterBandStats()); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createMeterBandStats() { + MeterBandStatsBuilder builder = new MeterBandStatsBuilder(); + builder.setPacketBandCount(BigInteger.valueOf(1L)); + builder.setByteBandCount(BigInteger.valueOf(1L)); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static ActionType createActionType(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + final Boolean four = ((input) & (1 << 3)) > 0; + final Boolean five = ((input) & (1 << 4)) > 0; + final Boolean six = ((input) & (1 << 5)) > 0; + final Boolean seven = ((input) & (1 << 6)) > 0; + final Boolean eight = ((input) & (1 << 7)) > 0; + final Boolean nine = ((input) & (1 << 8)) > 0; + final Boolean ten = ((input) & (1 << 9)) > 0; + final Boolean eleven = ((input) & (1 << 10)) > 0; + final Boolean twelve = ((input) & (1 << 11)) > 0; + final Boolean thirteen = ((input) & (1 << 12)) > 0; + final Boolean fourteen = ((input) & (1 << 13)) > 0; + final Boolean fifthteen = ((input) & (1 << 14)) > 0; + final Boolean sixteen = ((input) & (1 << 15)) > 0; + final Boolean seventeen = ((input) & (1 << 16)) > 0; + return new ActionType(three, two, five, thirteen, seventeen, eleven, one, nine, sixteen, seven, eight, + fifthteen, six, fourteen, four, twelve, ten); + } + + private static GroupCapabilities createGroupCapabilities(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + final Boolean four = ((input) & (1 << 3)) > 0; + return new GroupCapabilities(three, four, two, one); + } + + private static GroupTypes createGroupTypes(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + final Boolean four = ((input) & (1 << 3)) > 0; + return new GroupTypes(one, four, three, two); + } + + private static List createActionType() { + ActionType actionType1 = new ActionType(true, false, true, false, true, false, true, false, true, false, true, + false, true, false, true, false, true); + ActionType actionType2 = new ActionType(true, false, false, false, true, false, true, false, true, false, true, + false, true, false, true, true, true); + ActionType actionType3 = new ActionType(true, false, true, false, true, false, true, false, true, false, true, + false, true, false, true, false, true); + ActionType actionType4 = new ActionType(true, false, true, false, true, false, true, false, true, false, true, + false, true, false, true, false, true); + List list = new ArrayList<>(); + list.add(actionType1); + list.add(actionType2); + list.add(actionType3); + list.add(actionType4); + return list; + + } + + private static List createGroupDesc() { + GroupDescBuilder builder = new GroupDescBuilder(); + builder.setType(GroupType.forValue(1)); + builder.setGroupId(new GroupId(1L)); + builder.setBucketsList(createBucketsList()); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createGroupStats() { + GroupStatsBuilder builder = new GroupStatsBuilder(); + builder.setGroupId(new GroupId(1L)); + builder.setRefCount(1L); + builder.setPacketCount(BigInteger.valueOf(1L)); + builder.setByteCount(BigInteger.valueOf(1L)); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + builder.setBucketStats(createBucketStats()); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createBucketsList() { + BucketsListBuilder builder = new BucketsListBuilder(); + builder.setWeight(1); + builder.setWatchPort(new PortNumber(1L)); + builder.setWatchGroup(1L); + builder.setAction(createActionList()); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createActionList() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(45L)); + outputBuilder.setMaxLength(55); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder(); + SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder(); + ttlActionBuilder.setNwTtl((short) 64); + ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build()); + actionBuilder.setActionChoice(ttlCaseBuilder.build()); + actions.add(actionBuilder.build()); + return actions; + } + + private static List createBucketStats() { + BucketStatsBuilder builder = new BucketStatsBuilder(); + builder.setPacketCount(BigInteger.valueOf(1L)); + builder.setByteCount(BigInteger.valueOf(1L)); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createQueueStats() { + QueueStatsBuilder builder = new QueueStatsBuilder(); + builder.setPortNo(1L); + builder.setQueueId(1L); + builder.setTxBytes(BigInteger.valueOf(1L)); + builder.setTxPackets(BigInteger.valueOf(1L)); + builder.setTxErrors(BigInteger.valueOf(1L)); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createPortStats() { + PortStatsBuilder builder = new PortStatsBuilder(); + builder.setPortNo(1L); + builder.setRxPackets(BigInteger.valueOf(1L)); + builder.setTxPackets(BigInteger.valueOf(1L)); + builder.setRxBytes(BigInteger.valueOf(1L)); + builder.setTxBytes(BigInteger.valueOf(1L)); + builder.setRxDropped(BigInteger.valueOf(1L)); + builder.setTxDropped(BigInteger.valueOf(1L)); + builder.setRxErrors(BigInteger.valueOf(1L)); + builder.setTxErrors(BigInteger.valueOf(1L)); + builder.setRxFrameErr(BigInteger.valueOf(1L)); + builder.setRxOverErr(BigInteger.valueOf(1L)); + builder.setRxCrcErr(BigInteger.valueOf(1L)); + builder.setCollisions(BigInteger.valueOf(1L)); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + List list = new ArrayList(); + list.add(builder.build()); + return list; + } + + private static List createTableStats() { + TableStatsBuilder builder = new TableStatsBuilder(); + builder.setTableId((short) 1); + builder.setActiveCount(1L); + builder.setLookupCount(BigInteger.valueOf(1L)); + builder.setMatchedCount(BigInteger.valueOf(1L)); + List list = new ArrayList(); + list.add(builder.build()); + return list; + } + + private static List createFlowStats() { + FlowStatsBuilder builder = new FlowStatsBuilder(); + builder.setTableId((short) 1); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + builder.setPriority(1); + builder.setIdleTimeout(1); + builder.setHardTimeout(1); + builder.setCookie(BigInteger.valueOf(1234L)); + builder.setPacketCount(BigInteger.valueOf(1234L)); + builder.setByteCount(BigInteger.valueOf(1234L)); + MatchBuilder matchBuilder = new MatchBuilder(); + matchBuilder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(42L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); + entries.add(entriesBuilder.build()); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 4); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); + entries.add(entriesBuilder.build()); + matchBuilder.setMatchEntry(entries); + builder.setMatch(matchBuilder.build()); + List instructions = new ArrayList<>(); + // Goto_table instruction + InstructionBuilder builderInstruction = new InstructionBuilder(); + GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder(); + GotoTableBuilder instructionBuilder = new GotoTableBuilder(); + instructionBuilder.setTableId((short) 5); + gotoCaseBuilder.setGotoTable(instructionBuilder.build()); + builderInstruction.setInstructionChoice(gotoCaseBuilder.build()); + instructions.add(builderInstruction.build()); + // Write_metadata instruction + builderInstruction = new InstructionBuilder(); + WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder(); + WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder(); + metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); + metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); + metadataCaseBuilder.setWriteMetadata(metadataBuilder.build()); + builderInstruction.setInstructionChoice(metadataCaseBuilder.build()); + instructions.add(builderInstruction.build()); + // Clear_actions instruction + builderInstruction = new InstructionBuilder(); + builderInstruction.setInstructionChoice(new ClearActionsCaseBuilder().build()); + instructions.add(builderInstruction.build()); + // Meter instruction + builderInstruction = new InstructionBuilder(); + MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder(); + MeterBuilder meterBuilder = new MeterBuilder(); + meterBuilder.setMeterId(42L); + meterCaseBuilder.setMeter(meterBuilder.build()); + builderInstruction.setInstructionChoice(meterCaseBuilder.build()); + instructions.add(builderInstruction.build()); + // Write_actions instruction + builderInstruction = new InstructionBuilder(); + WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder(); + WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(45L)); + outputBuilder.setMaxLength(55); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder(); + SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder(); + ttlActionBuilder.setNwTtl((short) 64); + ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build()); + actionBuilder.setActionChoice(ttlCaseBuilder.build()); + actions.add(actionBuilder.build()); + writeActionsBuilder.setAction(actions); + writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build()); + builderInstruction.setInstructionChoice(writeActionsCaseBuilder.build()); + instructions.add(builderInstruction.build()); + // Apply_actions instruction + builderInstruction = new InstructionBuilder(); + ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder(); + ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder(); + actions = new ArrayList<>(); + actionBuilder = new ActionBuilder(); + PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder(); + PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder(); + vlanBuilder.setEthertype(new EtherType(new EtherType(14))); + vlanCaseBuilder.setPushVlanAction(vlanBuilder.build()); + actionBuilder.setActionChoice(vlanCaseBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setActionChoice(new PopPbbCaseBuilder().build()); + actions.add(actionBuilder.build()); + applyActionsBuilder.setAction(actions); + applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build()); + builderInstruction.setInstructionChoice(applyActionsCaseBuilder.build()); + instructions.add(builderInstruction.build()); + builder.setInstruction(instructions); + List list = new ArrayList(); + list.add(builder.build()); + return list; + } + + private static MultipartRequestFlags createMultipartRequestFlags(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + return new MultipartRequestFlags(one); + } + + private static MultipartReplyDescCase decodeDescBody(ByteBuf output) { + MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder(); + MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder(); + byte[] mfrDesc = new byte[256]; + output.readBytes(mfrDesc); + desc.setMfrDesc(new String(mfrDesc).trim()); + byte[] hwDesc = new byte[256]; + output.readBytes(hwDesc); + desc.setHwDesc(new String(hwDesc).trim()); + byte[] swDesc = new byte[256]; + output.readBytes(swDesc); + desc.setSwDesc(new String(swDesc).trim()); + byte[] serialNumber = new byte[32]; + output.readBytes(serialNumber); + desc.setSerialNum(new String(serialNumber).trim()); + byte[] dpDesc = new byte[256]; + output.readBytes(dpDesc); + desc.setDpDesc(new String(dpDesc).trim()); + descCase.setMultipartReplyDesc(desc.build()); + return descCase.build(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java new file mode 100644 index 00000000..7ec4e446 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10BarrierReplyMessageFactoryTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10BarrierReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 19; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + BarrierOutputBuilder builder = new BarrierOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + BarrierOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 8); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java new file mode 100644 index 00000000..dc2758bc --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FeaturesReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 6; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetFeaturesOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setDatapathId(BigInteger.valueOf(1L)); + builder.setBuffers(1L); + builder.setTables((short) 1); + builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false)); + builder.setActionsV10( + new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true)); + builder.setPhyPort(createPorts()); + GetFeaturesOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80); + Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(3); + Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), + createCapabilities(serializedBuffer.readInt())); + Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt())); + PhyPort port = message.getPhyPort().get(0); + Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort()); + byte[] address = new byte[6]; + serializedBuffer.readBytes(address); + Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), + new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); + byte[] name = new byte[16]; + serializedBuffer.readBytes(name); + Assert.assertEquals("Wrong name", port.getName(), new String(name).trim()); + Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt())); + Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt())); + Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); + + } + + private static List createPorts() { + List ports = new ArrayList<>(); + PhyPortBuilder builder = new PhyPortBuilder(); + builder.setPortNo(1L); + builder.setHwAddr(new MacAddress("94:de:80:a6:61:40")); + builder.setName("Port name"); + builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true)); + builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false)); + builder.setCurrentFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setAdvertisedFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setSupportedFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setPeerFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + ports.add(builder.build()); + return ports; + } + + private static PortConfigV10 createPortConfig(long input) { + final Boolean _portDown = ((input) & (1 << 0)) > 0; + final Boolean _noStp = ((input) & (1 << 1)) > 0; + final Boolean _noRecv = ((input) & (1 << 2)) > 0; + final Boolean _noRecvStp = ((input) & (1 << 3)) > 0; + final Boolean _noFlood = ((input) & (1 << 4)) > 0; + final Boolean _noFwd = ((input) & (1 << 5)) > 0; + final Boolean _noPacketIn = ((input) & (1 << 6)) > 0; + return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); + } + + private static PortFeaturesV10 createPortFeatures(long input) { + final Boolean _10mbHd = ((input) & (1 << 0)) > 0; + final Boolean _10mbFd = ((input) & (1 << 1)) > 0; + final Boolean _100mbHd = ((input) & (1 << 2)) > 0; + final Boolean _100mbFd = ((input) & (1 << 3)) > 0; + final Boolean _1gbHd = ((input) & (1 << 4)) > 0; + final Boolean _1gbFd = ((input) & (1 << 5)) > 0; + final Boolean _10gbFd = ((input) & (1 << 6)) > 0; + final Boolean _copper = ((input) & (1 << 7)) > 0; + final Boolean _fiber = ((input) & (1 << 8)) > 0; + final Boolean _autoneg = ((input) & (1 << 9)) > 0; + final Boolean _pause = ((input) & (1 << 10)) > 0; + final Boolean _pauseAsym = ((input) & (1 << 11)) > 0; + return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper, + _fiber, _pause, _pauseAsym); + } + + private static PortStateV10 createPortState(long input) { + final Boolean _linkDown = ((input) & (1 << 0)) > 0; + final Boolean _blocked = ((input) & (1 << 1)) > 0; + final Boolean _live = ((input) & (1 << 2)) > 0; + final Boolean _stpListen = ((input) & (1 << 3)) > 0; + final Boolean _stpLearn = ((input) & (1 << 4)) > 0; + final Boolean _stpForward = ((input) & (1 << 5)) > 0; + final Boolean _stpBlock = ((input) & (1 << 6)) > 0; + final Boolean _stpMask = ((input) & (1 << 7)) > 0; + return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); + } + + private static CapabilitiesV10 createCapabilities(long input) { + Boolean _oFPCFLOWSTATS = ((input) & (1 << 0)) > 0; + Boolean _oFPCTABLESTATS = ((input) & (1 << 1)) > 0; + Boolean _oFPCPORTSTATS = ((input) & (1 << 2)) > 0; + Boolean _oFPCSTP = ((input) & (1 << 3)) > 0; + Boolean _oFPCRESERVED = ((input) & (1 << 4)) > 0; + Boolean _oFPCIPREASM = ((input) & (1 << 5)) > 0; + Boolean _oFPCQUEUESTATS = ((input) & (1 << 6)) > 0; + Boolean _oFPCARPMATCHIP = ((input) & (1 << 7)) > 0; + return new CapabilitiesV10(_oFPCARPMATCHIP, _oFPCFLOWSTATS, _oFPCIPREASM, _oFPCPORTSTATS, _oFPCQUEUESTATS, + _oFPCRESERVED, _oFPCSTP, _oFPCTABLESTATS); + } + + private static ActionTypeV10 createActionsV10(long input) { + Boolean _oFPATOUTPUT = ((input) & (1 << 0)) > 0; + Boolean _oFPATSETVLANVID = ((input) & (1 << 1)) > 0; + Boolean _oFPATSETVLANPCP = ((input) & (1 << 2)) > 0; + Boolean _oFPATSTRIPVLAN = ((input) & (1 << 3)) > 0; + Boolean _oFPATSETDLSRC = ((input) & (1 << 4)) > 0; + Boolean _oFPATSETDLDST = ((input) & (1 << 5)) > 0; + Boolean _oFPATSETNWSRC = ((input) & (1 << 6)) > 0; + Boolean _oFPATSETNWDST = ((input) & (1 << 7)) > 0; + Boolean _oFPATSETNWTOS = ((input) & (1 << 8)) > 0; + Boolean _oFPATSETTPSRC = ((input) & (1 << 9)) > 0; + Boolean _oFPATSETTPDST = ((input) & (1 << 10)) > 0; + Boolean _oFPATENQUEUE = ((input) & (1 << 11)) > 0; + Boolean _oFPATVENDOR = ((input) & (1 << 12)) > 0; + return new ActionTypeV10(_oFPATENQUEUE, _oFPATOUTPUT, _oFPATSETDLDST, _oFPATSETDLSRC, _oFPATSETNWDST, + _oFPATSETNWSRC, _oFPATSETNWTOS, _oFPATSETTPDST, _oFPATSETTPSRC, _oFPATSETVLANPCP, _oFPATSETVLANVID, + _oFPATSTRIPVLAN, _oFPATVENDOR); + + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java new file mode 100644 index 00000000..fdd24fe9 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10FlowRemovedMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 11; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, FlowRemovedMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); + matchBuilder.setNwSrcMask((short) 0); + matchBuilder.setNwDstMask((short) 0); + matchBuilder.setInPort(58); + matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01")); + matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff")); + matchBuilder.setDlVlan(18); + matchBuilder.setDlVlanPcp((short) 5); + matchBuilder.setDlType(42); + matchBuilder.setNwTos((short) 4); + matchBuilder.setNwProto((short) 7); + matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8")); + matchBuilder.setNwDst(new Ipv4Address("16.16.16.16")); + matchBuilder.setTpSrc(6653); + matchBuilder.setTpDst(6633); + builder.setMatchV10(matchBuilder.build()); + byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 }; + builder.setCookie(new BigInteger(1, cookie)); + builder.setPriority(1); + builder.setReason(FlowRemovedReason.forValue(1)); + builder.setDurationSec(1L); + builder.setDurationNsec(1L); + builder.setIdleTimeout(12); + builder.setPacketCount(BigInteger.valueOf(1L)); + builder.setByteCount(BigInteger.valueOf(2L)); + FlowRemovedMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88); + Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + serializedBuffer.readBytes(dlSrc); + Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + serializedBuffer.readBytes(dlDst); + Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort()); + byte[] cookieRead = new byte[8]; + serializedBuffer.readBytes(cookieRead); + Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead); + Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong()); + Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java new file mode 100644 index 00000000..5d3c3a8d --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PacketInMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 10; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, PacketInMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + PacketInMessageBuilder builder = new PacketInMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setBufferId(1L); + builder.setTotalLen(1); + builder.setInPort(1); + builder.setReason(PacketInReason.forValue(0)); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + builder.setData(data); + PacketInMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 34); + Assert.assertEquals("Wrong buffer id", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong total len", message.getTotalLen().intValue(), serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong port in", message.getInPort().intValue(), serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertArrayEquals("Wrong data", message.getData(), + serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java new file mode 100644 index 00000000..8f97bc89 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10PortStatusMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 12; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, PortStatusMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setReason(PortReason.forValue(1)); + builder.setPortNo(1L); + builder.setHwAddr(new MacAddress("94:de:80:a6:61:40")); + builder.setName("Port name"); + builder.setConfigV10(new PortConfigV10(true, false, true, false, true, false, true)); + builder.setStateV10(new PortStateV10(true, false, true, false, true, false, true, false)); + builder.setCurrentFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setAdvertisedFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setSupportedFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + builder.setPeerFeaturesV10( + new PortFeaturesV10(true, false, true, false, true, false, true, false, true, false, true, false)); + PortStatusMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 64); + Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(7); + Assert.assertEquals("Wrong port No", message.getPortNo().intValue(), serializedBuffer.readShort()); + byte[] address = new byte[6]; + serializedBuffer.readBytes(address); + Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), + new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); + byte[] name = new byte[16]; + serializedBuffer.readBytes(name); + Assert.assertEquals("Wrong name", message.getName(), new String(name).trim()); + Assert.assertEquals("Wrong config", message.getConfigV10(), createPortConfig(serializedBuffer.readInt())); + Assert.assertEquals("Wrong state", message.getStateV10(), createPortState(serializedBuffer.readInt())); + Assert.assertEquals("Wrong current", message.getCurrentFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong advertised", message.getAdvertisedFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong supported", message.getSupportedFeaturesV10(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong peer", message.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); + } + + private static PortConfigV10 createPortConfig(long input) { + final Boolean _portDown = ((input) & (1 << 0)) > 0; + final Boolean _noStp = ((input) & (1 << 1)) > 0; + final Boolean _noRecv = ((input) & (1 << 2)) > 0; + final Boolean _noRecvStp = ((input) & (1 << 3)) > 0; + final Boolean _noFlood = ((input) & (1 << 4)) > 0; + final Boolean _noFwd = ((input) & (1 << 5)) > 0; + final Boolean _noPacketIn = ((input) & (1 << 6)) > 0; + return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); + } + + private static PortFeaturesV10 createPortFeatures(long input) { + final Boolean _10mbHd = ((input) & (1 << 0)) > 0; + final Boolean _10mbFd = ((input) & (1 << 1)) > 0; + final Boolean _100mbHd = ((input) & (1 << 2)) > 0; + final Boolean _100mbFd = ((input) & (1 << 3)) > 0; + final Boolean _1gbHd = ((input) & (1 << 4)) > 0; + final Boolean _1gbFd = ((input) & (1 << 5)) > 0; + final Boolean _10gbFd = ((input) & (1 << 6)) > 0; + final Boolean _copper = ((input) & (1 << 7)) > 0; + final Boolean _fiber = ((input) & (1 << 8)) > 0; + final Boolean _autoneg = ((input) & (1 << 9)) > 0; + final Boolean _pause = ((input) & (1 << 10)) > 0; + final Boolean _pauseAsym = ((input) & (1 << 11)) > 0; + return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper, + _fiber, _pause, _pauseAsym); + } + + private static PortStateV10 createPortState(long input) { + final Boolean _linkDown = ((input) & (1 << 0)) > 0; + final Boolean _blocked = ((input) & (1 << 1)) > 0; + final Boolean _live = ((input) & (1 << 2)) > 0; + final Boolean _stpListen = ((input) & (1 << 3)) > 0; + final Boolean _stpLearn = ((input) & (1 << 4)) > 0; + final Boolean _stpForward = ((input) & (1 << 5)) > 0; + final Boolean _stpBlock = ((input) & (1 << 6)) > 0; + final Boolean _stpMask = ((input) & (1 << 7)) > 0; + return new PortStateV10(_blocked, _linkDown, _live, _stpBlock, _stpForward, _stpLearn, _stpListen, _stpMask); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java new file mode 100644 index 00000000..c46d03d7 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10QueueGetConfigReplyMessageFactoryTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10QueueGetConfigReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 21; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, GetQueueConfigOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setPort(new PortNumber(1L)); + builder.setQueues(createQueues()); + GetQueueConfigOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40); + Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort()); + serializedBuffer.skipBytes(6); + Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort()); + serializedBuffer.skipBytes(2); + List properties = message.getQueues().get(0).getQueueProperty(); + Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), + serializedBuffer.readShort()); + Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort()); + serializedBuffer.skipBytes(4); + RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class); + Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort()); + serializedBuffer.skipBytes(6); + } + + private List createQueues() { + List list = new ArrayList<>(); + QueuesBuilder builder = new QueuesBuilder(); + builder.setQueueId(new QueueId(1L)); + builder.setQueueProperty(createPropertiesList()); + + list.add(builder.build()); + return list; + } + + private static List createPropertiesList() { + List propertiesList = new ArrayList<>(); + QueuePropertyBuilder pb = new QueuePropertyBuilder(); + pb.setProperty(QueueProperties.forValue(1)); + RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder(); + rateBuilder.setRate(5); + pb.addAugmentation(RateQueueProperty.class, rateBuilder.build()); + propertiesList.add(pb.build()); + return propertiesList; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java new file mode 100644 index 00000000..eff1c0fe --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -0,0 +1,413 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class OF10StatsReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 17; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartReplyMessage.class)); + } + + @Test + public void testDescBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(0)); + MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder(); + MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder(); + desc.setMfrDesc("Test"); + desc.setHwDesc("Test"); + desc.setSwDesc("Test"); + desc.setSerialNum("12345"); + desc.setDpDesc("Test"); + descCase.setMultipartReplyDesc(desc.build()); + builder.setMultipartReplyBody(descCase.build()); + MultipartReplyMessage message = builder.build(); + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 1068); + Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer)); + } + + @Test + public void testFlowBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(1)); + MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder(); + MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder(); + flow.setFlowStats(createFlowStats()); + flowCase.setMultipartReplyFlow(flow.build()); + builder.setMultipartReplyBody(flowCase.build()); + MultipartReplyMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 108); + Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + FlowStats flowStats = flow.getFlowStats().get(0); + Assert.assertEquals("Wrong length", 96, serializedBuffer.readShort()); + Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + serializedBuffer.readBytes(dlSrc); + Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + serializedBuffer.readBytes(dlDst); + Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(1); + Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), serializedBuffer.readShort()); + serializedBuffer.skipBytes(6); + Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong port", 42, serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong maxlength", 50, serializedBuffer.readUnsignedShort()); + } + + @Test + public void testAggregateBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(2)); + MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder(); + MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder(); + aggregate.setPacketCount(BigInteger.valueOf(1234L)); + aggregate.setByteCount(BigInteger.valueOf(1234L)); + aggregate.setFlowCount(1L); + aggregateCase.setMultipartReplyAggregate(aggregate.build()); + builder.setMultipartReplyBody(aggregateCase.build()); + MultipartReplyMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 36); + Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + Assert.assertEquals("Wrong Packet count", 1234L, serializedBuffer.readLong()); + Assert.assertEquals("Wrong Byte count", 1234L, serializedBuffer.readLong()); + Assert.assertEquals("Wrong flow count", 1L, serializedBuffer.readInt()); + serializedBuffer.skipBytes(4); + } + + @Test + public void testTableBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(3)); + MultipartReplyTableCaseBuilder tableCase = new MultipartReplyTableCaseBuilder(); + MultipartReplyTableBuilder table = new MultipartReplyTableBuilder(); + table.setTableStats(createTableStats()); + tableCase.setMultipartReplyTable(table.build()); + builder.setMultipartReplyBody(tableCase.build()); + MultipartReplyMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 60); + Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + Assert.assertEquals("Wrong table id", 1, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(3); + Assert.assertEquals("Wrong name", "Table name", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 16)); + Assert.assertEquals("Wrong wildcards", 3145983, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong max entries", 1L, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong active count", 1L, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong lookup count", 1234L, serializedBuffer.readLong()); + Assert.assertEquals("Wrong matched count", 1234L, serializedBuffer.readLong()); + } + + @Test + public void testPortStatsBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(4)); + MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder(); + MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder(); + portStats.setPortStats(createPortStats()); + portStatsCase.setMultipartReplyPortStats(portStats.build()); + builder.setMultipartReplyBody(portStatsCase.build()); + MultipartReplyMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 118); + Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody(); + MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats(); + PortStats portStatsOutput = messageOutput.getPortStats().get(0); + Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(6); + Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(), + serializedBuffer.readLong()); + Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(), + serializedBuffer.readLong()); + } + + @Test + public void testQueueBodySerialize() throws Exception { + MultipartReplyMessageBuilder builder; + builder = new MultipartReplyMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setFlags(new MultipartRequestFlags(true)); + builder.setType(MultipartType.forValue(5)); + MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder(); + MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder(); + queue.setQueueStats(createQueueStats()); + queueCase.setMultipartReplyQueue(queue.build()); + builder.setMultipartReplyBody(queueCase.build()); + MultipartReplyMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 44); + Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort()); + Assert.assertEquals("Wrong flags", message.getFlags(), + createMultipartRequestFlags(serializedBuffer.readShort())); + MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody(); + MultipartReplyQueue messageOutput = body.getMultipartReplyQueue(); + QueueStats queueStats = messageOutput.getQueueStats().get(0); + Assert.assertEquals("Wrong length", 32, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(2); + Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong()); + Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong()); + } + + private static List createQueueStats() { + QueueStatsBuilder builder = new QueueStatsBuilder(); + builder.setQueueId(1L); + builder.setTxBytes(BigInteger.valueOf(1L)); + builder.setTxPackets(BigInteger.valueOf(1L)); + builder.setTxErrors(BigInteger.valueOf(1L)); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createPortStats() { + PortStatsBuilder builder = new PortStatsBuilder(); + builder.setPortNo(1L); + builder.setRxPackets(BigInteger.valueOf(1L)); + builder.setTxPackets(BigInteger.valueOf(1L)); + builder.setRxBytes(BigInteger.valueOf(1L)); + builder.setTxBytes(BigInteger.valueOf(1L)); + builder.setRxDropped(BigInteger.valueOf(1L)); + builder.setTxDropped(BigInteger.valueOf(1L)); + builder.setRxErrors(BigInteger.valueOf(1L)); + builder.setTxErrors(BigInteger.valueOf(1L)); + builder.setRxFrameErr(BigInteger.valueOf(1L)); + builder.setRxOverErr(BigInteger.valueOf(1L)); + builder.setRxCrcErr(BigInteger.valueOf(1L)); + builder.setCollisions(BigInteger.valueOf(1L)); + List list = new ArrayList(); + list.add(builder.build()); + return list; + } + + private static List createTableStats() { + TableStatsBuilder builder = new TableStatsBuilder(); + builder.setTableId((short) 1); + builder.setName("Table name"); + builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); + builder.setMaxEntries(1L); + builder.setActiveCount(1L); + builder.setLookupCount(BigInteger.valueOf(1234L)); + builder.setMatchedCount(BigInteger.valueOf(1234L)); + List list = new ArrayList<>(); + list.add(builder.build()); + return list; + } + + private static List createFlowStats() { + FlowStatsBuilder builder = new FlowStatsBuilder(); + builder.setTableId((short) 1); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); + matchBuilder.setNwSrcMask((short) 0); + matchBuilder.setNwDstMask((short) 0); + matchBuilder.setInPort(58); + matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01")); + matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff")); + matchBuilder.setDlVlan(18); + matchBuilder.setDlVlanPcp((short) 5); + matchBuilder.setDlType(42); + matchBuilder.setNwTos((short) 4); + matchBuilder.setNwProto((short) 7); + matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8")); + matchBuilder.setNwDst(new Ipv4Address("16.16.16.16")); + matchBuilder.setTpSrc(6653); + matchBuilder.setTpDst(6633); + builder.setMatchV10(matchBuilder.build()); + builder.setDurationSec(1L); + builder.setDurationNsec(2L); + builder.setPriority(1); + builder.setIdleTimeout(1); + builder.setHardTimeout(1); + builder.setCookie(BigInteger.valueOf(1234L)); + builder.setPacketCount(BigInteger.valueOf(1234L)); + builder.setByteCount(BigInteger.valueOf(1234L)); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); + OutputActionBuilder outputBuilder = new OutputActionBuilder(); + outputBuilder.setPort(new PortNumber(42L)); + outputBuilder.setMaxLength(50); + caseBuilder.setOutputAction(outputBuilder.build()); + actionBuilder.setActionChoice(caseBuilder.build()); + actions.add(actionBuilder.build()); + builder.setAction(actions); + List list = new ArrayList(); + list.add(builder.build()); + return list; + } + + private static MultipartRequestFlags createMultipartRequestFlags(int input) { + final Boolean one = ((input) & (1 << 0)) > 0; + return new MultipartRequestFlags(one); + } + + private static MultipartReplyDescCase decodeDescBody(ByteBuf output) { + MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder(); + MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder(); + byte[] mfrDesc = new byte[256]; + output.readBytes(mfrDesc); + desc.setMfrDesc(new String(mfrDesc).trim()); + byte[] hwDesc = new byte[256]; + output.readBytes(hwDesc); + desc.setHwDesc(new String(hwDesc).trim()); + byte[] swDesc = new byte[256]; + output.readBytes(swDesc); + desc.setSwDesc(new String(swDesc).trim()); + byte[] serialNumber = new byte[32]; + output.readBytes(serialNumber); + desc.setSerialNum(new String(serialNumber).trim()); + byte[] dpDesc = new byte[256]; + output.readBytes(dpDesc); + desc.setDpDesc(new String(dpDesc).trim()); + descCase.setMultipartReplyDesc(desc.build()); + return descCase.build(); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java new file mode 100644 index 00000000..550e9c72 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PacketInMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 10; + private static final byte PADDING = 2; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PacketInMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + PacketInMessageBuilder builder = new PacketInMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setBufferId(256L); + builder.setTotalLen(10); + builder.setReason(PacketInReason.forValue(0)); + builder.setTableId(new TableId(1L)); + byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 }; + builder.setCookie(new BigInteger(1, cookie)); + MatchBuilder matchBuilder = new MatchBuilder(); + matchBuilder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntryBuilder entriesBuilder = new MatchEntryBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder(); + InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); + inPhyPortBuilder.setPortNumber(new PortNumber(42L)); + inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build()); + entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build()); + entries.add(entriesBuilder.build()); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder(); + IpEcnBuilder ipEcnBuilder = new IpEcnBuilder(); + ipEcnBuilder.setEcn((short) 4); + ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build()); + entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build()); + entries.add(entriesBuilder.build()); + matchBuilder.setMatchEntry(entries); + builder.setMatch(matchBuilder.build()); + byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"); + builder.setData(data); + PacketInMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 66); + Assert.assertEquals("Wrong BufferId", message.getBufferId().longValue(), serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong actions length", message.getTotalLen().intValue(), + serializedBuffer.readUnsignedShort()); + Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); + Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), + serializedBuffer.readUnsignedByte()); + cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + serializedBuffer.readBytes(cookie); + Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie)); + Assert.assertEquals("Wrong match type", 1, serializedBuffer.readUnsignedShort()); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); + short fieldAndMask = serializedBuffer.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 42, serializedBuffer.readUnsignedInt()); + Assert.assertEquals("Wrong oxm class", 0x8000, serializedBuffer.readUnsignedShort()); + fieldAndMask = serializedBuffer.readUnsignedByte(); + Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1); + Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1); + serializedBuffer.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(7); + serializedBuffer.skipBytes(PADDING); + Assert.assertArrayEquals("Wrong data", message.getData(), + serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java new file mode 100644 index 00000000..dd872501 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class PortStatusMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 12; + private static final byte PADDING = 7; + private static final byte PORT_PADDING_1 = 4; + private static final byte PORT_PADDING_2 = 2; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, PortStatusMessage.class)); + } + + @Test + public void testSerialize() throws Exception { + PortStatusMessageBuilder builder = new PortStatusMessageBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setReason(PortReason.forValue(1)); + builder.setPortNo(1L); + builder.setHwAddr(new MacAddress("94:de:80:a6:61:40")); + builder.setName("Port name"); + builder.setConfig(new PortConfig(true, false, true, false)); + builder.setState(new PortState(true, false, true)); + builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, + true, false, true, false, true, false)); + builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, + false, true, false, true, false)); + builder.setCurrSpeed(1234L); + builder.setMaxSpeed(1234L); + PortStatusMessage message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80); + Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); + serializedBuffer.skipBytes(PADDING); + Assert.assertEquals("Wrong PortNo", message.getPortNo().intValue(), serializedBuffer.readUnsignedInt()); + serializedBuffer.skipBytes(PORT_PADDING_1); + byte[] address = new byte[6]; + serializedBuffer.readBytes(address); + Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), + new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); + serializedBuffer.skipBytes(PORT_PADDING_2); + byte[] name = new byte[16]; + serializedBuffer.readBytes(name); + Assert.assertEquals("Wrong name", message.getName(), new String(name).trim()); + Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(serializedBuffer.readInt())); + Assert.assertEquals("Wrong state", message.getState(), createPortState(serializedBuffer.readInt())); + Assert.assertEquals("Wrong current", message.getCurrentFeatures(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong advertised", message.getAdvertisedFeatures(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong supported", message.getSupportedFeatures(), + createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong peer", message.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt())); + Assert.assertEquals("Wrong Current speed", message.getCurrSpeed().longValue(), serializedBuffer.readInt()); + Assert.assertEquals("Wrong Max speed", message.getMaxSpeed().longValue(), serializedBuffer.readInt()); + } + + private static PortConfig createPortConfig(long input) { + final Boolean _portDown = ((input) & (1 << 0)) > 0; + final Boolean _noRecv = ((input) & (1 << 2)) > 0; + final Boolean _noFwd = ((input) & (1 << 5)) > 0; + final Boolean _noPacketIn = ((input) & (1 << 6)) > 0; + return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown); + } + + private static PortFeatures createPortFeatures(long input) { + final Boolean _10mbHd = ((input) & (1 << 0)) > 0; + final Boolean _10mbFd = ((input) & (1 << 1)) > 0; + final Boolean _100mbHd = ((input) & (1 << 2)) > 0; + final Boolean _100mbFd = ((input) & (1 << 3)) > 0; + final Boolean _1gbHd = ((input) & (1 << 4)) > 0; + final Boolean _1gbFd = ((input) & (1 << 5)) > 0; + final Boolean _10gbFd = ((input) & (1 << 6)) > 0; + final Boolean _40gbFd = ((input) & (1 << 7)) > 0; + final Boolean _100gbFd = ((input) & (1 << 8)) > 0; + final Boolean _1tbFd = ((input) & (1 << 9)) > 0; + final Boolean _other = ((input) & (1 << 10)) > 0; + final Boolean _copper = ((input) & (1 << 11)) > 0; + final Boolean _fiber = ((input) & (1 << 12)) > 0; + final Boolean _autoneg = ((input) & (1 << 13)) > 0; + final Boolean _pause = ((input) & (1 << 14)) > 0; + final Boolean _pauseAsym = ((input) & (1 << 15)) > 0; + return new PortFeatures(_100gbFd, _100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _1tbFd, + _40gbFd, _autoneg, _copper, _fiber, _other, _pause, _pauseAsym); + } + + private static PortState createPortState(long input) { + final Boolean one = ((input) & (1 << 0)) > 0; + final Boolean two = ((input) & (1 << 1)) > 0; + final Boolean three = ((input) & (1 << 2)) > 0; + return new PortState(two, one, three); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java new file mode 100644 index 00000000..c69a0da1 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/QueueGetConfigReplyMessageFactoryTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class QueueGetConfigReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 23; + private static final byte PADDING = 4; + private static final byte QUEUE_PADDING = 6; + private static final byte PROPERTY_HEADER_PADDING = 4; + private static final byte PROPERTY_RATE_PADDING = 6; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, GetQueueConfigOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setPort(new PortNumber(0x00010203L)); + builder.setQueues(createQueuesList()); + GetQueueConfigOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80); + Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readInt()); + serializedBuffer.skipBytes(PADDING); + + Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong port", message.getQueues().get(0).getPort().getValue().longValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort()); + serializedBuffer.skipBytes(QUEUE_PADDING); + List properties = message.getQueues().get(0).getQueueProperty(); + Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), + serializedBuffer.readShort()); + Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort()); + serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING); + RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class); + Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort()); + serializedBuffer.skipBytes(PROPERTY_RATE_PADDING); + + Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getQueueId().getValue().longValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getPort().getValue().longValue(), + serializedBuffer.readInt()); + Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort()); + serializedBuffer.skipBytes(QUEUE_PADDING); + List propertiesTwo = message.getQueues().get(1).getQueueProperty(); + Assert.assertEquals("Wrong property", propertiesTwo.get(0).getProperty().getIntValue(), + serializedBuffer.readShort()); + Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort()); + serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING); + RateQueueProperty rateQueuePropertyTwo = propertiesTwo.get(0).getAugmentation(RateQueueProperty.class); + Assert.assertEquals("Wrong rate", rateQueuePropertyTwo.getRate().intValue(), serializedBuffer.readShort()); + serializedBuffer.skipBytes(PROPERTY_RATE_PADDING); + + } + + private static List createQueuesList() { + List queuesList = new ArrayList<>(); + for (int i = 1; i < 3; i++) { + QueuesBuilder qb = new QueuesBuilder(); + qb.setQueueId(new QueueId((long) i)); + qb.setPort(new PortNumber((long) i)); + qb.setQueueProperty(createPropertiesList()); + queuesList.add(qb.build()); + } + return queuesList; + } + + private static List createPropertiesList() { + List propertiesList = new ArrayList<>(); + QueuePropertyBuilder pb = new QueuePropertyBuilder(); + pb.setProperty(QueueProperties.forValue(2)); + RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder(); + rateBuilder.setRate(5); + pb.addAugmentation(RateQueueProperty.class, rateBuilder.build()); + propertiesList.add(pb.build()); + return propertiesList; + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java new file mode 100644 index 00000000..8ed58553 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/RoleReplyMessageFactoryTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.math.BigInteger; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutputBuilder; + +/** + * @author giuseppex.petralia@intel.com + * + */ +public class RoleReplyMessageFactoryTest { + private OFSerializer factory; + private static final byte MESSAGE_TYPE = 25; + private static final byte PADDING = 4; + + @Before + public void startUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry + .getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, RoleRequestOutput.class)); + } + + @Test + public void testSerialize() throws Exception { + RoleRequestOutputBuilder builder = new RoleRequestOutputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setRole(ControllerRole.forValue(0)); + builder.setGenerationId(BigInteger.valueOf(1L)); + RoleRequestOutput message = builder.build(); + + ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, serializedBuffer); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); + Assert.assertEquals("Wrong role", message.getRole().getIntValue(), + ControllerRole.forValue((int) serializedBuffer.readUnsignedInt()).getIntValue()); + serializedBuffer.skipBytes(PADDING); + byte[] genId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + serializedBuffer.readBytes(genId); + Assert.assertEquals("Wrong generation ID", message.getGenerationId(), new BigInteger(1, genId)); + } +} From f5221a159a53724cc07ffd8f2fa87436fd70292b Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 21 Dec 2015 17:30:17 +0100 Subject: [PATCH 217/285] Pull in slf4j-log4j12 from odlparent Rely on odlparent's dependency management instead of ${slf4j.version} (which comes from odlparent anyway). Change-Id: Ic2e1971fc047330d2386f20ff97d936edf2cd28e Signed-off-by: Stephen Kitt --- simple-client/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 484b3759..1a71abf2 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -44,7 +44,6 @@ org.slf4j slf4j-log4j12 - ${slf4j.version}
          From 79e676044c4a2b1a3e13502dcc77b2a0948b5223 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 15 May 2015 21:12:54 +0200 Subject: [PATCH 218/285] Cleanup VersionMessageWrapper Fields should really be final and the message buffer is not optional. Change-Id: I2eda0fece1ac8ef1cb7337ff5f17f528455e2b4a Signed-off-by: Robert Varga (cherry picked from commit 3d7142f71d50155111db46032776fa22260afafc) --- .../protocol/impl/core/VersionMessageUdpWrapper.java | 6 ++---- .../protocol/impl/core/VersionMessageWrapper.java | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java index c1625e5b..8f8d0641 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.core; import io.netty.buffer.ByteBuf; - import java.net.InetSocketAddress; /** @@ -18,15 +17,14 @@ * @author michal.polkorab */ public class VersionMessageUdpWrapper extends VersionMessageWrapper { - - private InetSocketAddress address; + private final InetSocketAddress address; /** * @param version Openflow wire version * @param messageBuffer ByteBuf containing binary message * @param address sender address */ - public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { + public VersionMessageUdpWrapper(final short version, final ByteBuf messageBuffer, final InetSocketAddress address) { super(version, messageBuffer); this.address = address; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java index a61298de..cdbe419c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; /** @@ -15,18 +16,17 @@ * @author michal.polkorab */ public class VersionMessageWrapper { - - private short version; - private ByteBuf messageBuffer; + private final short version; + private final ByteBuf messageBuffer; /** * Constructor * @param version version decoded in {@link OFVersionDetector} * @param messageBuffer message received from {@link OFFrameDecoder} */ - public VersionMessageWrapper(short version, ByteBuf messageBuffer) { + public VersionMessageWrapper(final short version, final ByteBuf messageBuffer) { this.version = version; - this.messageBuffer = messageBuffer; + this.messageBuffer = Preconditions.checkNotNull(messageBuffer); } /** @@ -42,6 +42,4 @@ public short getVersion() { public ByteBuf getMessageBuffer() { return messageBuffer; } - - } From 6a499f9932f6965ce84e97e98d2cd188482e8327 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 11 Jan 2016 22:28:52 +0100 Subject: [PATCH 219/285] Bug 4942 - Barrier send condition updated - fixes uncovered case - if a barrier was scheduled and another barrier was sent due to exceeded "maxNonBarrierMessages", then we would cancel / not enqueue the scheduled barrier because of "sinceLast" time - this time is lower than "maxBarrierNanos" Change-Id: I86f1be2ac0dc76241523ee3b6e6bf12bec90889e Signed-off-by: Michal Polkorab (cherry picked from commit 62c0db21eb5d45415011647427ba9f7a0dc69302) --- .../core/connection/OutboundQueueManager.java | 15 +++++---------- .../core/connection/StackedOutboundQueue.java | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 90db23da..1769face 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -86,16 +86,11 @@ protected void barrier() { return; } - final long now = System.nanoTime(); - final long sinceLast = now - lastBarrierNanos; - if (sinceLast >= maxBarrierNanos) { - LOG.debug("Last barrier at {} now {}, elapsed {}", lastBarrierNanos, now, sinceLast); - // FIXME: we should be tracking requests/responses instead of this - if (nonBarrierMessages == 0) { - LOG.trace("No messages written since last barrier, not issuing one"); - } else { - scheduleBarrierMessage(); - } + if (currentQueue.isBarrierNeeded()) { + LOG.trace("Sending a barrier message"); + scheduleBarrierMessage(); + } else { + LOG.trace("Barrier not needed, not issuing one"); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index a9876d99..cafd114c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -51,12 +51,24 @@ public void commitEntry(final Long xid, final OfHeader message, final FutureCall } Long reserveBarrierIfNeeded() { + if (isBarrierNeeded()) { + return reserveEntry(); + } + return null; + } + + /** + * Checks if Barrier Request is the last message enqueued. If not, one needs + * to be scheduled in order to collect data about previous messages. + * @return true if last enqueued message is Barrier Request, false otherwise + */ + boolean isBarrierNeeded() { final long bXid = barrierXid; final long fXid = firstSegment.getBaseXid() + flushOffset; if (bXid >= fXid) { LOG.debug("Barrier found at XID {} (currently at {})", bXid, fXid); - return null; + return false; } - return reserveEntry(); + return true; } } From c2e3a0d22602b63a1664baa49f466a64396e0583 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 14 Jan 2016 22:42:32 -0500 Subject: [PATCH 220/285] Bump versions by 0.1.0 for next dev cycle Change-Id: I8e4a58ccdbfca15d14fb9fb9741bf3ae8f05b612 Signed-off-by: Thanh Ha --- artifacts/pom.xml | 4 ++-- features/pom.xml | 16 ++++++++-------- openflow-protocol-api/pom.xml | 8 ++++---- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-it/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- openflowjava-config/pom.xml | 2 +- openflowjava-util/pom.xml | 2 +- parent/pom.xml | 12 ++++++------ pom.xml | 2 +- simple-client/pom.xml | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 80abc2e6..94856e82 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,13 +14,13 @@ org.opendaylight.odlparent odlparent-lite - 1.6.0-SNAPSHOT + 1.7.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-artifacts - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT pom diff --git a/features/pom.xml b/features/pom.xml index 4cc091be..62dc813d 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,21 +4,21 @@ org.opendaylight.odlparent features-parent - 1.6.0-SNAPSHOT + 1.7.0-SNAPSHOT org.opendaylight.openflowjava features-openflowjava - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT jar - 0.4.0-SNAPSHOT - 1.3.0-SNAPSHOT - 2.0.0-SNAPSHOT - 1.3.0-SNAPSHOT - 0.8.0-SNAPSHOT + 0.5.0-SNAPSHOT + 1.4.0-SNAPSHOT + 2.1.0-SNAPSHOT + 1.4.0-SNAPSHOT + 0.9.0-SNAPSHOT @@ -36,7 +36,7 @@ org.opendaylight.odlparent odlparent-artifacts - 1.6.0-SNAPSHOT + 1.7.0-SNAPSHOT import pom diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index efaa892a..130523cf 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.mdsal binding-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT org.opendaylight.openflowjava openflow-protocol-api - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT bundle Openflow Protocol Library - API @@ -18,8 +18,8 @@ - 2.0.0-SNAPSHOT - 0.8.0-SNAPSHOT + 2.1.0-SNAPSHOT + 0.9.0-SNAPSHOT diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index fae2c30b..6d4bcc84 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent openflow-protocol-impl diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 436f8bdf..12b0774f 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent openflow-protocol-it diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 8ec7ea7e..c65f9479 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent openflow-protocol-spi diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index ad7c00fa..dc9de5fa 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent openflowjava-config diff --git a/openflowjava-util/pom.xml b/openflowjava-util/pom.xml index 7b78d39e..f6bb3e54 100644 --- a/openflowjava-util/pom.xml +++ b/openflowjava-util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent bundle diff --git a/parent/pom.xml b/parent/pom.xml index 59048b9a..f4699245 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent odlparent - 1.6.0-SNAPSHOT + 1.7.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT pom openflowjava @@ -52,12 +52,12 @@ dav:http://nexus.opendaylight.org/content/sites/site UTF-8 ${project.build.directory}/yang-gen-config - 1.6.0-SNAPSHOT + 1.7.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - 0.4.0-SNAPSHOT - 1.3.0-SNAPSHOT - 0.8.0-SNAPSHOT + 0.5.0-SNAPSHOT + 1.4.0-SNAPSHOT + 0.9.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 56e8b447..dc4ee45a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT parent diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 1a71abf2..a74dca65 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT ../parent simple-client From 861b8da48425288e5769ca837d9dd4f86fe958fb Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Sat, 16 Jan 2016 22:55:33 +0100 Subject: [PATCH 221/285] AlreadyReading flag not used correctly - alreadyReading field is set correctly in channelRead() to signal that reading occurs and that any tries to flush are not needed, as a flush is always scheduled after the reading is done - alreadyReading flag was not set back to false, which might cause unnecessary checks for flush being scheduled Change-Id: Icafdf282390340b176cbe4d9702c84558af8b412 Signed-off-by: Michal Polkorab --- .../impl/core/connection/AbstractOutboundQueueManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 520d145d..8febb158 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -143,10 +143,11 @@ public void channelReadComplete(final ChannelHandlerContext ctx) throws Exceptio // we'll steal its work. Note that more work may accumulate in the time window // between now and when the task will run, so it may not be a no-op after all. // - // The reason for this is to will the output buffer before we go into selection + // The reason for this is to fill the output buffer before we go into selection // phase. This will make sure the pipe is full (in which case our next wake up // will be the queue becoming writable). writeAndFlush(); + alreadyReading = false; } @Override From 1404783ae3f3ecfbff27196a1c6ef0a3b74b1a72 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Sun, 17 Jan 2016 00:21:38 +0100 Subject: [PATCH 222/285] AllocatedXid assigned incorrectly - allocatedXid should be set as endXid of the last unflushed segment - incorrect allocatedXid resulted in unnecessary segment creation Change-Id: I040e4bd3f58ace6a911349b04eea2c2793372aa0 Signed-off-by: Michal Polkorab --- .../impl/core/connection/AbstractStackedOutboundQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index 54e779ea..a32c1ad1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -66,7 +66,7 @@ protected void ensureSegment(final StackedSegment first, final int offset) { unflushedSegments.add(newSegment); } - allocatedXid = uncompletedSegments.get(uncompletedSegments.size() - 1).getEndXid(); + allocatedXid = unflushedSegments.get(unflushedSegments.size() - 1).getEndXid(); } /* From 3e1330bea0561a66984710a4e941c297b4c3d1e8 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 21 Jan 2016 15:53:23 -0500 Subject: [PATCH 223/285] Bump yangtools to 1.0.0-SNAPSHOT Change-Id: Ie9097f01a9bfe3e68e5dced1f17efdcb736d21bc Signed-off-by: Thanh Ha --- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- parent/pom.xml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 6d4bcc84..a125a931 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -74,7 +74,7 @@ org.opendaylight.mdsal maven-sal-api-gen-plugin - ${yangtools.version} + ${mdsal.model.version} jar
          diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index c65f9479..430e2c90 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -75,7 +75,7 @@ org.opendaylight.mdsal maven-sal-api-gen-plugin - ${yangtools.version} + ${mdsal.model.version} jar diff --git a/parent/pom.xml b/parent/pom.xml index f4699245..103a32fb 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -57,7 +57,8 @@ 0.5.0-SNAPSHOT 1.4.0-SNAPSHOT - 0.9.0-SNAPSHOT + 0.9.0-SNAPSHOT + 1.0.0-SNAPSHOT From 434034870b13ece8b789f7481abaf6eae93771e1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 19 Feb 2016 14:36:02 +0100 Subject: [PATCH 224/285] BUG-2825: use provided Ipv4/MacAddress factories IetfInetUtil and IetfYangUtil provide performance-optimized methods for converting Ipv{4,6}{Address,Prefix}/MacAddress to and from binary format. Note that this changes the strings being produced: ipv6 addresses are properly shortened and max addresses have the canonical lower-case format. Change-Id: Ib912a8db3d4d89e85ee97bedc23a0160b7c36fba Signed-off-by: Robert Varga --- .../OF10SetDlDstActionDeserializer.java | 8 +- .../OF10SetDlSrcActionDeserializer.java | 8 +- .../OF10SetNwDstActionDeserializer.java | 4 +- .../OF10SetNwSrcActionDeserializer.java | 4 +- .../MultipartReplyMessageFactory.java | 61 ++++++++-------- .../OF10FeaturesReplyMessageFactory.java | 15 ++-- .../OF10PortModInputMessageFactory.java | 11 +-- .../OF10PortStatusMessageFactory.java | 10 +-- .../factories/PortModInputMessageFactory.java | 11 +-- .../factories/PortStatusMessageFactory.java | 16 ++-- .../match/OxmArpSpaDeserializer.java | 8 +- .../match/OxmArpTpaDeserializer.java | 8 +- .../match/OxmDeserializerHelper.java | 9 +-- .../match/OxmIpv4DstDeserializer.java | 8 +- .../match/OxmIpv4SrcDeserializer.java | 8 +- .../match/OxmIpv6DstDeserializer.java | 8 +- .../match/OxmIpv6NdTargetDeserializer.java | 8 +- .../match/OxmIpv6SrcDeserializer.java | 8 +- .../action/OF10SetDlDstActionSerializer.java | 9 +-- .../action/OF10SetDlSrcActionSerializer.java | 9 +-- .../action/OF10SetNwDstActionSerializer.java | 12 +-- .../action/OF10SetNwSrcActionSerializer.java | 11 +-- .../MultipartReplyMessageFactory.java | 73 ++++++++----------- .../OF10FeaturesReplyMessageFactory.java | 25 ++----- .../OF10PortModInputMessageFactory.java | 6 +- .../OF10PortStatusMessageFactory.java | 25 ++----- .../factories/PortModInputMessageFactory.java | 7 +- .../factories/PortStatusMessageFactory.java | 24 ++---- .../AbstractOxmIpv4AddressSerializer.java | 12 ++- .../AbstractOxmMacAddressSerializer.java | 7 +- .../match/OxmArpSpaSerializer.java | 5 +- .../match/OxmArpTpaSerializer.java | 5 +- .../match/OxmIpv4DstSerializer.java | 5 +- .../match/OxmIpv4SrcSerializer.java | 5 +- .../impl/util/OF10MatchDeserializer.java | 16 +--- .../impl/util/OF10MatchSerializer.java | 17 ++--- .../OF10FlowModInputMessageFactoryTest.java | 2 +- .../OF10PortModInputMessageFactoryTest.java | 2 +- .../PortModInputMessageFactoryTest.java | 2 +- .../PortStatusMessageFactoryTest.java | 4 +- .../multipart/MultipartReplyPortDescTest.java | 6 +- .../impl/util/MatchDeserializerTest.java | 10 +-- .../util/OF10ActionsDeserializerTest.java | 13 +--- .../impl/util/OF10MatchDeserializerTest.java | 8 +- .../openflowjava/util/ByteBufUtils.java | 24 ++++++ 45 files changed, 232 insertions(+), 325 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java index 29f640f3..d212eee8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder; @@ -27,14 +25,12 @@ public class OF10SetDlDstActionDeserializer extends AbstractActionDeserializer { @Override - public Action deserialize(ByteBuf input) { + public Action deserialize(final ByteBuf input) { ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetDlDstCaseBuilder caseBuilder = new SetDlDstCaseBuilder(); SetDlDstActionBuilder actionBuilder = new SetDlDstActionBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - actionBuilder.setDlDstAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + actionBuilder.setDlDstAddress(ByteBufUtils.readIetfMacAddress(input)); caseBuilder.setSetDlDstAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java index 6e2428a4..9ca56a90 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder; @@ -27,14 +25,12 @@ public class OF10SetDlSrcActionDeserializer extends AbstractActionDeserializer { @Override - public Action deserialize(ByteBuf input) { + public Action deserialize(final ByteBuf input) { ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetDlSrcCaseBuilder caseBuilder = new SetDlSrcCaseBuilder(); SetDlSrcActionBuilder actionBuilder = new SetDlSrcActionBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - actionBuilder.setDlSrcAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + actionBuilder.setDlSrcAddress(ByteBufUtils.readIetfMacAddress(input)); caseBuilder.setSetDlSrcAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java index 1bd01e86..14ea5fcc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java @@ -9,10 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; @@ -31,7 +29,7 @@ public Action deserialize(final ByteBuf input) { input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetNwDstCaseBuilder caseBuilder = new SetNwDstCaseBuilder(); SetNwDstActionBuilder actionBuilder = new SetNwDstActionBuilder(); - actionBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + actionBuilder.setIpAddress(ByteBufUtils.readIetfIpv4Address(input)); caseBuilder.setSetNwDstAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); return builder.build(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java index a5899c7a..9c982c21 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java @@ -9,10 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder; @@ -31,7 +29,7 @@ public Action deserialize(final ByteBuf input) { input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetNwSrcCaseBuilder caseBuilder = new SetNwSrcCaseBuilder(); SetNwSrcActionBuilder actionBuilder = new SetNwSrcActionBuilder(); - actionBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + actionBuilder.setIpAddress(ByteBufUtils.readIetfIpv4Address(input)); caseBuilder.setSetNwSrcAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); return builder.build(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java index 085a8565..62ebf38f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java @@ -22,7 +22,6 @@ import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; @@ -182,7 +181,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer flowStatsList = new ArrayList<>(); @@ -312,7 +311,7 @@ private MultipartReplyFlowCase setFlow(ByteBuf input) { return caseBuilder.build(); } - private static FlowModFlags createFlowModFlagsFromBitmap(int input) { + private static FlowModFlags createFlowModFlagsFromBitmap(final int input) { final Boolean fmfSENDFLOWREM = (input & (1 << 0)) != 0; final Boolean fmfCHECKOVERLAP = (input & (1 << 1)) != 0; final Boolean fmfRESETCOUNTS = (input & (1 << 2)) != 0; @@ -321,7 +320,7 @@ private static FlowModFlags createFlowModFlagsFromBitmap(int input) { return new FlowModFlags(fmfCHECKOVERLAP, fmfNOBYTCOUNTS, fmfNOPKTCOUNTS, fmfRESETCOUNTS, fmfSENDFLOWREM); } - private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { + private static MultipartReplyAggregateCase setAggregate(final ByteBuf input) { MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder(); MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder(); byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; @@ -336,7 +335,7 @@ private static MultipartReplyAggregateCase setAggregate(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyTableCase setTable(ByteBuf input) { + private static MultipartReplyTableCase setTable(final ByteBuf input) { MultipartReplyTableCaseBuilder caseBuilder = new MultipartReplyTableCaseBuilder(); MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder(); List tableStatsList = new ArrayList<>(); @@ -358,7 +357,7 @@ private static MultipartReplyTableCase setTable(ByteBuf input) { return caseBuilder.build(); } - private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { + private MultipartReplyTableFeaturesCase setTableFeatures(final ByteBuf input) { MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder(); MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder(); List features = new ArrayList<>(); @@ -385,12 +384,12 @@ private MultipartReplyTableFeaturesCase setTableFeatures(ByteBuf input) { return caseBuilder.build(); } - private static TableConfig createTableConfig(long input) { + private static TableConfig createTableConfig(final long input) { boolean deprecated = (input & 3) != 0; return new TableConfig(deprecated); } - private List createTableFeaturesProperties(ByteBuf input, int length) { + private List createTableFeaturesProperties(final ByteBuf input, final int length) { List properties = new ArrayList<>(); int tableFeaturesLength = length; while (tableFeaturesLength > 0) { @@ -465,7 +464,7 @@ private List createTableFeaturesProperties(ByteBuf input return properties; } - private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { + private static MultipartReplyPortStatsCase setPortStats(final ByteBuf input) { MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder(); MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder(); List portStatsList = new ArrayList<>(); @@ -518,7 +517,7 @@ private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyQueueCase setQueue(ByteBuf input) { + private static MultipartReplyQueueCase setQueue(final ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); List queueStatsList = new ArrayList<>(); @@ -544,7 +543,7 @@ private static MultipartReplyQueueCase setQueue(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyGroupCase setGroup(ByteBuf input) { + private static MultipartReplyGroupCase setGroup(final ByteBuf input) { MultipartReplyGroupCaseBuilder caseBuilder = new MultipartReplyGroupCaseBuilder(); MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder(); List groupStatsList = new ArrayList<>(); @@ -584,7 +583,7 @@ private static MultipartReplyGroupCase setGroup(ByteBuf input) { return caseBuilder.build(); } - private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { + private static MultipartReplyMeterFeaturesCase setMeterFeatures(final ByteBuf input) { MultipartReplyMeterFeaturesCaseBuilder caseBuilder = new MultipartReplyMeterFeaturesCaseBuilder(); MultipartReplyMeterFeaturesBuilder builder = new MultipartReplyMeterFeaturesBuilder(); builder.setMaxMeter(input.readUnsignedInt()); @@ -597,7 +596,7 @@ private static MultipartReplyMeterFeaturesCase setMeterFeatures(ByteBuf input) { return caseBuilder.build(); } - private static MeterFlags createMeterFlags(long input) { + private static MeterFlags createMeterFlags(final long input) { final Boolean mfKBPS = (input & (1 << 0)) != 0; final Boolean mfPKTPS = (input & (1 << 1)) != 0; final Boolean mfBURST = (input & (1 << 2)) != 0; @@ -605,13 +604,13 @@ private static MeterFlags createMeterFlags(long input) { return new MeterFlags(mfBURST, mfKBPS, mfPKTPS, mfSTATS); } - private static MeterBandTypeBitmap createMeterBandsBitmap(long input) { + private static MeterBandTypeBitmap createMeterBandsBitmap(final long input) { final Boolean mbtDROP = (input & (1 << 1)) != 0; final Boolean mbtDSCPREMARK = (input & (1 << 2)) != 0; return new MeterBandTypeBitmap(mbtDROP, mbtDSCPREMARK); } - private static MultipartReplyMeterCase setMeter(ByteBuf input) { + private static MultipartReplyMeterCase setMeter(final ByteBuf input) { MultipartReplyMeterCaseBuilder caseBuilder = new MultipartReplyMeterCaseBuilder(); MultipartReplyMeterBuilder builder = new MultipartReplyMeterBuilder(); List meterStatsList = new ArrayList<>(); @@ -650,7 +649,7 @@ private static MultipartReplyMeterCase setMeter(ByteBuf input) { return caseBuilder.build(); } - private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { + private MultipartReplyMeterConfigCase setMeterConfig(final ByteBuf input) { MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder(); MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder(); List meterConfigList = new ArrayList<>(); @@ -711,7 +710,7 @@ private MultipartReplyMeterConfigCase setMeterConfig(ByteBuf input) { return caseBuilder.build(); } - private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { + private MultipartReplyExperimenterCase setExperimenter(final ByteBuf input) { final long expId = input.readUnsignedInt(); final long expType = input.readUnsignedInt(); @@ -728,7 +727,7 @@ private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) { return mpReplyExperimenterCaseBld.build(); } - private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { + private static MultipartReplyPortDescCase setPortDesc(final ByteBuf input) { MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder(); MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder(); List portsList = new ArrayList<>(); @@ -736,9 +735,7 @@ private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { PortsBuilder portsBuilder = new PortsBuilder(); portsBuilder.setPortNo(input.readUnsignedInt()); input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01); - byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(hwAddress); - portsBuilder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); + portsBuilder.setHwAddr(ByteBufUtils.readIetfMacAddress(input)); input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02); portsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, EncodeConstants.MAX_PORT_NAME_LENGTH)); portsBuilder.setConfig(createPortConfig(input.readUnsignedInt())); @@ -756,7 +753,7 @@ private static MultipartReplyPortDescCase setPortDesc(ByteBuf input) { return caseBuilder.build(); } - private static PortConfig createPortConfig(long input) { + private static PortConfig createPortConfig(final long input) { final Boolean pcPortDown = ((input) & (1 << 0)) != 0; final Boolean pcNRecv = ((input) & (1 << 2)) != 0; final Boolean pcNFwd = ((input) & (1 << 5)) != 0; @@ -764,14 +761,14 @@ private static PortConfig createPortConfig(long input) { return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } - private static PortState createPortState(long input) { + private static PortState createPortState(final long input) { final Boolean psLinkDown = ((input) & (1 << 0)) != 0; final Boolean psBlocked = ((input) & (1 << 1)) != 0; final Boolean psLive = ((input) & (1 << 2)) != 0; return new PortState(psBlocked, psLinkDown, psLive); } - private static PortFeatures createPortFeatures(long input) { + private static PortFeatures createPortFeatures(final long input) { final Boolean pf10mbHd = ((input) & (1 << 0)) != 0; final Boolean pf10mbFd = ((input) & (1 << 1)) != 0; final Boolean pf100mbHd = ((input) & (1 << 2)) != 0; @@ -792,7 +789,7 @@ private static PortFeatures createPortFeatures(long input) { pf1gbHd, pf1tbFd, pf40gbFd, pfAutoneg, pfCopper, pfFiber, pfOther, pfPause, pfPauseAsym); } - private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessage) { + private static MultipartReplyGroupFeaturesCase setGroupFeatures(final ByteBuf rawMessage) { MultipartReplyGroupFeaturesCaseBuilder caseBuilder = new MultipartReplyGroupFeaturesCaseBuilder(); MultipartReplyGroupFeaturesBuilder featuresBuilder = new MultipartReplyGroupFeaturesBuilder(); featuresBuilder.setTypes(createGroupType(rawMessage.readUnsignedInt())); @@ -811,7 +808,7 @@ private static MultipartReplyGroupFeaturesCase setGroupFeatures(ByteBuf rawMessa return caseBuilder.build(); } - private static ActionType createActionBitmap(long input) { + private static ActionType createActionBitmap(final long input) { final Boolean atOutput = ((input) & (1 << 0)) != 0; final Boolean atCopyTTLout = ((input) & (1 << 11)) != 0; final Boolean atCopyTTLin = ((input) & (1 << 12)) != 0; @@ -835,7 +832,7 @@ private static ActionType createActionBitmap(long input) { atSetField, atSetMplsTTL, atSetNWTTL, atSetQueue); } - private static GroupCapabilities createCapabilities(long input) { + private static GroupCapabilities createCapabilities(final long input) { final Boolean gcSelectWeight = ((input) & (1 << 0)) != 0; final Boolean gcSelectLiveness = ((input) & (1 << 1)) != 0; final Boolean gcChaining = ((input) & (1 << 2)) != 0; @@ -843,7 +840,7 @@ private static GroupCapabilities createCapabilities(long input) { return new GroupCapabilities(gcChaining, gcChainingChecks, gcSelectLiveness, gcSelectWeight); } - private static GroupTypes createGroupType(long input) { + private static GroupTypes createGroupType(final long input) { final Boolean gtAll = ((input) & (1 << 0)) != 0; final Boolean gtSelect = ((input) & (1 << 1)) != 0; final Boolean gtIndirect = ((input) & (1 << 2)) != 0; @@ -851,7 +848,7 @@ private static GroupTypes createGroupType(long input) { return new GroupTypes(gtAll, gtFF, gtIndirect, gtSelect); } - private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) { + private MultipartReplyGroupDescCase setGroupDesc(final ByteBuf input) { MultipartReplyGroupDescCaseBuilder caseBuilder = new MultipartReplyGroupDescCaseBuilder(); MultipartReplyGroupDescBuilder builder = new MultipartReplyGroupDescBuilder(); List groupDescsList = new ArrayList<>(); @@ -887,7 +884,7 @@ private MultipartReplyGroupDescCase setGroupDesc(ByteBuf input) { @Override public void injectDeserializerRegistry( - DeserializerRegistry deserializerRegistry) { + final DeserializerRegistry deserializerRegistry) { registry = deserializerRegistry; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index 469f920e..c94b0d11 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -9,16 +9,13 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import java.math.BigInteger; import java.util.ArrayList; import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OpenflowUtils; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; @@ -35,7 +32,7 @@ public class OF10FeaturesReplyMessageFactory implements OFDeserializer { @Override - public PortModInput deserialize(ByteBuf rawMessage) { + public PortModInput deserialize(final ByteBuf rawMessage) { PortModInputBuilder builder = new PortModInputBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort())); - byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - rawMessage.readBytes(hwAddress); - builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); + builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage)); builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt())); builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt())); return builder.build(); } - private static PortConfigV10 createPortConfig(long input) { + private static PortConfigV10 createPortConfig(final long input) { final Boolean _portDown = ((input) & (1 << 0)) > 0; final Boolean _noStp = ((input) & (1 << 1)) > 0; final Boolean _noRecv = ((input) & (1 << 2)) > 0; @@ -50,7 +47,7 @@ private static PortConfigV10 createPortConfig(long input) { return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown); } - private static PortFeaturesV10 createPortFeatures(long input) { + private static PortFeaturesV10 createPortFeatures(final long input) { final Boolean _10mbHd = ((input) & (1 << 0)) > 0; final Boolean _10mbFd = ((input) & (1 << 1)) > 0; final Boolean _100mbHd = ((input) & (1 << 2)) > 0; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java index 9c3b72e7..2bab42b6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactory.java @@ -9,12 +9,10 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.OpenflowUtils; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; @@ -28,7 +26,7 @@ public class OF10PortStatusMessageFactory implements OFDeserializer private static final byte PADDING_IN_PORT_MOD_MESSAGE_3 = 4; @Override - public PortModInput deserialize(ByteBuf rawMessage) { + public PortModInput deserialize(final ByteBuf rawMessage) { PortModInputBuilder builder = new PortModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt())); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1); - byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - rawMessage.readBytes(hwAddress); - builder.setHwAddress(new MacAddress(ByteBufUtils.macAddressToString(hwAddress))); + builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage)); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2); builder.setConfig(createPortConfig(rawMessage.readUnsignedInt())); builder.setMask(createPortConfig(rawMessage.readUnsignedInt())); @@ -46,7 +43,7 @@ public PortModInput deserialize(ByteBuf rawMessage) { return builder.build(); } - private static PortConfig createPortConfig(long input) { + private static PortConfig createPortConfig(final long input) { final Boolean pcPortDown = ((input) & (1 << 0)) != 0; final Boolean pcNRecv = ((input) & (1 << 2)) != 0; final Boolean pcNFwd = ((input) & (1 << 5)) != 0; @@ -54,7 +51,7 @@ private static PortConfig createPortConfig(long input) { return new PortConfig(pcNFwd, pcNPacketIn, pcNRecv, pcPortDown); } - private static PortFeatures createPortFeatures(long input) { + private static PortFeatures createPortFeatures(final long input) { final Boolean pf10mbHd = ((input) & (1 << 0)) != 0; final Boolean pf10mbFd = ((input) & (1 << 1)) != 0; final Boolean pf100mbHd = ((input) & (1 << 2)) != 0; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index fe3d7ac7..5310aa2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -9,11 +9,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; @@ -33,7 +31,7 @@ public class PortStatusMessageFactory implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addArpSpaValue(input, builder); return builder.build(); } - private static void addArpSpaValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addArpSpaValue(final ByteBuf input, final MatchEntryBuilder builder) { ArpSpaCaseBuilder caseBuilder = new ArpSpaCaseBuilder(); ArpSpaBuilder arpBuilder = new ArpSpaBuilder(); - arpBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + arpBuilder.setIpv4Address(ByteBufUtils.readIetfIpv4Address(input)); if (builder.isHasMask()) { arpBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java index fdeaddc5..da5dfee6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java @@ -8,11 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -30,16 +28,16 @@ public class OxmArpTpaDeserializer extends AbstractOxmMatchEntryDeserializer implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addArpTpaValue(input, builder); return builder.build(); } - private static void addArpTpaValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addArpTpaValue(final ByteBuf input, final MatchEntryBuilder builder) { ArpTpaCaseBuilder caseBuilder = new ArpTpaCaseBuilder(); ArpTpaBuilder arpBuilder = new ArpTpaBuilder(); - arpBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + arpBuilder.setIpv4Address(ByteBufUtils.readIetfIpv4Address(input)); if (builder.isHasMask()) { arpBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java index 1127faea..daeb2950 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java @@ -8,9 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; /** @@ -29,7 +28,7 @@ private OxmDeserializerHelper() { * @param matchEntryLength mask length * @return binary mask */ - public static byte[] convertMask(ByteBuf input, int matchEntryLength) { + public static byte[] convertMask(final ByteBuf input, final int matchEntryLength) { byte[] mask = new byte[matchEntryLength]; input.readBytes(mask); return mask; @@ -40,9 +39,9 @@ public static byte[] convertMask(ByteBuf input, int matchEntryLength) { * @param input input ByteBuf * @return mac address */ - public static MacAddress convertMacAddress(ByteBuf input) { + public static MacAddress convertMacAddress(final ByteBuf input) { byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; input.readBytes(address); - return new MacAddress(ByteBufUtils.macAddressToString(address)); + return IetfYangUtil.INSTANCE.macAddressFor(address); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java index d0e5fc1a..6664538d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java @@ -8,11 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -30,16 +28,16 @@ public class OxmIpv4DstDeserializer extends AbstractOxmMatchEntryDeserializer implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addIpv4DstValue(input, builder); return builder.build(); } - private static void addIpv4DstValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addIpv4DstValue(final ByteBuf input, final MatchEntryBuilder builder) { Ipv4DstCaseBuilder caseBuilder = new Ipv4DstCaseBuilder(); Ipv4DstBuilder ipv4Builder = new Ipv4DstBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + ipv4Builder.setIpv4Address(ByteBufUtils.readIetfIpv4Address(input)); if (builder.isHasMask()) { ipv4Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java index fdd020c6..5b0cc22d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java @@ -8,11 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -30,16 +28,16 @@ public class OxmIpv4SrcDeserializer extends AbstractOxmMatchEntryDeserializer implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addIpv4SrcValue(input, builder); return builder.build(); } - private static void addIpv4SrcValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addIpv4SrcValue(final ByteBuf input, final MatchEntryBuilder builder) { Ipv4SrcCaseBuilder caseBuilder = new Ipv4SrcCaseBuilder(); Ipv4SrcBuilder ipv4Builder = new Ipv4SrcBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + ipv4Builder.setIpv4Address(ByteBufUtils.readIetfIpv4Address(input)); if (builder.isHasMask()) { ipv4Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.GROUPS_IN_IPV4_ADDRESS)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java index 364cbaef..4d88c269 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java @@ -8,11 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -30,16 +28,16 @@ public class OxmIpv6DstDeserializer extends AbstractOxmMatchEntryDeserializer implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addIpv6DstValue(input, builder); return builder.build(); } - private static void addIpv6DstValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addIpv6DstValue(final ByteBuf input, final MatchEntryBuilder builder) { Ipv6DstCaseBuilder caseBuilder = new Ipv6DstCaseBuilder(); Ipv6DstBuilder ipv6Builder = new Ipv6DstBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + ipv6Builder.setIpv6Address(ByteBufUtils.readIetfIpv6Address(input)); if (builder.isHasMask()) { ipv6Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java index 2afd9a50..99c52c95 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java @@ -8,10 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -29,16 +27,16 @@ public class OxmIpv6NdTargetDeserializer extends AbstractOxmMatchEntryDeserializ implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addIpv6NdTargetValue(input, builder); return builder.build(); } - private static void addIpv6NdTargetValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addIpv6NdTargetValue(final ByteBuf input, final MatchEntryBuilder builder) { Ipv6NdTargetCaseBuilder caseBuilder = new Ipv6NdTargetCaseBuilder(); Ipv6NdTargetBuilder ipv6Builder = new Ipv6NdTargetBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + ipv6Builder.setIpv6Address(ByteBufUtils.readIetfIpv6Address(input)); caseBuilder.setIpv6NdTarget(ipv6Builder.build()); builder.setMatchEntryValue(caseBuilder.build()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java index 4b486f0b..22b9ccef 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java @@ -8,11 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; @@ -30,16 +28,16 @@ public class OxmIpv6SrcDeserializer extends AbstractOxmMatchEntryDeserializer implements OFDeserializer { @Override - public MatchEntry deserialize(ByteBuf input) { + public MatchEntry deserialize(final ByteBuf input) { MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); addIpv6SrcValue(input, builder); return builder.build(); } - private static void addIpv6SrcValue(ByteBuf input, MatchEntryBuilder builder) { + private static void addIpv6SrcValue(final ByteBuf input, final MatchEntryBuilder builder) { Ipv6SrcCaseBuilder caseBuilder = new Ipv6SrcCaseBuilder(); Ipv6SrcBuilder ipv6Builder = new Ipv6SrcBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + ipv6Builder.setIpv6Address(ByteBufUtils.readIetfIpv6Address(input)); if (builder.isHasMask()) { ipv6Builder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES)); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java index e654466a..d526eb01 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -22,10 +21,10 @@ public class OF10SetDlDstActionSerializer extends AbstractActionSerializer { @Override - public void serialize(Action action, ByteBuf outBuffer) { + public void serialize(final Action action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(((SetDlDstCase) action.getActionChoice()) - .getSetDlDstAction().getDlDstAddress().getValue())); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(((SetDlDstCase) action.getActionChoice()) + .getSetDlDstAction().getDlDstAddress())); outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java index 67db7d57..5e487c3f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -22,10 +21,10 @@ public class OF10SetDlSrcActionSerializer extends AbstractActionSerializer { @Override - public void serialize(Action action, ByteBuf outBuffer) { + public void serialize(final Action action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(((SetDlSrcCase) action.getActionChoice()) - .getSetDlSrcAction().getDlSrcAddress().getValue())); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(((SetDlSrcCase) action.getActionChoice()) + .getSetDlSrcAction().getDlSrcAddress())); outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java index 73ecd595..c7a2f34a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -24,12 +23,8 @@ public class OF10SetNwDstActionSerializer extends AbstractActionSerializer { @Override public void serialize(final Action action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(((SetNwDstCase) action.getActionChoice()).getSetNwDstAction() - .getIpAddress().getValue()); - for (String group : addressGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } + outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes( + ((SetNwDstCase) action.getActionChoice()).getSetNwDstAction().getIpAddress())); } @Override @@ -41,5 +36,4 @@ protected int getType() { protected int getLength() { return ActionConstants.GENERAL_ACTION_LENGTH; } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java index d63bf9c4..bf98a278 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java @@ -9,9 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.action; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -24,12 +23,8 @@ public class OF10SetNwSrcActionSerializer extends AbstractActionSerializer { @Override public void serialize(final Action action, final ByteBuf outBuffer) { super.serialize(action, outBuffer); - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction() - .getIpAddress().getValue()); - for (String group : addressGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } + outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes( + ((SetNwSrcCase) action.getActionChoice()).getSetNwSrcAction().getIpAddress())); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java index e0393c7b..52a547f0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java @@ -22,6 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; @@ -145,12 +146,12 @@ public class MultipartReplyMessageFactory implements OFSerializer map = new HashMap<>(); map.put(0, flags.isOFPMPFREQMORE()); int bitmap = ByteBufUtils.fillBitMaskFromMap(map); outBuffer.writeShort(bitmap); } - private void serializeTableFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeTableFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body; MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures(); for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) { @@ -375,14 +376,14 @@ private static int paddingNeeded(final int length) { return result; } - private void writeTableConfig(TableConfig tableConfig, ByteBuf outBuffer) { + private void writeTableConfig(final TableConfig tableConfig, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, tableConfig.isOFPTCDEPRECATEDMASK()); int bitmap = ByteBufUtils.fillBitMaskFromMap(map); outBuffer.writeInt(bitmap); } - private void serializeMeterFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeMeterFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyMeterFeaturesCase meterFeaturesCase = (MultipartReplyMeterFeaturesCase) body; MultipartReplyMeterFeatures meterFeatures = meterFeaturesCase.getMultipartReplyMeterFeatures(); outBuffer.writeInt(meterFeatures.getMaxMeter().intValue()); @@ -393,7 +394,7 @@ private void serializeMeterFeaturesBody(MultipartReplyBody body, ByteBuf outBuff outBuffer.writeZero(METER_FEATURES_PADDING); } - private void writeBandTypes(MeterBandTypeBitmap bandTypes, ByteBuf outBuffer) { + private void writeBandTypes(final MeterBandTypeBitmap bandTypes, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, bandTypes.isOFPMBTDROP()); map.put(1, bandTypes.isOFPMBTDSCPREMARK()); @@ -401,7 +402,7 @@ private void writeBandTypes(MeterBandTypeBitmap bandTypes, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void serializeMeterConfigBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeMeterConfigBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyMeterConfigCase meterConfigCase = (MultipartReplyMeterConfigCase) body; MultipartReplyMeterConfig meter = meterConfigCase.getMultipartReplyMeterConfig(); for (MeterConfig meterConfig : meter.getMeterConfig()) { @@ -437,7 +438,7 @@ private static void writeBandCommonFields(final MeterBandCommons meterBand, fina outBuffer.writeInt(meterBand.getBurstSize().intValue()); } - private void writeMeterFlags(MeterFlags flags, ByteBuf outBuffer) { + private void writeMeterFlags(final MeterFlags flags, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, flags.isOFPMFKBPS()); map.put(1, flags.isOFPMFPKTPS()); @@ -447,7 +448,7 @@ private void writeMeterFlags(MeterFlags flags, ByteBuf outBuffer) { outBuffer.writeShort(bitmap); } - private void serializeMeterBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeMeterBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyMeterCase meterCase = (MultipartReplyMeterCase) body; MultipartReplyMeter meter = meterCase.getMultipartReplyMeter(); for (MeterStats meterStats : meter.getMeterStats()) { @@ -469,7 +470,7 @@ private void serializeMeterBody(MultipartReplyBody body, ByteBuf outBuffer) { } } - private void serializeGroupFeaturesBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeGroupFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyGroupFeaturesCase groupFeaturesCase = (MultipartReplyGroupFeaturesCase) body; MultipartReplyGroupFeatures groupFeatures = groupFeaturesCase.getMultipartReplyGroupFeatures(); writeGroupTypes(groupFeatures.getTypes(), outBuffer); @@ -482,7 +483,7 @@ private void serializeGroupFeaturesBody(MultipartReplyBody body, ByteBuf outBuff } } - private void writeActionType(ActionType action, ByteBuf outBuffer) { + private void writeActionType(final ActionType action, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, action.isOFPATOUTPUT()); map.put(1, action.isOFPATCOPYTTLOUT()); @@ -505,7 +506,7 @@ private void writeActionType(ActionType action, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writeGroupCapabilities(GroupCapabilities capabilities, ByteBuf outBuffer) { + private void writeGroupCapabilities(final GroupCapabilities capabilities, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, capabilities.isOFPGFCSELECTWEIGHT()); map.put(1, capabilities.isOFPGFCSELECTLIVENESS()); @@ -515,7 +516,7 @@ private void writeGroupCapabilities(GroupCapabilities capabilities, ByteBuf outB outBuffer.writeInt(bitmap); } - private void writeGroupTypes(GroupTypes types, ByteBuf outBuffer) { + private void writeGroupTypes(final GroupTypes types, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, types.isOFPGTALL()); map.put(1, types.isOFPGTSELECT()); @@ -525,7 +526,7 @@ private void writeGroupTypes(GroupTypes types, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void serializeGroupDescBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { + private void serializeGroupDescBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) { MultipartReplyGroupDescCase groupDescCase = (MultipartReplyGroupDescCase) body; MultipartReplyGroupDesc group = groupDescCase.getMultipartReplyGroupDesc(); for (GroupDesc groupDesc : group.getGroupDesc()) { @@ -551,7 +552,7 @@ private void serializeGroupDescBody(MultipartReplyBody body, ByteBuf outBuffer, } } - private void serializeGroupBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeGroupBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyGroupCase groupCase = (MultipartReplyGroupCase) body; MultipartReplyGroup group = groupCase.getMultipartReplyGroup(); for (GroupStats groupStats : group.getGroupStats()) { @@ -574,7 +575,7 @@ private void serializeGroupBody(MultipartReplyBody body, ByteBuf outBuffer) { } } - private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeQueueBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body; MultipartReplyQueue queue = queueCase.getMultipartReplyQueue(); for (QueueStats queueStats : queue.getQueueStats()) { @@ -588,7 +589,7 @@ private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) { } } - private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializePortStatsBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body; MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats(); for (PortStats portStat : portStats.getPortStats()) { @@ -611,7 +612,7 @@ private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) } } - private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeTableBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyTableCase tableCase = (MultipartReplyTableCase) body; MultipartReplyTable table = tableCase.getMultipartReplyTable(); for (TableStats tableStats : table.getTableStats()) { @@ -623,7 +624,7 @@ private void serializeTableBody(MultipartReplyBody body, ByteBuf outBuffer) { } } - private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeAggregateBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyAggregateCase aggregateCase = (MultipartReplyAggregateCase) body; MultipartReplyAggregate aggregate = aggregateCase.getMultipartReplyAggregate(); outBuffer.writeLong(aggregate.getPacketCount().longValue()); @@ -632,7 +633,7 @@ private void serializeAggregateBody(MultipartReplyBody body, ByteBuf outBuffer) outBuffer.writeZero(AGGREGATE_PADDING); } - private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, MultipartReplyMessage message) { + private void serializeFlowBody(final MultipartReplyBody body, final ByteBuf outBuffer, final MultipartReplyMessage message) { MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body; MultipartReplyFlow flow = flowCase.getMultipartReplyFlow(); for (FlowStats flowStats : flow.getFlowStats()) { @@ -660,7 +661,7 @@ private void serializeFlowBody(MultipartReplyBody body, ByteBuf outBuffer, Multi } } - private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializeDescBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyDescCase descCase = (MultipartReplyDescCase) body; MultipartReplyDesc desc = descCase.getMultipartReplyDesc(); write256String(desc.getMfrDesc(), outBuffer); @@ -670,7 +671,7 @@ private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) { write256String(desc.getDpDesc(), outBuffer); } - private void write256String(String toWrite, ByteBuf outBuffer) { + private void write256String(final String toWrite, final ByteBuf outBuffer) { byte[] nameBytes = toWrite.getBytes(); if (nameBytes.length < 256) { byte[] nameBytesPadding = new byte[256]; @@ -688,7 +689,7 @@ private void write256String(String toWrite, ByteBuf outBuffer) { } } - private void write32String(String toWrite, ByteBuf outBuffer) { + private void write32String(final String toWrite, final ByteBuf outBuffer) { byte[] nameBytes = toWrite.getBytes(); if (nameBytes.length < 32) { byte[] nameBytesPadding = new byte[32]; @@ -706,14 +707,14 @@ private void write32String(String toWrite, ByteBuf outBuffer) { } } - private void serializePortDescBody(MultipartReplyBody body, ByteBuf outBuffer) { + private void serializePortDescBody(final MultipartReplyBody body, final ByteBuf outBuffer) { MultipartReplyPortDescCase portCase = (MultipartReplyPortDescCase) body; MultipartReplyPortDesc portDesc = portCase.getMultipartReplyPortDesc(); for (Ports port : portDesc.getPorts()) { outBuffer.writeInt(port.getPortNo().intValue()); // Assuming PortNo // = PortId outBuffer.writeZero(PORT_DESC_PADDING_1); - writeMacAddress(port.getHwAddr().getValue(), outBuffer); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(port.getHwAddr())); outBuffer.writeZero(PORT_DESC_PADDING_2); writeName(port.getName(), outBuffer); writePortConfig(port.getConfig(), outBuffer); @@ -727,7 +728,7 @@ private void serializePortDescBody(MultipartReplyBody body, ByteBuf outBuffer) { } } - private void writeName(String name, ByteBuf outBuffer) { + private void writeName(final String name, final ByteBuf outBuffer) { byte[] nameBytes = name.getBytes(); if (nameBytes.length < 16) { byte[] nameBytesPadding = new byte[16]; @@ -746,17 +747,7 @@ private void writeName(String name, ByteBuf outBuffer) { } - private void writeMacAddress(String macAddress, ByteBuf outBuffer) { - String[] macAddressParts = macAddress.split(":"); - byte[] macAddressBytes = new byte[6]; - for (int i = 0; i < 6; i++) { - Integer hex = Integer.parseInt(macAddressParts[i], 16); - macAddressBytes[i] = hex.byteValue(); - } - outBuffer.writeBytes(macAddressBytes); - } - - private void writePortConfig(PortConfig config, ByteBuf outBuffer) { + private void writePortConfig(final PortConfig config, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, config.isPortDown()); map.put(2, config.isNoRecv()); @@ -766,7 +757,7 @@ private void writePortConfig(PortConfig config, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortState(PortState state, ByteBuf outBuffer) { + private void writePortState(final PortState state, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, state.isLinkDown()); map.put(1, state.isBlocked()); @@ -775,7 +766,7 @@ private void writePortState(PortState state, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) { + private void writePortFeatures(final PortFeatures features, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, features.is_10mbHd()); map.put(1, features.is_10mbFd()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java index 8edf30ca..62de9328 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; @@ -31,7 +32,7 @@ public class OF10FeaturesReplyMessageFactory implements OFSerializer map = new HashMap<>(); map.put(0, feature.is_10mbHd()); map.put(1, feature.is_10mbFd()); @@ -71,7 +72,7 @@ private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortState(PortStateV10 state, ByteBuf outBuffer) { + private void writePortState(final PortStateV10 state, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, state.isLinkDown()); map.put(1, state.isBlocked()); @@ -85,7 +86,7 @@ private void writePortState(PortStateV10 state, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { + private void writePortConfig(final PortConfigV10 config, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, config.isPortDown()); map.put(1, config.isNoStp()); @@ -98,7 +99,7 @@ private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private static int createCapabilities(CapabilitiesV10 capabilities) { + private static int createCapabilities(final CapabilitiesV10 capabilities) { Map map = new HashMap<>(); map.put(0, capabilities.isOFPCFLOWSTATS()); map.put(1, capabilities.isOFPCTABLESTATS()); @@ -120,17 +121,7 @@ private static int createActionsV10(final ActionTypeV10 action) { } - private void writeMacAddress(String macAddress, ByteBuf outBuffer) { - String[] macAddressParts = macAddress.split(":"); - byte[] macAddressBytes = new byte[6]; - for (int i = 0; i < 6; i++) { - Integer hex = Integer.parseInt(macAddressParts[i], 16); - macAddressBytes[i] = hex.byteValue(); - } - outBuffer.writeBytes(macAddressBytes); - } - - private void writeName(String name, ByteBuf outBuffer) { + private void writeName(final String name, final ByteBuf outBuffer) { byte[] nameBytes = name.getBytes(); if (nameBytes.length < 16) { byte[] nameBytesPadding = new byte[16]; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java index 4002b8fc..be88873c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java @@ -9,10 +9,10 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; @@ -30,7 +30,7 @@ public class OF10PortModInputMessageFactory implements OFSerializer map = new HashMap<>(); map.put(0, feature.is_10mbHd()); map.put(1, feature.is_10mbFd()); @@ -62,7 +63,7 @@ private void writePortFeature(PortFeaturesV10 feature, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortState(PortStateV10 state, ByteBuf outBuffer) { + private void writePortState(final PortStateV10 state, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, state.isLinkDown()); map.put(1, state.isBlocked()); @@ -76,7 +77,7 @@ private void writePortState(PortStateV10 state, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { + private void writePortConfig(final PortConfigV10 config, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, config.isPortDown()); map.put(1, config.isNoStp()); @@ -89,17 +90,7 @@ private void writePortConfig(PortConfigV10 config, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writeMacAddress(String macAddress, ByteBuf outBuffer) { - String[] macAddressParts = macAddress.split(":"); - byte[] macAddressBytes = new byte[6]; - for (int i = 0; i < 6; i++) { - Integer hex = Integer.parseInt(macAddressParts[i], 16); - macAddressBytes[i] = hex.byteValue(); - } - outBuffer.writeBytes(macAddressBytes); - } - - private void writeName(String name, ByteBuf outBuffer) { + private void writeName(final String name, final ByteBuf outBuffer) { byte[] nameBytes = name.getBytes(); if (nameBytes.length < 16) { byte[] nameBytesPadding = new byte[16]; @@ -115,7 +106,5 @@ private void writeName(String name, ByteBuf outBuffer) { } else { outBuffer.writeBytes(nameBytes); } - } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index 65364aeb..3bb2f639 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -9,13 +9,12 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import java.util.HashMap; import java.util.Map; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; @@ -36,7 +35,7 @@ public void serialize(final PortModInput message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPortNo().getValue().intValue()); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(message.getHwAddress().getValue())); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(message.getHwAddress())); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_02); outBuffer.writeInt(createPortConfigBitmask(message.getConfig())); outBuffer.writeInt(createPortConfigBitmask(message.getMask())); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java index 897db17f..e5a551c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; @@ -30,13 +31,13 @@ public class PortStatusMessageFactory implements OFSerializer private static final byte PORT_PADDING_2 = 2; @Override - public void serialize(PortStatusMessage message, ByteBuf outBuffer) { + public void serialize(final PortStatusMessage message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeZero(PADDING); outBuffer.writeInt(message.getPortNo().intValue()); outBuffer.writeZero(PORT_PADDING_1); - writeMacAddress(message.getHwAddr().getValue(), outBuffer); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(message.getHwAddr())); outBuffer.writeZero(PORT_PADDING_2); writeName(message.getName(), outBuffer); writePortConfig(message.getConfig(), outBuffer); @@ -50,7 +51,7 @@ public void serialize(PortStatusMessage message, ByteBuf outBuffer) { ByteBufUtils.updateOFHeaderLength(outBuffer); } - private void writePortConfig(PortConfig config, ByteBuf outBuffer) { + private void writePortConfig(final PortConfig config, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, config.isPortDown()); map.put(2, config.isNoRecv()); @@ -60,17 +61,7 @@ private void writePortConfig(PortConfig config, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writeMacAddress(String macAddress, ByteBuf outBuffer) { - String[] macAddressParts = macAddress.split(":"); - byte[] macAddressBytes = new byte[6]; - for (int i = 0; i < 6; i++) { - Integer hex = Integer.parseInt(macAddressParts[i], 16); - macAddressBytes[i] = hex.byteValue(); - } - outBuffer.writeBytes(macAddressBytes); - } - - private void writeName(String name, ByteBuf outBuffer) { + private void writeName(final String name, final ByteBuf outBuffer) { byte[] nameBytes = name.getBytes(); if (nameBytes.length < 16) { byte[] nameBytesPadding = new byte[16]; @@ -89,7 +80,7 @@ private void writeName(String name, ByteBuf outBuffer) { } - private void writePortState(PortState state, ByteBuf outBuffer) { + private void writePortState(final PortState state, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, state.isLinkDown()); map.put(1, state.isBlocked()); @@ -98,7 +89,7 @@ private void writePortState(PortState state, ByteBuf outBuffer) { outBuffer.writeInt(bitmap); } - private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) { + private void writePortFeatures(final PortFeatures features, final ByteBuf outBuffer) { Map map = new HashMap<>(); map.put(0, features.is_10mbHd()); map.put(1, features.is_10mbFd()); @@ -119,5 +110,4 @@ private void writePortFeatures(PortFeatures features, ByteBuf outBuffer) { int bitmap = ByteBufUtils.fillBitMaskFromMap(map); outBuffer.writeInt(bitmap); } - } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index ea9d0a5c..5dcba7ab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -8,8 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; /** * Parent for Ipv4 address based match entry serializers @@ -17,11 +18,18 @@ */ public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { - protected static void writeIpv4Address(String address, final ByteBuf out) { + /** + * @deprecated Use {@link #writeIpv4Address(Ipv4Address, ByteBuf)} instead. + */ + @Deprecated + protected static void writeIpv4Address(final String address, final ByteBuf out) { Iterable addressGroups = ByteBufUtils.DOT_SPLITTER.split(address); for (String group : addressGroups) { out.writeByte(Short.parseShort(group)); } } + protected static void writeIpv4Address(final Ipv4Address address, final ByteBuf out) { + out.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(address)); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index a665eb79..487f6009 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -8,8 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; /** @@ -18,7 +17,7 @@ */ public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { - protected void writeMacAddress(MacAddress address, ByteBuf outBuffer) { - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(address.getValue())); // 48 b + mask [OF 1.3.2 spec] + protected void writeMacAddress(final MacAddress address, final ByteBuf outBuffer) { + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(address)); // 48 b + mask [OF 1.3.2 spec] } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java index 6bdff69a..99ed4c9c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -21,10 +20,10 @@ public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { super.serialize(entry, outBuffer); ArpSpaCase entryValue = (ArpSpaCase) entry.getMatchEntryValue(); - writeIpv4Address(entryValue.getArpSpa().getIpv4Address().getValue(), outBuffer); + writeIpv4Address(entryValue.getArpSpa().getIpv4Address(), outBuffer); if (entry.isHasMask()) { writeMask(entryValue.getArpSpa().getMask(), outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java index 32ce8ffc..29e24cab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -21,10 +20,10 @@ public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { super.serialize(entry, outBuffer); ArpTpaCase entryValue = (ArpTpaCase) entry.getMatchEntryValue(); - writeIpv4Address(entryValue.getArpTpa().getIpv4Address().getValue(), outBuffer); + writeIpv4Address(entryValue.getArpTpa().getIpv4Address(), outBuffer); if (entry.isHasMask()) { writeMask(entryValue.getArpTpa().getMask(), outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java index 4a3ba4cb..9e1c00b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -21,10 +20,10 @@ public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { super.serialize(entry, outBuffer); Ipv4DstCase entryValue = (Ipv4DstCase) entry.getMatchEntryValue(); - writeIpv4Address(entryValue.getIpv4Dst().getIpv4Address().getValue(), outBuffer); + writeIpv4Address(entryValue.getIpv4Dst().getIpv4Address(), outBuffer); if (entry.isHasMask()) { writeMask(entryValue.getIpv4Dst().getMask(), outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java index 08bca868..42667ee0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; @@ -21,10 +20,10 @@ public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { @Override - public void serialize(MatchEntry entry, ByteBuf outBuffer) { + public void serialize(final MatchEntry entry, final ByteBuf outBuffer) { super.serialize(entry, outBuffer); Ipv4SrcCase entryValue = (Ipv4SrcCase) entry.getMatchEntryValue(); - writeIpv4Address(entryValue.getIpv4Src().getIpv4Address().getValue(), outBuffer); + writeIpv4Address(entryValue.getIpv4Src().getIpv4Address(), outBuffer); if (entry.isHasMask()) { writeMask(entryValue.getIpv4Src().getMask(), outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index b0a4f41c..7ff074ae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -9,12 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; @@ -42,12 +38,8 @@ public MatchV10 deserialize(final ByteBuf input) { builder.setNwSrcMask(decodeNwSrcMask(wildcards)); builder.setNwDstMask(decodeNwDstMask(wildcards)); builder.setInPort(input.readUnsignedShort()); - byte[] dlSrc = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(dlSrc); - builder.setDlSrc(new MacAddress(ByteBufUtils.macAddressToString(dlSrc))); - byte[] dlDst = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(dlDst); - builder.setDlDst(new MacAddress(ByteBufUtils.macAddressToString(dlDst))); + builder.setDlSrc(ByteBufUtils.readIetfMacAddress(input)); + builder.setDlDst(ByteBufUtils.readIetfMacAddress(input)); builder.setDlVlan(input.readUnsignedShort()); builder.setDlVlanPcp(input.readUnsignedByte()); @@ -56,8 +48,8 @@ public MatchV10 deserialize(final ByteBuf input) { builder.setNwTos(input.readUnsignedByte()); builder.setNwProto(input.readUnsignedByte()); input.skipBytes(PADDING_IN_MATCH_2); - builder.setNwSrc(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - builder.setNwDst(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + builder.setNwSrc(ByteBufUtils.readIetfIpv4Address(input)); + builder.setNwDst(ByteBufUtils.readIetfIpv4Address(input)); builder.setTpSrc(input.readUnsignedShort()); builder.setTpDst(input.readUnsignedShort()); return builder.build(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index 830753ea..be005f06 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -9,9 +9,10 @@ package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; @@ -35,8 +36,8 @@ public class OF10MatchSerializer implements OFSerializer { public void serialize(final MatchV10 match, final ByteBuf outBuffer) { outBuffer.writeInt(encodeWildcards(match.getWildcards(), match.getNwSrcMask(), match.getNwDstMask())); outBuffer.writeShort(match.getInPort()); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlSrc().getValue())); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(match.getDlDst().getValue())); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(match.getDlSrc())); + outBuffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(match.getDlDst())); outBuffer.writeShort(match.getDlVlan()); outBuffer.writeByte(match.getDlVlanPcp()); outBuffer.writeZero(PADDING_IN_MATCH); @@ -44,14 +45,8 @@ public void serialize(final MatchV10 match, final ByteBuf outBuffer) { outBuffer.writeByte(match.getNwTos()); outBuffer.writeByte(match.getNwProto()); outBuffer.writeZero(PADDING_IN_MATCH_2); - Iterable srcGroups = ByteBufUtils.DOT_SPLITTER.split(match.getNwSrc().getValue()); - for (String group : srcGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } - Iterable dstGroups = ByteBufUtils.DOT_SPLITTER.split(match.getNwDst().getValue()); - for (String group : dstGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } + outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(match.getNwSrc())); + outBuffer.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(match.getNwDst())); outBuffer.writeShort(match.getTpSrc()); outBuffer.writeShort(match.getTpDst()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java index 92c16dcb..5f910a97 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -98,7 +98,7 @@ private static MatchV10 createMatch() { matchBuilder.setNwDstMask((short) 0); matchBuilder.setInPort(58); matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01")); - matchBuilder.setDlDst(new MacAddress("FF:FF:FF:FF:FF:FF")); + matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff")); matchBuilder.setDlVlan(18); matchBuilder.setDlVlanPcp((short) 5); matchBuilder.setDlType(42); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java index e4a3a801..175245de 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java @@ -45,7 +45,7 @@ public void test() { PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV10(deserializedMessage); Assert.assertEquals("Wrong port", new PortNumber(6633L), deserializedMessage.getPortNo()); - Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress()); + Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress()); Assert.assertEquals("Wrong config", new PortConfigV10(true, false, false, true, false, false, true), deserializedMessage.getConfigV10()); Assert.assertEquals("Wrong mask", new PortConfigV10(false, true, true, false, false, true, false), diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java index 6c4850c0..6a0c9740 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java @@ -47,7 +47,7 @@ public void test() throws Exception { // Test Message Assert.assertEquals("Wrong port", new PortNumber(9L), deserializedMessage.getPortNo()); - Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:B0:EB"), deserializedMessage.getHwAddress()); + Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress()); Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig()); Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask()); Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true, diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index 67f9b266..c3b16b9c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -72,7 +72,7 @@ public void test(){ BufferHelper.checkHeaderV13(builtByFactory); Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue()); Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), builtByFactory.getHwAddr()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), builtByFactory.getHwAddr()); Assert.assertEquals("Wrong name", "s1-eth1", builtByFactory.getName()); Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig()); Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState()); @@ -118,4 +118,4 @@ public void testWithDifferentBitmaps(){ false, false, false, false, false, false, false, false, false, false, false, false), message.getPeerFeatures()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java index f397831d..3f04e709 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -88,7 +88,7 @@ public void testMultipartReplyPortDesc() { Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); Ports port = message.getPorts().get(0); Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr()); Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); @@ -104,7 +104,7 @@ public void testMultipartReplyPortDesc() { Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); port = message.getPorts().get(1); Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr()); Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); @@ -119,4 +119,4 @@ public void testMultipartReplyPortDesc() { Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 4519deed..6fa7be12 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -161,7 +161,7 @@ public void testIpv6Address() { key.setExperimenterId(null); OFDeserializer entryDeserializer = registry.getDeserializer(key); MatchEntry entry = entryDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), + Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0:1:2:3:4:5:6:f07"), ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address()); } @@ -401,7 +401,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("::15"), ((Ipv6SrcCase) entry26.getMatchEntryValue()).getIpv6Src().getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), @@ -410,7 +410,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("::17"), ((Ipv6DstCase) entry27.getMatchEntryValue()).getIpv6Dst().getIpv6Address()); Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), @@ -438,7 +438,7 @@ public void testMatch() { Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), + Assert.assertEquals("Wrong entry value", new Ipv6Address("::20"), ((Ipv6NdTargetCase) entry31.getMatchEntryValue()).getIpv6NdTarget().getIpv6Address()); MatchEntry entry32 = entries.get(32); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); @@ -528,4 +528,4 @@ public void testStandardMatch() { Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntry().size()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index fdb15dd4..9bc4b84b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -8,16 +8,13 @@ package org.opendaylight.openflowjava.protocol.impl.util; import io.netty.buffer.ByteBuf; - import java.util.List; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; @@ -91,14 +88,12 @@ public void test() { Assert.assertTrue("Wrong action type", action4.getActionChoice() instanceof StripVlanCase); Action action5 = actions.get(4); Assert.assertTrue("Wrong action type", action5.getActionChoice() instanceof SetDlSrcCase); - Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), - ByteBufUtils.macAddressToBytes(((SetDlSrcCase) action5.getActionChoice()) - .getSetDlSrcAction().getDlSrcAddress().getValue())); + Assert.assertEquals("Wrong dl-src", "01:02:03:04:05:06", + ((SetDlSrcCase) action5.getActionChoice()).getSetDlSrcAction().getDlSrcAddress().getValue()); Action action6 = actions.get(5); Assert.assertTrue("Wrong action type", action6.getActionChoice() instanceof SetDlDstCase); - Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), - ByteBufUtils.macAddressToBytes(((SetDlDstCase) action6.getActionChoice()) - .getSetDlDstAction().getDlDstAddress().getValue())); + Assert.assertEquals("Wrong dl-dst", "02:03:04:05:06:07", + ((SetDlDstCase) action6.getActionChoice()).getSetDlDstAction().getDlDstAddress().getValue()); Action action7 = actions.get(6); Assert.assertTrue("Wrong action type", action7.getActionChoice() instanceof SetNwSrcCase); Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 83242ce4..09a5c19f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -57,8 +57,8 @@ public void test() { Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue()); Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue()); Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue()); - Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc()); - Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst()); + Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc()); + Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst()); Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue()); Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue()); Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue()); @@ -85,8 +85,8 @@ public void test2() { Assert.assertEquals("Wrong srcMask", 0, match.getNwSrcMask().shortValue()); Assert.assertEquals("Wrong dstMask", 0, match.getNwDstMask().shortValue()); Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue()); - Assert.assertEquals("Wrong dl-src", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlSrc()); - Assert.assertEquals("Wrong dl-dst", new MacAddress("AA:BB:CC:DD:EE:FF"), match.getDlDst()); + Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc()); + Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst()); Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue()); Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue()); Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue()); diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index d68f6f9c..032d87f9 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -19,6 +19,11 @@ import java.util.Map; import java.util.Map.Entry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; /** Class for common operations on ByteBuf @@ -324,6 +329,7 @@ public static String readIpv4Address(final ByteBuf buf) { return sb.toString(); } + /** * Read an IPv6 address from a buffer and format it into a string of eight groups of four * hexadecimal digits separated by colons. @@ -342,4 +348,22 @@ public static String readIpv6Address(final ByteBuf buf) { return sb.toString(); } + + public static Ipv4Address readIetfIpv4Address(final ByteBuf buf) { + final byte[] tmp = new byte[4]; + buf.readBytes(tmp); + return IetfInetUtil.INSTANCE.ipv4AddressFor(tmp); + } + + public static Ipv6Address readIetfIpv6Address(final ByteBuf buf) { + final byte[] tmp = new byte[16]; + buf.readBytes(tmp); + return IetfInetUtil.INSTANCE.ipv6AddressFor(tmp); + } + + public static MacAddress readIetfMacAddress(final ByteBuf buf) { + final byte[] tmp = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + buf.readBytes(tmp); + return IetfYangUtil.INSTANCE.macAddressFor(tmp); + } } From 779ec4afee27cc948485f0778d8b3380fbe01379 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 2 Feb 2016 15:20:27 +0100 Subject: [PATCH 225/285] Bug 4614 - Reintroduce xid check for correct RPC handling Change-Id: I259147af4cbcab5115083df690edfa3cd3c8b5b9 Signed-off-by: Michal Polkorab (cherry picked from commit 867607566914d5b8a79e161eb0a40c4be9e01746) --- .../protocol/impl/core/connection/RpcResponseKey.java | 2 ++ .../protocol/impl/core/connection/RpcResponseKeyTest.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java index 9cd482b1..050f3cf7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java @@ -68,6 +68,8 @@ public boolean equals(Object obj) { } } else if (!outputClazz.equals(other.outputClazz)) { return false; + } else if (xid != other.getXid()) { + return false; } return true; } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java index 0b816c25..2ef9cb82 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKeyTest.java @@ -40,6 +40,8 @@ public void testEquals(){ key1 = new RpcResponseKey(xid1, outputClazz1); Assert.assertFalse("Wrong equal by outputClazz.", key1.equals(key2)); key2 = new RpcResponseKey(xid2, outputClazz1); + Assert.assertFalse("Wrong equal.", key1.equals(key2)); + key1 = new RpcResponseKey(xid2, outputClazz1); Assert.assertTrue("Wrong equal.", key1.equals(key2)); } From 3a9dc6618aac4d9d498d91d1a7fb240619ddcc39 Mon Sep 17 00:00:00 2001 From: Rashmi Pujar Date: Thu, 18 Feb 2016 17:30:50 -0500 Subject: [PATCH 226/285] Bug 5377: Support configuring cipher suites to use for SSLEngine Change-Id: I8d573de8e5fd64f48776e274b75ff418a62bee1d Signed-off-by: Rashmi Pujar --- .../protocol/api/connection/TlsConfiguration.java | 7 +++++++ .../api/connection/TlsConfigurationImpl.java | 12 +++++++++++- .../api/connection/TlsConfigurationImplTest.java | 8 +++++++- .../protocol/impl/core/TcpChannelInitializer.java | 8 ++++++++ .../rev140328/SwitchConnectionProviderModule.java | 6 ++++++ .../openflow-switch-connection-provider-impl.yang | 4 ++++ .../PublishingChannelInitializerFactoryTest.java | 5 ++++- .../impl/core/PublishingChannelInitializerTest.java | 5 ++++- .../protocol/impl/core/SslContextFactoryTest.java | 5 ++++- .../SwitchConnectionProviderImpl02Test.java | 4 +++- .../connection/SwitchConnectionProviderImplTest.java | 4 +++- .../protocol/it/integration/IntegrationTest.java | 3 ++- 12 files changed, 63 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index 6676dd02..f5a71a8c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.api.connection; +import java.util.List; + import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; @@ -62,4 +64,9 @@ public interface TlsConfiguration { * @return password protecting specified truststore */ String getTruststorePassword(); + + /** + * @return list of cipher suites for TLS connection + */ + List getCipherSuites(); } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java index 78a6c6b8..2a290140 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.api.connection; +import java.util.List; + import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; @@ -23,6 +25,7 @@ public class TlsConfigurationImpl implements TlsConfiguration { private String keyStore; private PathType keystorePathType; private PathType truststorePathType; + private List cipherSuites; /** * Default constructor @@ -35,13 +38,15 @@ public class TlsConfigurationImpl implements TlsConfiguration { */ public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, PathType trustStorePathType, KeystoreType keyStoreType, - String keyStore, PathType keyStorePathType) { + String keyStore, PathType keyStorePathType, + List cipherSuites) { this.trustStoreType = trustStoreType; this.trustStore = trustStore; this.truststorePathType = trustStorePathType; this.keyStoreType = keyStoreType; this.keyStore = keyStore; this.keystorePathType = keyStorePathType; + this.cipherSuites = cipherSuites; } @Override @@ -88,4 +93,9 @@ public String getCertificatePassword() { public String getTruststorePassword() { return "opendaylight"; } + + @Override + public List getCipherSuites() { + return cipherSuites; + } } diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java index f71d2302..be52a188 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java @@ -10,10 +10,14 @@ import static org.junit.Assert.*; +import java.util.List; + import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import com.google.common.collect.Lists; + /** * @author michal.polkorab * @@ -25,8 +29,9 @@ public class TlsConfigurationImplTest { */ @Test public void test() { + List cipherSuites = Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256"); TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, - "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); + "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH, cipherSuites); assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); @@ -36,5 +41,6 @@ public void test() { assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); + assertEquals("Wrong cipher suites", cipherSuites, config.getCipherSuites()); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 18566eb2..881f697a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -16,6 +16,7 @@ import io.netty.util.concurrent.GenericFutureListener; import java.net.InetAddress; import java.util.Iterator; +import java.util.List; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLEngine; import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; @@ -84,6 +85,13 @@ protected void initChannel(final SocketChannel ch) { final SSLEngine engine = sslFactory.getServerContext().createSSLEngine(); engine.setNeedClientAuth(true); engine.setUseClientMode(false); + List suitesList = getTlsConfiguration().getCipherSuites(); + if (suitesList != null && !suitesList.isEmpty()) { + LOGGER.debug("Requested Cipher Suites are: {}", suitesList); + String[] suites = suitesList.toArray(new String[suitesList.size()]); + engine.setEnabledCipherSuites(suites); + LOGGER.debug("Cipher suites enabled in SSLEngine are: {}", engine.getEnabledCipherSuites().toString()); + } final SslHandler ssl = new SslHandler(engine); final Future handshakeFuture = ssl.handshakeFuture(); final ConnectionFacade finalConnectionFacade = connectionFacade; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 6077c787..6ded9bfb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -12,6 +12,8 @@ import com.google.common.base.MoreObjects; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.List; + import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; @@ -136,6 +138,10 @@ public String getCertificatePassword() { public String getTruststorePassword() { return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null); } + @Override + public List getCipherSuites() { + return tlsConfig.getCipherSuites(); + } }; } @Override diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index aead1758..1610ff1b 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -97,6 +97,10 @@ module openflow-switch-connection-provider-impl { description "password protecting truststore"; type string; } + leaf-list cipher-suites { + description "combination of cryptographic algorithms used by TLS connection"; + type string; + } } container threads { leaf boss-threads { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java index 6001e7f8..48697240 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerFactoryTest.java @@ -22,6 +22,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import com.google.common.collect.Lists; + /** * * @author jameshall @@ -43,7 +45,8 @@ public void setUp() { MockitoAnnotations.initMocks(this); factory = new ChannelInitializerFactory(); tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", - PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH); + PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH, + Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); factory.setDeserializationFactory(deserializationFactory); factory.setSerializationFactory(serializationFactory); factory.setSwitchConnectionHandler(switchConnectionHandler); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java index bcd2ebb9..b855cc91 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/PublishingChannelInitializerTest.java @@ -39,6 +39,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.Tls; +import com.google.common.collect.Lists; + /** * * @author james.hall @@ -89,7 +91,8 @@ public void setUp() throws Exception { when(mockSocketCh.pipeline()).thenReturn(mockChPipeline) ; tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, - KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH); + KeystoreType.JKS, "/selfSignedController", PathType.CLASSPATH, + Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java index a52f44c6..c73f6c63 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactoryTest.java @@ -20,6 +20,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import com.google.common.collect.Lists; + /** * * @author jameshall @@ -36,7 +38,8 @@ public class SslContextFactoryTest { public void setUp() { MockitoAnnotations.initMocks(this); tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/exemplary-ctlTrustStore", - PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH) ; + PathType.CLASSPATH, KeystoreType.JKS, "/exemplary-ctlKeystore", PathType.CLASSPATH, + Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; sslContextFactory = new SslContextFactory(tlsConfiguration); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 447f464b..302c3e90 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -7,6 +7,7 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; @@ -92,7 +93,8 @@ private void createConfig(final TransportProtocol protocol) { if (protocol.equals(TransportProtocol.TLS)) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, - "/selfSignedController", PathType.CLASSPATH) ; + "/selfSignedController", PathType.CLASSPATH, + Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; } config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); config.setTransferProtocol(protocol); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 3b53eed6..491e18de 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; @@ -65,7 +66,8 @@ private void createConfig(final TransportProtocol protocol) { if (protocol.equals(TransportProtocol.TLS)) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, - "/selfSignedController", PathType.CLASSPATH) ; + "/selfSignedController", PathType.CLASSPATH, + Lists.newArrayList("TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256")) ; } config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); config.setTransferProtocol(protocol); diff --git a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java index e10d12de..77e747a9 100644 --- a/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java +++ b/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java @@ -74,7 +74,8 @@ public void setUp(final TransportProtocol protocol) throws Exception { if (protocol.equals(TransportProtocol.TLS)) { tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, - "/selfSignedController", PathType.CLASSPATH) ; + "/selfSignedController", PathType.CLASSPATH, + new ArrayList()); } connConfig = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT, true); connConfig.setTransferProtocol(protocol); From 3183810b0ec6075f1cf0d2752f8f488916d29acc Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 27 Jan 2016 02:08:19 +0100 Subject: [PATCH 227/285] Bug 5118 - Unsent messages reported as failed after disconnect - if there were messages delivered to OutboundQueue and disconnect occured, unsent messages were not marked as failed, resulting in incorrect / no report - channelInactive in AbstractOutboundQueueManager was never triggered as the event was consumed in DelegatingInboundHandler Change-Id: Ifd64c8f9346534a934d49a88ddd5c8f71cbb01e7 Signed-off-by: Michal Polkorab (cherry picked from commit 25677520a3fca1a925a0970efa20d586e1445e6f) --- .../protocol/impl/core/PipelineHandlers.java | 4 +- .../AbstractOutboundQueueManager.java | 8 ++++ .../AbstractStackedOutboundQueue.java | 38 ++++++++++++++----- .../connection/ConnectionAdapterImpl.java | 6 ++- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java index 51ac5482..88144d47 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java @@ -44,9 +44,9 @@ public enum PipelineHandlers { */ DELEGATING_INBOUND_HANDLER, /** - * Performs efficient flushing + * Performs configurable efficient flushing */ - CHANNEL_OUTBOUNF_QUEUE, + CHANNEL_OUTBOUND_QUEUE_MANAGER, /** * Decodes incoming messages into message frames * and filters them based on version supported diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 8febb158..fdcc1f3e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -163,14 +163,22 @@ public void channelWritabilityChanged(final ChannelHandlerContext ctx) throws Ex @Override public void channelInactive(final ChannelHandlerContext ctx) throws Exception { + // First of all, delegates disconnect event notification into ConnectionAdapter -> OF Plugin -> queue.close() + // -> queueHandler.onConnectionQueueChanged(null). The last call causes that no more entries are enqueued + // in the queue. super.channelInactive(ctx); LOG.debug("Channel {} initiating shutdown...", ctx.channel()); + // Then we start queue shutdown, start counting written messages (so that we don't keep sending messages + // indefinitely) and failing not completed entries. shuttingDown = true; final long entries = currentQueue.startShutdown(ctx.channel()); LOG.debug("Cleared {} queue entries from channel {}", entries, ctx.channel()); + // Finally, we schedule flush task that will take care of unflushed entries. We also cover the case, + // when there is more than shutdownOffset messages enqueued in unflushed segments + // (AbstractStackedOutboundQueue#finishShutdown()). scheduleFlush(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index a32c1ad1..75963335 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -260,16 +260,31 @@ long startShutdown(final Channel channel) { final long xid = LAST_XID_OFFSET_UPDATER.addAndGet(this, StackedSegment.SEGMENT_SIZE); shutdownOffset = (int) (xid - firstSegment.getBaseXid() - StackedSegment.SEGMENT_SIZE); - return lockedShutdownFlush(); + // Fails all uncompleted entries, because they will never be completed due to disconnected channel. + return lockedFailSegments(uncompletedSegments.iterator()); } } + /** + * Checks if the shutdown is in final phase -> all allowed entries (number of entries < shutdownOffset) are flushed + * and fails all not completed entries (if in final phase) + * @return true if in final phase, false if a flush is needed + */ boolean finishShutdown() { + boolean needsFlush; synchronized (unflushedSegments) { - lockedShutdownFlush(); + // Fails all entries, that were flushed in shutdownOffset (became uncompleted) + // - they will never be completed due to disconnected channel. + lockedFailSegments(uncompletedSegments.iterator()); + // If no further flush is needed, than we fail all unflushed segments, so that each enqueued entry + // is reported as unsuccessful due to channel disconnection. No further entries should be enqueued + // by this time. + needsFlush = needsFlush(); + if (!needsFlush) { + lockedFailSegments(unflushedSegments.iterator()); + } } - - return !needsFlush(); + return !needsFlush; } protected OutboundQueueEntry getEntry(final Long xid) { @@ -302,22 +317,27 @@ protected OutboundQueueEntry getEntry(final Long xid) { return fastSegment.getEntry(fastOffset); } + /** + * Fails not completed entries in segments and frees completed segments + * @param iterator list of segments to be failed + * @return number of failed entries + */ @GuardedBy("unflushedSegments") - private long lockedShutdownFlush() { + private long lockedFailSegments(Iterator iterator) { long entries = 0; // Fail all queues - final Iterator it = uncompletedSegments.iterator(); - while (it.hasNext()) { - final StackedSegment segment = it.next(); + while (iterator.hasNext()) { + final StackedSegment segment = iterator.next(); entries += segment.failAll(OutboundQueueException.DEVICE_DISCONNECTED); if (segment.isComplete()) { LOG.trace("Cleared segment {}", segment); - it.remove(); + iterator.remove(); } } return entries; } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 37635c03..7c10be16 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -203,7 +203,11 @@ public OutboundQueueHandlerRegistration regi outputManager = ret; /* we don't need it anymore */ channel.pipeline().remove(output); - channel.pipeline().addLast(outputManager); + // OutboundQueueManager is put before DelegatingInboundHandler because otherwise channelInactive event would + // be first processed in OutboundQueueManager and then in ConnectionAdapter (and Openflowplugin). This might + // cause problems because we are shutting down the queue before Openflowplugin knows about it. + channel.pipeline().addBefore(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), + PipelineHandlers.CHANNEL_OUTBOUND_QUEUE_MANAGER.name(), outputManager); return new OutboundQueueHandlerRegistrationImpl(handler) { @Override From 001718df723036230d70ef6bba8eb4ce1a6f30bd Mon Sep 17 00:00:00 2001 From: Mike Kolesnik Date: Tue, 15 Mar 2016 11:51:43 +0200 Subject: [PATCH 228/285] Use controller.mdsal.version when appropriate Use the property controller.mdsal.version when looking for mdsal artifacts from org.opendaylight.controller. Otherwise, it's confusing since mdsal.version actually referrs to artifacts from org.opendaylight.mdsal. Change-Id: I58019ccb199ba1aa5ace515d6f2601c93f9b21b5 Signed-off-by: Mike Kolesnik --- parent/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 103a32fb..1554d92b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -56,7 +56,7 @@ ${project.build.directory}/yang-gen-sal 0.5.0-SNAPSHOT - 1.4.0-SNAPSHOT + 1.4.0-SNAPSHOT 0.9.0-SNAPSHOT 1.0.0-SNAPSHOT @@ -87,7 +87,7 @@ org.opendaylight.controller mdsal-artifacts - ${mdsal.version} + ${controller.mdsal.version} import pom From 7b63f30a8fb6f192c10803af2949a55a9d5777bf Mon Sep 17 00:00:00 2001 From: Dileep Date: Mon, 28 Mar 2016 07:49:12 -0700 Subject: [PATCH 229/285] Bug 3230 - Attempt to use Epoll native transport if available Attempts to use Epoll native transport if available. Uses Epoll.isAvailable() to check availability. Refer : http://netty.io/wiki/native-transports.html Change-Id: I0019a084b0f2410f4cea7d5541fe0e5b49699bec Depends-on: I073093f9a7b28de9890a6842f8bef72d4fdf6872 Signed-off-by: Dileep Ranganathan --- features/pom.xml | 6 + openflow-protocol-impl/pom.xml | 6 + .../core/SwitchConnectionProviderImpl.java | 15 ++- .../impl/core/TcpConnectionInitializer.java | 16 ++- .../protocol/impl/core/TcpHandler.java | 59 ++++++++- .../impl/core/UdpChannelInitializer.java | 6 +- .../protocol/impl/core/UdpHandler.java | 58 ++++++++- .../protocol/impl/core/TcpHandlerTest.java | 115 ++++++++++++++++-- .../SwitchConnectionProviderImplTest.java | 2 +- .../impl/core/connection/UdpHandlerTest.java | 53 +++++++- .../impl/clients/SimpleClientInitializer.java | 6 +- .../clients/UdpSimpleClientInitializer.java | 6 +- 12 files changed, 302 insertions(+), 46 deletions(-) diff --git a/features/pom.xml b/features/pom.xml index 62dc813d..f35b4d8a 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -156,6 +156,12 @@ io.netty netty-transport + + io.netty + netty-transport-native-epoll + + linux-x86_64 + diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index a125a931..0c3fc442 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -150,5 +150,11 @@ org.opendaylight.controller config-api + + io.netty + netty-transport-native-epoll + + linux-x86_64 + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index aa79e6a3..411a9b43 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -11,7 +11,8 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.epoll.Epoll; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -134,18 +135,24 @@ private ServerFacade createAndConfigureServer() { factory.setDeserializationFactory(deserializationFactory); factory.setUseBarrier(connConfig.useBarrier()); final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol(); + + // Check if Epoll native transport is available. + // TODO : Add option to disable Epoll. + boolean isEpollEnabled = Epoll.isAvailable(); + if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer(); ((TcpHandler) server).setChannelInitializer(channelInitializer); - ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration()); + ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled); - final NioEventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup(); - connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler); + final EventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup(); + connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled); connectionInitializer.setChannelInitializer(channelInitializer); connectionInitializer.run(); } else if (transportProtocol.equals(TransportProtocol.UDP)){ server = new UdpHandler(connConfig.getAddress(), connConfig.getPort()); + ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled); ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer()); } else { throw new IllegalStateException("Unknown transport protocol received: " + transportProtocol); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java index c4b0937e..c5905d60 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java @@ -2,9 +2,8 @@ import io.netty.bootstrap.Bootstrap; import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.epoll.EpollSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; - import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,21 +27,28 @@ public class TcpConnectionInitializer implements ServerFacade, private TcpChannelInitializer channelInitializer; private Bootstrap b; + private boolean isEpollEnabled; /** * Constructor * @param workerGroup - shared worker group */ - public TcpConnectionInitializer(NioEventLoopGroup workerGroup) { + public TcpConnectionInitializer(EventLoopGroup workerGroup, boolean isEpollEnabled) { Preconditions.checkNotNull(workerGroup, "WorkerGroup can't be null"); this.workerGroup = workerGroup; + this.isEpollEnabled = isEpollEnabled; } @Override public void run() { b = new Bootstrap(); - b.group(workerGroup).channel(NioSocketChannel.class) - .handler(channelInitializer); + if(isEpollEnabled) { + b.group(workerGroup).channel(EpollSocketChannel.class) + .handler(channelInitializer); + } else { + b.group(workerGroup).channel(NioSocketChannel.class) + .handler(channelInitializer); + } } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index ff4bc6a1..00a3fd71 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -13,11 +13,17 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; import io.netty.util.concurrent.GenericFutureListener; +import io.netty.channel.epoll.Epoll; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.epoll.EpollEventLoopGroup; +import io.netty.channel.epoll.EpollServerSocketChannel; + import java.net.InetAddress; import java.net.InetSocketAddress; @@ -50,13 +56,15 @@ public class TcpHandler implements ServerFacade { private int port; private String address; private final InetAddress startupAddress; - private NioEventLoopGroup workerGroup; - private NioEventLoopGroup bossGroup; + private EventLoopGroup workerGroup; + private EventLoopGroup bossGroup; private final SettableFuture isOnlineFuture; private ThreadConfiguration threadConfig; private TcpChannelInitializer channelInitializer; + private Class socketChannelClass; + /** * Constructor of TCPHandler that listens on selected port. * @@ -90,13 +98,13 @@ public void run() { * Any other setting means netty will measure the time it spent selecting * and spend roughly proportional time executing tasks. */ - workerGroup.setIoRatio(100); + //workerGroup.setIoRatio(100); final ChannelFuture f; try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) + .channel(socketChannelClass) .handler(new LoggingHandler(LogLevel.DEBUG)) .childHandler(channelInitializer) .option(ChannelOption.SO_BACKLOG, 128) @@ -202,7 +210,21 @@ public void setThreadConfig(ThreadConfiguration threadConfig) { * Initiate event loop groups * @param threadConfiguration number of threads to be created, if not specified in threadConfig */ - public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration) { + public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration, boolean isEpollEnabled) { + + if(isEpollEnabled) { + initiateEpollEventLoopGroups(threadConfiguration); + } else { + initiateNioEventLoopGroups(threadConfiguration); + } + } + + /** + * Initiate Nio event loop groups + * @param threadConfiguration number of threads to be created, if not specified in threadConfig + */ + public void initiateNioEventLoopGroups(ThreadConfiguration threadConfiguration) { + socketChannelClass = NioServerSocketChannel.class; if (threadConfiguration != null) { bossGroup = new NioEventLoopGroup(threadConfiguration.getBossThreadCount()); workerGroup = new NioEventLoopGroup(threadConfiguration.getWorkerThreadCount()); @@ -210,12 +232,37 @@ public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration) { bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); } + ((NioEventLoopGroup)workerGroup).setIoRatio(100); + } + + /** + * Initiate Epoll event loop groups with Nio as fall back + * @param threadConfiguration + */ + protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfiguration) { + try { + socketChannelClass = EpollServerSocketChannel.class; + if (threadConfiguration != null) { + bossGroup = new EpollEventLoopGroup(threadConfiguration.getBossThreadCount()); + workerGroup = new EpollEventLoopGroup(threadConfiguration.getWorkerThreadCount()); + } else { + bossGroup = new EpollEventLoopGroup(); + workerGroup = new EpollEventLoopGroup(); + } + ((EpollEventLoopGroup)workerGroup).setIoRatio(100); + return; + } catch (Throwable ex) { + LOGGER.debug("Epoll initiation failed"); + } + + //Fallback mechanism + initiateNioEventLoopGroups(threadConfiguration); } /** * @return workerGroup */ - public NioEventLoopGroup getWorkerGroup() { + public EventLoopGroup getWorkerGroup() { return workerGroup; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java index ba1650e5..ccb8b06c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java @@ -8,16 +8,16 @@ package org.opendaylight.openflowjava.protocol.impl.core; -import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.channel.socket.DatagramChannel; /** * @author michal.polkorab * */ -public class UdpChannelInitializer extends ProtocolChannelInitializer { +public class UdpChannelInitializer extends ProtocolChannelInitializer { @Override - protected void initChannel(NioDatagramChannel ch) throws Exception { + protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), new OFDatagramPacketHandler(getSwitchConnectionHandler())); OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 3e6e384e..9339ba16 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -12,7 +12,10 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoopGroup; +import io.netty.channel.epoll.EpollDatagramChannel; +import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.DatagramChannel; import io.netty.channel.socket.nio.NioDatagramChannel; import io.netty.util.concurrent.GenericFutureListener; @@ -41,6 +44,7 @@ public final class UdpHandler implements ServerFacade { private final SettableFuture isOnlineFuture; private UdpChannelInitializer channelInitializer; private ThreadConfiguration threadConfig; + private Class datagramChannelClass; /** * Constructor of UdpHandler that listens on selected port. @@ -64,16 +68,11 @@ public UdpHandler(final InetAddress address, final int port) { @Override public void run() { - if (threadConfig != null) { - group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); - } else { - group = new NioEventLoopGroup(); - } final ChannelFuture f; try { Bootstrap b = new Bootstrap(); b.group(group) - .channel(NioDatagramChannel.class) + .channel(datagramChannelClass) .option(ChannelOption.SO_BROADCAST, false) .handler(channelInitializer); @@ -146,4 +145,51 @@ public void setChannelInitializer(UdpChannelInitializer channelInitializer) { public void setThreadConfig(ThreadConfiguration threadConfig) { this.threadConfig = threadConfig; } + + /** + * Initiate event loop groups + * @param threadConfiguration number of threads to be created, if not specified in threadConfig + */ + public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration, boolean isEpollEnabled) { + + if(isEpollEnabled) { + initiateEpollEventLoopGroups(threadConfiguration); + } else { + initiateNioEventLoopGroups(threadConfiguration); + } + } + + /** + * Initiate Nio event loop groups + * @param threadConfiguration number of threads to be created, if not specified in threadConfig + */ + public void initiateNioEventLoopGroups(ThreadConfiguration threadConfiguration) { + datagramChannelClass = NioDatagramChannel.class; + if (threadConfiguration != null) { + group = new NioEventLoopGroup(threadConfiguration.getWorkerThreadCount()); + } else { + group = new NioEventLoopGroup(); + } + } + + /** + * Initiate Epoll event loop groups with Nio as fall back + * @param threadConfiguration + */ + protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfiguration) { + try { + datagramChannelClass = EpollDatagramChannel.class; + if (threadConfiguration != null) { + group = new EpollEventLoopGroup(threadConfiguration.getWorkerThreadCount()); + } else { + group = new EpollEventLoopGroup(); + } + return; + } catch (Throwable ex) { + LOGGER.debug("Epoll initiation failed"); + } + + //Fallback mechanism + initiateNioEventLoopGroups(threadConfiguration); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java index 6d103355..6faad908 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java @@ -18,6 +18,7 @@ import java.net.Socket; import java.util.concurrent.ExecutionException; +import io.netty.channel.unix.Errors; import org.junit.Assert; import org.junit.Test; import org.mockito.Mock; @@ -62,7 +63,25 @@ public void testRunWithNullAddress() throws IOException, InterruptedException, E tcpHandler = new TcpHandler(null, 0); tcpHandler.setChannelInitializer(mockChannelInitializer); - assertEquals("failed to start server", true, startupServer()) ; + assertEquals("failed to start server", true, startupServer(false)) ; + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; + shutdownServer(); + } + + /** + * Test run with null address set on Epoll native transport + * @throws IOException + * @throws InterruptedException + * @throws ExecutionException + */ + @Test + public void testRunWithNullAddressOnEpoll() throws IOException, InterruptedException, ExecutionException { + + tcpHandler = new TcpHandler(null, 0); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + //Use Epoll native transport + assertEquals("failed to start server", true, startupServer(true)) ; assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; shutdownServer(); } @@ -79,11 +98,29 @@ public void testRunWithAddress() throws IOException, InterruptedException, Execu tcpHandler = new TcpHandler(serverAddress, 0); tcpHandler.setChannelInitializer(mockChannelInitializer); - assertEquals("failed to start server", true, startupServer()) ; + assertEquals("failed to start server", true, startupServer(false)) ; assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; shutdownServer(); } + /** + * Test run with address set on Epoll native transport + * @throws IOException + * @throws InterruptedException + * @throws ExecutionException + */ + @Test + public void testRunWithAddressOnEpoll() throws IOException, InterruptedException, ExecutionException { + + tcpHandler = new TcpHandler(serverAddress, 0); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + //Use Epoll native transport + assertEquals("failed to start server", true, startupServer(true)); + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())); + shutdownServer(); + } + /** * Test run with encryption * @throws InterruptedException @@ -91,17 +128,40 @@ public void testRunWithAddress() throws IOException, InterruptedException, Execu * @throws ExecutionException */ @Test - public void testRunWithEncryption () throws InterruptedException, IOException, ExecutionException { + public void testRunWithEncryption() throws InterruptedException, IOException, ExecutionException { int serverPort = 28001; tcpHandler = new TcpHandler(serverAddress, serverPort); tcpHandler.setChannelInitializer(mockChannelInitializer); - assertEquals( "failed to start server", true, startupServer()) ; - assertEquals( "wrong connection count", 0, tcpHandler.getNumberOfConnections() ); - assertEquals( "wrong port", serverPort, tcpHandler.getPort() ); - assertEquals( "wrong address", serverAddress.getHostAddress(), tcpHandler.getAddress()) ; + assertEquals( "failed to start server", true, startupServer(false)); + assertEquals( "wrong connection count", 0, tcpHandler.getNumberOfConnections()); + assertEquals( "wrong port", serverPort, tcpHandler.getPort()); + assertEquals( "wrong address", serverAddress.getHostAddress(), tcpHandler.getAddress()); - assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())) ; + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())); + + shutdownServer(); + } + + /** + * Test run with encryption on Epoll native transport + * @throws InterruptedException + * @throws IOException + * @throws ExecutionException + */ + @Test + public void testRunWithEncryptionOnEpoll() throws InterruptedException, IOException, ExecutionException { + int serverPort = 28001; + tcpHandler = new TcpHandler(serverAddress, serverPort); + tcpHandler.setChannelInitializer(mockChannelInitializer); + + //Use Epoll native transport + assertEquals( "failed to start server", true, startupServer(true)); + assertEquals( "wrong connection count", 0, tcpHandler.getNumberOfConnections()); + assertEquals( "wrong port", serverPort, tcpHandler.getPort()); + assertEquals( "wrong address", serverAddress.getHostAddress(), tcpHandler.getAddress()); + + assertEquals("failed to connect client", true, clientConnection(tcpHandler.getPort())); shutdownServer(); } @@ -123,7 +183,7 @@ public void testSocketAlreadyInUse() throws IOException { try { tcpHandler = new TcpHandler(serverAddress, serverPort); tcpHandler.setChannelInitializer(mockChannelInitializer); - tcpHandler.initiateEventLoopGroups(null); + tcpHandler.initiateEventLoopGroups(null, false); tcpHandler.run(); } catch (Exception e) { if (e instanceof BindException) { @@ -134,6 +194,35 @@ public void testSocketAlreadyInUse() throws IOException { Assert.assertTrue("Expected BindException has not been thrown", exceptionThrown == true); } + /** + * Test run on already used port + * @throws IOException + */ + @Test + public void testSocketAlreadyInUseOnEpoll() throws IOException { + int serverPort = 28001; + Socket firstBinder = new Socket(); + boolean exceptionThrown = false; + try { + firstBinder.bind(new InetSocketAddress(serverAddress, serverPort)); + } catch (Exception e) { + Assert.fail("Test precondition failed - not able to bind socket to port " + serverPort); + } + try { + tcpHandler = new TcpHandler(serverAddress, serverPort); + tcpHandler.setChannelInitializer(mockChannelInitializer); + //Use Epoll native transport + tcpHandler.initiateEventLoopGroups(null, true); + tcpHandler.run(); + } catch (Exception e) { + if (e instanceof BindException || e instanceof Errors.NativeIoException) { + exceptionThrown = true; + } + } + firstBinder.close(); + Assert.assertTrue("Expected BindException has not been thrown", exceptionThrown == true); + } + /** * Trigger the server shutdown and wait 2 seconds for completion */ @@ -149,9 +238,13 @@ private void shutdownServer() throws InterruptedException, ExecutionException { * @throws IOException * @throws ExecutionException */ - private Boolean startupServer() throws InterruptedException, IOException, ExecutionException { + private Boolean startupServer(boolean isEpollEnabled) throws InterruptedException, IOException, ExecutionException { ListenableFuture online = tcpHandler.getIsOnlineFuture(); - tcpHandler.initiateEventLoopGroups(null); + /** + * Test EPoll based native transport if isEpollEnabled is true. + * Else use Nio based transport. + */ + tcpHandler.initiateEventLoopGroups(null, isEpollEnabled); (new Thread(tcpHandler)).start(); int retry = 0; while (online.isDone() != true && retry++ < 20) { diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 491e18de..17559515 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -161,7 +161,7 @@ public void testStartup6() { } catch (InterruptedException | ExecutionException | TimeoutException e) { Assert.fail(); } - } + } /** * Tests correct provider shutdown diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java index 0dd9ce3b..ff36181f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java @@ -47,7 +47,27 @@ public void startUp() { public void testWithEmptyAddress() throws InterruptedException, ExecutionException, IOException { udpHandler = new UdpHandler(null, 0); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer()); + Assert.assertTrue("Wrong - start server", startupServer(false)); + try { + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + } catch (TimeoutException e) { + Assert.fail("Wrong - getIsOnlineFuture timed out"); + } + Assert.assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); + shutdownServer(); + } + + /** + * Test to create UdpHandler with empty address and zero port on Epoll native transport + * @throws InterruptedException + * @throws ExecutionException + * @throws IOException + */ + @Test + public void testWithEmptyAddressOnEpoll() throws InterruptedException, ExecutionException, IOException { + udpHandler = new UdpHandler(null, 0); + udpHandler.setChannelInitializer(udpChannelInitializerMock); + Assert.assertTrue("Wrong - start server", startupServer(true)); try { Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); } catch (TimeoutException e) { @@ -68,7 +88,7 @@ public void testWithAddressAndPort() throws InterruptedException, ExecutionExcep int port = 9874; udpHandler = new UdpHandler(InetAddress.getLocalHost(), port); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer()); + Assert.assertTrue("Wrong - start server", startupServer(false)); try { Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); } catch (TimeoutException e) { @@ -78,9 +98,34 @@ public void testWithAddressAndPort() throws InterruptedException, ExecutionExcep shutdownServer(); } - private Boolean startupServer() throws InterruptedException, IOException, ExecutionException { - ListenableFuture online = udpHandler.getIsOnlineFuture(); + /** + * Test to create UdpHandler with fill address and given port on Epoll native transport + * @throws InterruptedException + * @throws ExecutionException + * @throws IOException + */ + @Test + public void testWithAddressAndPortOnEpoll() throws InterruptedException, ExecutionException, IOException{ + int port = 9874; + udpHandler = new UdpHandler(InetAddress.getLocalHost(), port); + udpHandler.setChannelInitializer(udpChannelInitializerMock); + Assert.assertTrue("Wrong - start server", startupServer(true)); + try { + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + } catch (TimeoutException e) { + Assert.fail("Wrong - getIsOnlineFuture timed out"); + } + Assert.assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); + shutdownServer(); + } + private Boolean startupServer(boolean isEpollEnabled) throws InterruptedException, IOException, ExecutionException { + ListenableFuture online = udpHandler.getIsOnlineFuture(); + /** + * Test EPoll based native transport if isEpollEnabled is true. + * Else use Nio based transport. + */ + udpHandler.initiateEventLoopGroups(null, isEpollEnabled); (new Thread(udpHandler)).start(); int retry = 0; while (online.isDone() != true && retry++ < 20) { diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index a2fe3a11..98a6e1ff 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -11,7 +11,7 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.channel.socket.SocketChannel; import io.netty.handler.ssl.SslHandler; import javax.net.ssl.SSLEngine; @@ -22,7 +22,7 @@ * * @author michal.polkorab */ -public class SimpleClientInitializer extends ChannelInitializer { +public class SimpleClientInitializer extends ChannelInitializer { private SettableFuture isOnlineFuture; private boolean secured; @@ -38,7 +38,7 @@ public SimpleClientInitializer(SettableFuture isOnlineFuture, boolean s } @Override - public void initChannel(NioSocketChannel ch) throws Exception { + public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (secured) { SSLEngine engine = ClientSslContextFactory.getClientContext() diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java index 11444427..a68b6ab7 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java @@ -11,7 +11,7 @@ import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.channel.socket.DatagramChannel; import com.google.common.util.concurrent.SettableFuture; @@ -19,7 +19,7 @@ * * @author michal.polkorab */ -public class UdpSimpleClientInitializer extends ChannelInitializer { +public class UdpSimpleClientInitializer extends ChannelInitializer { private SettableFuture isOnlineFuture; private ScenarioHandler scenarioHandler; @@ -32,7 +32,7 @@ public UdpSimpleClientInitializer(SettableFuture isOnlineFuture) { } @Override - public void initChannel(NioDatagramChannel ch) throws Exception { + public void initChannel(DatagramChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler); simpleClientHandler.setScenario(scenarioHandler); From 0694052df727929d33bdce6974191fb79088cb2c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 27 Jan 2016 15:21:03 +0100 Subject: [PATCH 230/285] BUG-4862: catch ClassCastException When the looked up serializer does not implement the expected HeaderDesersializer interface we end up with a ClassCastException. Catch it, issue a warning and continue. Change-Id: I70f23733078710507bdc65931e41c1bd02c0684f Signed-off-by: Robert Varga (cherry picked from commit b80a043a43abc0948378f2d8cbb5a3b819a1f3bc) --- .../openflowjava/protocol/impl/util/ListDeserializer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index a53749c2..f5d0c2ba 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -77,8 +77,9 @@ public static List deserializeHeaders(short version, i MessageCodeKey key = keyMaker.make(input); try { deserializer = registry.getDeserializer(key); - } catch (IllegalStateException e) { - LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", key); + } catch (ClassCastException | IllegalStateException e) { + LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", + key, e); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); continue; } From 517b3f4815934fe9c833e521c8a4f024192d2fe9 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Wed, 27 Jan 2016 19:41:07 +0100 Subject: [PATCH 231/285] Bug 4473 - Concentrate multipart-reply (table features) exception logs - prevents log from flooding by unsupported structures in table features - OVS 2.4 related issue Change-Id: I07ca50074b0ac47047e6067ee22b1b3ec5414bc5 Signed-off-by: Michal Polkorab (cherry picked from commit 0ab3b3d2d5ef029a9fc3ba9ee7e6215b6630df25) --- .../protocol/impl/util/ListDeserializer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index f5d0c2ba..905eefd7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -72,14 +72,20 @@ public static List deserializeHeaders(short version, i if (input.readableBytes() > 0) { items = new ArrayList<>(); int startIndex = input.readerIndex(); + boolean exceptionLogged = false; while ((input.readerIndex() - startIndex) < length){ HeaderDeserializer deserializer; MessageCodeKey key = keyMaker.make(input); try { deserializer = registry.getDeserializer(key); } catch (ClassCastException | IllegalStateException e) { - LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", - key, e); + if (!exceptionLogged) { + LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", + key, e); + LOG.warn("This exception is logged only once for each multipart reply (table features) to " + + "prevent log flooding. There might be more of table features related exceptions."); + exceptionLogged = true; + } input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); continue; } From e83ea90057e8e461591f4cd5f6197e5c1c407072 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 2 Feb 2016 11:53:04 +0100 Subject: [PATCH 232/285] Bug 5173 - Prevent log flooding Change-Id: I9b26534b8a9330ea0f7e76b68d866b7afa431733 Signed-off-by: Michal Polkorab (cherry picked from commit e139552727bffe4da60cec61b5f18fcdb7cecff7) --- .../protocol/impl/util/ListDeserializer.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index 905eefd7..44534720 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -79,11 +79,19 @@ public static List deserializeHeaders(short version, i try { deserializer = registry.getDeserializer(key); } catch (ClassCastException | IllegalStateException e) { + // Following "if" is only hotfix to prevent log flooding. Log flooding is originally + // caused by using OVS 2.4 which directly uses / reports Nicira extensions. These extensions + // are not yet (2nd February 2016) fully supported by existing OF Plugin. + // TODO - simplify to correctly report exception during deserialization if (!exceptionLogged) { - LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}", - key, e); - LOG.warn("This exception is logged only once for each multipart reply (table features) to " - + "prevent log flooding. There might be more of table features related exceptions."); + LOG.warn("Problem during reading table feature property. Skipping unknown feature property: {}." + + "If more information is needed, set org.opendaylight.openflowjava do DEBUG log level.", + key, e.getMessage()); + if (LOG.isDebugEnabled()) { + LOG.debug("Detailed exception: {}", e); + LOG.debug("This exception is logged only once for each multipart reply (table features) to " + + "prevent log flooding. There might be more of table features related exceptions."); + } exceptionLogged = true; } input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); From 693ca12245dd55cad42ef3da61f409a5c678eb37 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 5 May 2016 08:32:21 -0400 Subject: [PATCH 233/285] Add SwitchConnectionProviderFactory Added a SwitchConnectionProviderFactory interface to the protocol SPI bundle and a SwitchConnectionProviderFactoryImpl to the impl bundle to create SwitchConnectionProvider instances given a SwitchConnectionConfig. The SwitchConnectionProviderFactoryImpl is instantiated and advertised as an OSGi service via blueprint. This allows clients to create new SwitchConnectionProvider instances while hiding implementation details. This is equivalent to creating instances via the config yang module. The SwitchConnectionConfig and related classes are generated via a new yang file that is equivalent to the config elements defined in the openflow-switch-connection-provider-impl config yang. This new yang model will be stored and retrieved via the data store. Change-Id: I511c12644d5d54cd99c6b1afbf4c078a0cecee8e Signed-off-by: Tom Pantelis --- .../SwitchConnectionProviderFactoryImpl.java | 178 ++++++++++++++++++ .../blueprint/openflow-protocol-impl.xml | 9 + openflow-protocol-spi/pom.xml | 5 +- .../SwitchConnectionProviderFactory.java | 25 +++ .../openflow-switch-connection-config.yang | 116 ++++++++++++ 5 files changed, 329 insertions(+), 4 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java create mode 100644 openflow-protocol-impl/src/main/resources/org/opendaylight/blueprint/openflow-protocol-impl.xml create mode 100644 openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderFactory.java create mode 100644 openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java new file mode 100644 index 00000000..a3aae92e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.core; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Throwables; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506._switch.connection.config.Threads; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506._switch.connection.config.Tls; + +/** + * Implementation of the SwitchConnectionProviderFactory interface. + * + * @author Thomas Pantelis + */ +public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProviderFactory { + + @Override + public SwitchConnectionProvider newInstance(SwitchConnectionConfig config) { + SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); + switchConnectionProviderImpl.setConfiguration(new ConnectionConfigurationImpl(config)); + return switchConnectionProviderImpl; + } + + private static InetAddress extractIpAddressBin(final IpAddress address) throws UnknownHostException { + byte[] addressBin = null; + if (address != null) { + if (address.getIpv4Address() != null) { + addressBin = address2bin(address.getIpv4Address().getValue()); + } else if (address.getIpv6Address() != null) { + addressBin = address2bin(address.getIpv6Address().getValue()); + } + } + + if (addressBin == null) { + return null; + } else { + return InetAddress.getByAddress(addressBin); + } + } + + private static byte[] address2bin(final String value) { + //TODO: translate ipv4 or ipv6 into byte[] + return null; + } + + private static class ConnectionConfigurationImpl implements ConnectionConfiguration { + private final SwitchConnectionConfig config; + private InetAddress address; + + private ConnectionConfigurationImpl(SwitchConnectionConfig config) { + this.config = config; + + try { + address = extractIpAddressBin(config.getAddress()); + } catch(UnknownHostException e) { + Throwables.propagate(e); + } + } + + @Override + public InetAddress getAddress() { + return address; + } + + @Override + public int getPort() { + return config.getPort(); + } + + @Override + public Object getTransferProtocol() { + return config.getTransportProtocol(); + } + + @Override + public TlsConfiguration getTlsConfiguration() { + final Tls tlsConfig = config.getTls(); + if(tlsConfig == null || !(TransportProtocol.TLS.equals(getTransferProtocol()))) { + return null; + } + + return new TlsConfiguration() { + @Override + public KeystoreType getTlsTruststoreType() { + return MoreObjects.firstNonNull(tlsConfig.getTruststoreType(), null); + } + @Override + public String getTlsTruststore() { + return MoreObjects.firstNonNull(tlsConfig.getTruststore(), null); + } + @Override + public KeystoreType getTlsKeystoreType() { + return MoreObjects.firstNonNull(tlsConfig.getKeystoreType(), null); + } + @Override + public String getTlsKeystore() { + return MoreObjects.firstNonNull(tlsConfig.getKeystore(), null); + } + @Override + public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() { + return MoreObjects.firstNonNull(tlsConfig.getKeystorePathType(), null); + } + @Override + public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() { + return MoreObjects.firstNonNull(tlsConfig.getTruststorePathType(), null); + } + @Override + public String getKeystorePassword() { + return MoreObjects.firstNonNull(tlsConfig.getKeystorePassword(), null); + } + @Override + public String getCertificatePassword() { + return MoreObjects.firstNonNull(tlsConfig.getCertificatePassword(), null); + } + @Override + public String getTruststorePassword() { + return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null); + } + @Override + public List getCipherSuites() { + return tlsConfig.getCipherSuites(); + } + }; + } + + @Override + public long getSwitchIdleTimeout() { + return config.getSwitchIdleTimeout(); + } + + @Override + public Object getSslContext() { + return null; + } + + @Override + public ThreadConfiguration getThreadConfiguration() { + final Threads threads = config.getThreads(); + if(threads == null) { + return null; + } + + return new ThreadConfiguration() { + @Override + public int getWorkerThreadCount() { + return threads.getWorkerThreads(); + } + + @Override + public int getBossThreadCount() { + return threads.getBossThreads(); + } + }; + } + + @Override + public boolean useBarrier() { + return config.isUseBarrier(); + } + } +} diff --git a/openflow-protocol-impl/src/main/resources/org/opendaylight/blueprint/openflow-protocol-impl.xml b/openflow-protocol-impl/src/main/resources/org/opendaylight/blueprint/openflow-protocol-impl.xml new file mode 100644 index 00000000..c4ce514b --- /dev/null +++ b/openflow-protocol-impl/src/main/resources/org/opendaylight/blueprint/openflow-protocol-impl.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 430e2c90..1d82eefd 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -23,10 +23,7 @@ true - - org.opendaylight.openflowjava.protocol.spi*, - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.* - + org.opendaylight.openflowjava.protocol.api.keys,*
          diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderFactory.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderFactory.java new file mode 100644 index 00000000..9ef8c4dd --- /dev/null +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.spi.connection; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig; + +/** + * Factory for creating SwitchConnectionProvider instances. + * + * @author Thomas Pantelis + */ +public interface SwitchConnectionProviderFactory { + /** + * Creates a new SwitchConnectionProvider with the given configuration. + * + * @param config the SwitchConnectionConfig + * @return a SwitchConnectionProvider instance + */ + SwitchConnectionProvider newInstance(SwitchConnectionConfig config); +} diff --git a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang new file mode 100644 index 00000000..53cfe088 --- /dev/null +++ b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang @@ -0,0 +1,116 @@ +module openflow-switch-connection-config { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config"; + prefix "openflow-switch-connection-config"; + + import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; } + import openflow-configuration {prefix of-config; revision-date 2014-06-30; } + + description + "Configuration for an Openflow switch connection."; + + revision "2016-05-06" { + description + "Initial revision"; + } + + list switch-connection-config { + key "instance-name"; + + leaf instance-name { + description "Name of the switch connection instance."; + type string; + } + + leaf port { + description "local listening port"; + type uint16; + mandatory true; + } + + leaf transport-protocol { + description "Transport protocol used for communication."; + type of-config:transport-protocol; + mandatory true; + } + + leaf address { + description "address of local listening interface"; + type ietf-inet:ip-address; + } + + leaf use-barrier { + description "Enable barrier in Openflow java"; + type boolean; + default true; + } + + leaf switch-idle-timeout { + description "idle timeout in [ms]"; + type uint32; + default 15000; + } + + container tls { + leaf keystore { + description "keystore location"; + type string; + } + + leaf keystore-type { + description "keystore type (JKS or PKCS12)"; + type of-config:keystore-type; + } + + leaf keystore-path-type { + description "keystore path type (CLASSPATH or PATH)"; + type of-config:path-type; + } + + leaf keystore-password { + description "password protecting keystore"; + type string; + } + + leaf certificate-password { + description "password protecting certificate"; + type string; + } + + leaf truststore { + description "truststore location"; + type string; + } + + leaf truststore-type { + description "truststore type (JKS or PKCS12)"; + type of-config:keystore-type; + } + + leaf truststore-path-type { + description "truststore path type (CLASSPATH or PATH)"; + type of-config:path-type; + } + + leaf truststore-password { + description "password protecting truststore"; + type string; + } + + leaf-list cipher-suites { + description "combination of cryptographic algorithms used by TLS connection"; + type string; + } + } + + container threads { + leaf boss-threads { + type uint16; + } + + leaf worker-threads { + type uint16; + } + } + } +} \ No newline at end of file From 78c308601f484d02be96ec0076436225dea59377 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Mon, 9 May 2016 19:59:15 -0400 Subject: [PATCH 234/285] Deprecate SwitchConnectionProviderModule Deprecate the SwitchConnectionProviderModule and corresponding yang. The createInstance method was modified to obtain the corresponding service instance created via blueprint from the OSGi registry using a ServiceTracker. Change-Id: Ie156466e08d4a5758ceae63f6c877f8210632cfb Signed-off-by: Tom Pantelis --- .../SwitchConnectionProviderModule.java | 200 +++--------------- ...SwitchConnectionProviderModuleFactory.java | 27 ++- ...nflow-switch-connection-provider-impl.yang | 1 + .../openflow-switch-connection-provider.yang | 2 + 4 files changed, 57 insertions(+), 173 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java index 6ded9bfb..a9756bdd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModule.java @@ -9,29 +9,19 @@ */ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328; -import com.google.common.base.MoreObjects; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.google.common.reflect.AbstractInvocationHandler; +import com.google.common.reflect.Reflection; +import java.lang.reflect.Method; +import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.osgi.framework.BundleContext; /** -* -*/ -public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule - { - - private static Logger LOG = LoggerFactory - .getLogger(SwitchConnectionProviderModule.class); + * @deprecated Replaced by blueprint wiring + */ +@Deprecated +public final class SwitchConnectionProviderModule extends AbstractSwitchConnectionProviderModule { + private BundleContext bundleContext; /** * @param identifier @@ -53,160 +43,34 @@ public SwitchConnectionProviderModule(final org.opendaylight.controller.config.a } @Override - protected void customValidation(){ - // Add custom validation for module attributes here. - } - - @Override - public java.lang.AutoCloseable createInstance() { - LOG.info("SwitchConnectionProvider started."); - final SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl(); - try { - final ConnectionConfiguration connConfiguration = createConnectionConfiguration(); - switchConnectionProviderImpl.setConfiguration(connConfiguration); - } catch (final UnknownHostException e) { - throw new IllegalArgumentException(e.getMessage(), e); - } - return switchConnectionProviderImpl; - } - - /** - * @return instance configuration object - * @throws UnknownHostException - */ - private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException { - final InetAddress address = extractIpAddressBin(getAddress()); - final Integer port = getPort(); - final long switchIdleTimeout = getSwitchIdleTimeout(); - final Tls tlsConfig = getTls(); - final Threads threads = getThreads(); - final Boolean useBarrier = getUseBarrier(); - final TransportProtocol transportProtocol = getTransportProtocol(); - - return new ConnectionConfiguration() { - @Override - public InetAddress getAddress() { - return address; - } - @Override - public int getPort() { - return port; - } - @Override - public Object getTransferProtocol() { - return transportProtocol; - } - @Override - public TlsConfiguration getTlsConfiguration() { - if (tlsConfig == null || !(TransportProtocol.TLS.equals(transportProtocol))) { - return null; - } - return new TlsConfiguration() { - @Override - public KeystoreType getTlsTruststoreType() { - return MoreObjects.firstNonNull(tlsConfig.getTruststoreType(), null); - } - @Override - public String getTlsTruststore() { - return MoreObjects.firstNonNull(tlsConfig.getTruststore(), null); - } - @Override - public KeystoreType getTlsKeystoreType() { - return MoreObjects.firstNonNull(tlsConfig.getKeystoreType(), null); - } - @Override - public String getTlsKeystore() { - return MoreObjects.firstNonNull(tlsConfig.getKeystore(), null); - } - @Override - public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() { - return MoreObjects.firstNonNull(tlsConfig.getKeystorePathType(), null); - } - @Override - public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() { - return MoreObjects.firstNonNull(tlsConfig.getTruststorePathType(), null); - } - @Override - public String getKeystorePassword() { - return MoreObjects.firstNonNull(tlsConfig.getKeystorePassword(), null); - } - @Override - public String getCertificatePassword() { - return MoreObjects.firstNonNull(tlsConfig.getCertificatePassword(), null); - } - @Override - public String getTruststorePassword() { - return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null); - } - @Override - public List getCipherSuites() { - return tlsConfig.getCipherSuites(); - } - }; - } - @Override - public long getSwitchIdleTimeout() { - return switchIdleTimeout; - } + public AutoCloseable createInstance() { + // The service is provided via blueprint so wait for and return it here for backwards compatibility. + String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName()); + final WaitingServiceTracker tracker = WaitingServiceTracker.create( + SwitchConnectionProvider.class, bundleContext, typeFilter); + final SwitchConnectionProvider actualService = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES); + + // We don't want to call close on the actual service as its life cycle is controlled by blueprint but + // we do want to close the tracker so create a proxy to override close appropriately. + return Reflection.newProxy(SwitchConnectionProvider.class, new AbstractInvocationHandler() { @Override - public Object getSslContext() { - // TODO Auto-generated method stub - return null; - } - @Override - public ThreadConfiguration getThreadConfiguration() { - if (threads == null) { + protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { + if (method.getName().equals("close")) { + tracker.close(); return null; + } else { + return method.invoke(actualService, args); } - return new ThreadConfiguration() { - - @Override - public int getWorkerThreadCount() { - return threads.getWorkerThreads(); - } - - @Override - public int getBossThreadCount() { - return threads.getBossThreads(); - } - }; } - - @Override - public boolean useBarrier() { - return useBarrier; - } - }; + }); } - /** - * @param address - * @return - * @throws UnknownHostException - */ - private static InetAddress extractIpAddressBin(final IpAddress address) throws UnknownHostException { - byte[] addressBin = null; - if (address != null) { - if (address.getIpv4Address() != null) { - addressBin = address2bin(address.getIpv4Address().getValue()); - } else if (address.getIpv6Address() != null) { - addressBin = address2bin(address.getIpv6Address().getValue()); - } - } - - if (addressBin == null) { - return null; - } else { - return InetAddress.getByAddress(addressBin); - } + public void setBundleContext(BundleContext bundleContext) { + this.bundleContext = bundleContext; } - /** - * @param value - * @return - */ - private static byte[] address2bin(final String value) { - //TODO: translate ipv4 or ipv6 into byte[] - return null; + @Override + public boolean canReuseInstance(AbstractSwitchConnectionProviderModule oldModule) { + return true; } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java index 6bf14239..ca41fc39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/SwitchConnectionProviderModuleFactory.java @@ -9,11 +9,28 @@ */ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328; -/** -* -*/ -public class SwitchConnectionProviderModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModuleFactory -{ +import org.opendaylight.controller.config.api.DependencyResolver; +import org.osgi.framework.BundleContext; +/** + * @deprecated Replaced by blueprint wiring + */ +@Deprecated +public class SwitchConnectionProviderModuleFactory extends AbstractSwitchConnectionProviderModuleFactory { + @Override + public SwitchConnectionProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, + SwitchConnectionProviderModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) { + SwitchConnectionProviderModule module = super.instantiateModule(instanceName, dependencyResolver, oldModule, + oldInstance, bundleContext); + module.setBundleContext(bundleContext); + return module; + } + @Override + public SwitchConnectionProviderModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, + BundleContext bundleContext) { + SwitchConnectionProviderModule module = super.instantiateModule(instanceName, dependencyResolver, bundleContext); + module.setBundleContext(bundleContext); + return module; + } } diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index 1610ff1b..b41b3847 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -21,6 +21,7 @@ module openflow-switch-connection-provider-impl { base "config:module-type"; config:provided-service openflow-switch-connection-provider:openflow-switch-connection-provider; config:java-name-prefix SwitchConnectionProvider; + status deprecated; } identity statistics-collection-service-impl { diff --git a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang index 3ed7c20b..25b38d19 100644 --- a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang +++ b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-provider.yang @@ -16,6 +16,8 @@ module openflow-switch-connection-provider { identity openflow-switch-connection-provider { base "config:service-type"; config:java-class "org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"; + config:disable-osgi-service-registration; + status deprecated; } identity statistics-collection-service { From 8fc43f701528b47eabcbc2362a445f5f722cf944 Mon Sep 17 00:00:00 2001 From: Abbas Pareedkunju Date: Thu, 2 Jun 2016 11:23:07 +0530 Subject: [PATCH 235/285] Fix for the Bug 5637 : When closing OutboundQueue close() should go prior to finishShutdown() When device gets disconnected with outstanding entries in queue segment, it could occur that entry.commit() gets invoked between segment.failAll() and OutboundQueueProvider.close(). This fix to prevent this scenario. Change-Id: Id297e7d4f10c7e31a550f94ac7d39f43e1320de1 Signed-off-by: Abbas Pareedkunju --- .../connection/AbstractOutboundQueueManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index fdcc1f3e..64063943 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -299,12 +299,14 @@ protected void flush() { LOG.trace("Dequeuing messages to channel {}", parent.getChannel()); writeAndFlush(); rescheduleFlush(); - } else if (currentQueue.finishShutdown()) { - close(); - LOG.debug("Channel {} shutdown complete", parent.getChannel()); } else { - LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); - rescheduleFlush(); + close(); + if (currentQueue.finishShutdown()) { + LOG.debug("Channel {} shutdown complete", parent.getChannel()); + } else { + LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); + rescheduleFlush(); + } } } From 0b153ce18153b71fc7e5bb6de5338d5dbaf9b1a1 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 9 Jun 2016 10:53:40 +0200 Subject: [PATCH 236/285] Fixed netty & checkstyle failures Change-Id: I5287bdcdcbc48513d45a9cd4593bf1df6c7be941 Signed-off-by: Michal Polkorab --- .../impl/core/ConnectionInitializer.java | 8 ++++++ .../impl/core/DelegatingInboundHandler.java | 8 +++--- .../protocol/impl/core/IdleHandler.java | 4 +-- .../impl/core/OFDatagramPacketDecoder.java | 12 ++++---- .../impl/core/OFDatagramPacketEncoder.java | 6 ++-- .../impl/core/OFDatagramPacketHandler.java | 28 +++++++++---------- .../protocol/impl/core/OFDecoder.java | 14 +++++----- .../protocol/impl/core/OFFrameDecoder.java | 26 ++++++++--------- .../protocol/impl/core/OFVersionDetector.java | 12 ++++---- .../protocol/impl/core/SslContextFactory.java | 10 +++---- .../protocol/impl/core/SslKeyStore.java | 4 +-- .../core/SwitchConnectionProviderImpl.java | 12 ++++---- .../impl/core/TcpChannelInitializer.java | 16 +++++------ .../impl/core/TcpConnectionInitializer.java | 12 ++++++-- .../protocol/impl/core/TcpHandler.java | 12 ++++---- .../protocol/impl/core/UdpHandler.java | 12 ++++---- .../AbstractOutboundQueueManager.java | 4 +-- .../DeserializerRegistryImpl.java | 4 +-- .../factories/EchoReplyMessageFactory.java | 4 ++- .../factories/EchoRequestMessageFactory.java | 4 ++- .../factories/ErrorMessageFactory.java | 7 +++-- .../OF10EchoReplyMessageFactory.java | 4 ++- .../OF10EchoRequestMessageFactory.java | 4 ++- .../factories/OF10ErrorMessageFactory.java | 7 +++-- .../OF10PacketOutInputMessageFactory.java | 3 +- .../factories/PacketInMessageFactory.java | 4 ++- .../PacketOutInputMessageFactory.java | 3 +- .../serialization/SerializerRegistryImpl.java | 4 +-- .../impl/util/OF13MatchSerializer.java | 6 ++-- .../statistics/StatisticsCounters.java | 16 +++++------ .../rev140328/StatisticsCollectionModule.java | 10 +++---- .../protocol/impl/core/DummyDecoder.java | 4 +-- .../MultipartReplyMessageFactoryTest.java | 4 +-- .../EchoOutputMessageFactoryTest.java | 5 ++-- .../EchoRequestMessageFactoryTest.java | 5 ++-- .../factories/ErrorMessageFactoryTest.java | 5 ++-- .../HelloInputMessageFactoryTest.java | 12 ++++---- .../OF10PacketInMessageFactoryTest.java | 5 ++-- .../OF10PacketOutInputMessageFactoryTest.java | 4 ++- .../factories/PacketInMessageFactoryTest.java | 5 ++-- .../PacketOutInputMessageFactoryTest.java | 4 ++- .../impl/util/ActionsDeserializerTest.java | 4 +-- .../impl/util/OF13MatchSerializerTest.java | 2 +- .../statistics/StatisticsCountersTest.java | 4 +-- .../impl/clients/ListeningSimpleClient.java | 14 +++++----- .../impl/clients/ScenarioHandler.java | 16 +++++------ .../protocol/impl/clients/SendEvent.java | 12 ++++---- .../protocol/impl/clients/SimpleClient.java | 18 ++++++------ .../impl/clients/SimpleClientFramer.java | 12 ++++---- .../impl/clients/SimpleClientHandler.java | 12 ++++---- .../protocol/impl/clients/SleepEvent.java | 6 ++-- .../impl/clients/UdpSimpleClient.java | 18 ++++++------ .../impl/clients/UdpSimpleClientFramer.java | 12 ++++---- .../impl/clients/WaitForMessageEvent.java | 10 +++---- 54 files changed, 258 insertions(+), 215 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java index 4959edaa..1e95c65c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.openflowjava.protocol.impl.core; /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java index e0a013c1..a0efc900 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java @@ -27,7 +27,7 @@ */ public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter { - private static final Logger LOGGER = LoggerFactory.getLogger(DelegatingInboundHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(DelegatingInboundHandler.class); private final MessageConsumer consumer; private boolean inactiveMessageSent = false; @@ -37,7 +37,7 @@ public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter { * @param connectionAdapter reference for adapter communicating with upper layers outside library */ public DelegatingInboundHandler(final MessageConsumer connectionAdapter) { - LOGGER.trace("Creating DelegatingInboundHandler"); + LOG.trace("Creating DelegatingInboundHandler"); consumer = Preconditions.checkNotNull(connectionAdapter); } @@ -48,7 +48,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) { @Override public void channelInactive(final ChannelHandlerContext ctx) { - LOGGER.debug("Channel inactive"); + LOG.debug("Channel inactive"); if (!inactiveMessageSent) { DisconnectEventBuilder builder = new DisconnectEventBuilder(); builder.setInfo("Channel inactive"); @@ -59,7 +59,7 @@ public void channelInactive(final ChannelHandlerContext ctx) { @Override public void channelUnregistered(final ChannelHandlerContext ctx) { - LOGGER.debug("Channel unregistered"); + LOG.debug("Channel unregistered"); if (!inactiveMessageSent) { DisconnectEventBuilder builder = new DisconnectEventBuilder(); builder.setInfo("Channel unregistered"); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java index 9b6e863d..5f408e6c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java @@ -23,7 +23,7 @@ */ public class IdleHandler extends ReadTimeoutHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(IdleHandler.class); private boolean first = true; /** @@ -43,7 +43,7 @@ public void channelRead(final ChannelHandlerContext ctx, final Object msg) throw @Override protected void readTimedOut(final ChannelHandlerContext ctx) throws Exception { if (first) { - LOGGER.debug("Switch idle"); + LOG.debug("Switch idle"); SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder(); builder.setInfo("Switch idle"); ctx.fireChannelRead(builder.build()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index 3a083eea..261beb9c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -23,27 +23,27 @@ */ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); + private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); private DeserializationFactory deserializationFactory; @Override public void channelRead0(final ChannelHandlerContext ctx, final VersionMessageUdpWrapper msg) throws Exception { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("UdpVersionMessageWrapper received"); - LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + if (LOG.isDebugEnabled()) { + LOG.debug("UdpVersionMessageWrapper received"); + LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); } try { final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); if (dataObject == null) { - LOGGER.warn("Translated POJO is null"); + LOG.warn("Translated POJO is null"); } else { MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); consumer.consume(dataObject); } } catch(Exception e) { - LOGGER.warn("Message deserialization failed", e); + LOG.warn("Message deserialization failed", e); // TODO: delegate exception to allow easier deserialization // debugging / deserialization problem awareness } finally { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java index 73a7a00e..8b1faef3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -28,19 +28,19 @@ */ public class OFDatagramPacketEncoder extends MessageToMessageEncoder { - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); + private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); private SerializationFactory serializationFactory; @Override protected void encode(ChannelHandlerContext ctx, UdpMessageListenerWrapper wrapper, List out) throws Exception { - LOGGER.trace("Encoding"); + LOG.trace("Encoding"); try { ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); out.add(new DatagramPacket(buffer, wrapper.getAddress())); } catch(Exception e) { - LOGGER.warn("Message serialization failed: {}", e.getMessage()); + LOG.warn("Message serialization failed: {}", e.getMessage()); Future newFailedFuture = ctx.newFailedFuture(e); wrapper.getListener().operationComplete(newFailedFuture); return; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index 16068a5e..0eb29161 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -31,7 +31,7 @@ */ public class OFDatagramPacketHandler extends MessageToMessageDecoder { - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketHandler.class); /** Length of OpenFlow 1.3 header */ public static final byte LENGTH_OF_HEADER = 8; @@ -50,15 +50,15 @@ public OFDatagramPacketHandler(SwitchConnectionHandler sch) { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOGGER.warn("Unexpected exception from downstream.", cause); - LOGGER.warn("Closing connection."); + LOG.warn("Unexpected exception from downstream.", cause); + LOG.warn("Closing connection."); ctx.close(); } @Override protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List out) throws Exception { - LOGGER.debug("OFDatagramPacketFramer"); + LOG.debug("OFDatagramPacketFramer"); MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); if (consumer == null) { ConnectionFacade connectionFacade = @@ -70,34 +70,34 @@ protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, ByteBuf bb = msg.content(); int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); - LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); + if (LOG.isDebugEnabled()) { + LOG.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); + LOG.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); - LOGGER.debug("length of actual message: {}", length); + LOG.debug("length of actual message: {}", length); if (readableBytes < length) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); - LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); + if (LOG.isDebugEnabled()) { + LOG.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); + LOG.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); byte version = bb.readByte(); if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { - LOGGER.debug("detected version: {}", version); + LOG.debug("detected version: {}", version); ByteBuf messageBuffer = bb.slice(); out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); messageBuffer.retain(); } else { - LOGGER.warn("detected version: {} - currently not supported", version); + LOG.warn("detected version: {} - currently not supported", version); } bb.skipBytes(bb.readableBytes()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index de419f8b..ec1f43d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -27,7 +27,7 @@ */ public class OFDecoder extends MessageToMessageDecoder { - private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class); + private static final Logger LOG = LoggerFactory.getLogger(OFDecoder.class); private final StatisticsCounters statisticsCounter; // TODO: make this final? @@ -37,7 +37,7 @@ public class OFDecoder extends MessageToMessageDecoder { * Constructor of class */ public OFDecoder() { - LOGGER.trace("Creating OF 1.3 Decoder"); + LOG.trace("Creating OF 1.3 Decoder"); // TODO: pass as argument statisticsCounter = StatisticsCounters.getInstance(); } @@ -46,23 +46,23 @@ public OFDecoder() { protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List out) throws Exception { statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("VersionMessageWrapper received"); - LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + if (LOG.isDebugEnabled()) { + LOG.debug("VersionMessageWrapper received"); + LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); } try { final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), msg.getVersion()); if (dataObject == null) { - LOGGER.warn("Translated POJO is null"); + LOG.warn("Translated POJO is null"); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } else { out.add(dataObject); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS); } } catch (Exception e) { - LOGGER.warn("Message deserialization failed", e); + LOG.warn("Message deserialization failed", e); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } finally { msg.getMessageBuffer().release(); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index f4ec8825..735070fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -29,7 +29,7 @@ public class OFFrameDecoder extends ByteToMessageDecoder { /** Length of OpenFlow 1.3 header */ 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); + private static final Logger LOG = LoggerFactory.getLogger(OFFrameDecoder.class); private ConnectionFacade connectionFacade; private boolean firstTlsPass = false; @@ -40,7 +40,7 @@ public class OFFrameDecoder extends ByteToMessageDecoder { * @param tlsPresent true is TLS is required, false otherwise */ public OFFrameDecoder(ConnectionFacade connectionFacade, boolean tlsPresent) { - LOGGER.trace("Creating OFFrameDecoder"); + LOG.trace("Creating OFFrameDecoder"); if (tlsPresent) { firstTlsPass = true; } @@ -50,11 +50,11 @@ public OFFrameDecoder(ConnectionFacade connectionFacade, boolean tlsPresent) { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause instanceof io.netty.handler.ssl.NotSslRecordException) { - LOGGER.warn("Not an TLS record exception - please verify TLS configuration."); + LOG.warn("Not an TLS record exception - please verify TLS configuration."); } else { - LOGGER.warn("Unexpected exception from downstream.", cause); + LOG.warn("Unexpected exception from downstream.", cause); } - LOGGER.warn("Closing connection."); + LOG.warn("Closing connection."); ctx.close(); } @@ -66,24 +66,24 @@ protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) } int readableBytes = bb.readableBytes(); if (readableBytes < LENGTH_OF_HEADER) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); - LOGGER.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); + if (LOG.isDebugEnabled()) { + LOG.debug("skipping bytebuf - too few bytes for header: {} < {}", readableBytes, LENGTH_OF_HEADER); + LOG.debug("bb: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); - LOGGER.debug("length of actual message: {}", length); + LOG.debug("length of actual message: {}", length); if (readableBytes < length) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); - LOGGER.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); + if (LOG.isDebugEnabled()) { + LOG.debug("skipping bytebuf - too few bytes for msg: {} < {}", readableBytes, length); + LOG.debug("bytebuffer: {}", ByteBufUtils.byteBufToHexString(bb)); } return; } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 0142ebfd..b635ef25 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -29,7 +29,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { /** Version number of OpenFlow 1.3 protocol */ private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID; private static final short OF_PACKETIN = 10; - private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class); + private static final Logger LOG = LoggerFactory.getLogger(OFVersionDetector.class); private final StatisticsCounters statisticsCounters; private volatile boolean filterPacketIns; @@ -37,7 +37,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { * Constructor of class. */ public OFVersionDetector() { - LOGGER.trace("Creating OFVersionDetector"); + LOG.trace("Creating OFVersionDetector"); statisticsCounters = StatisticsCounters.getInstance(); } @@ -48,24 +48,24 @@ public void setFilterPacketIns(final boolean enabled) { @Override protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List out) { if (!in.isReadable()) { - LOGGER.debug("not enough data"); + LOG.debug("not enough data"); in.release(); return; } final byte version = in.readByte(); if (version == OF13_VERSION_ID || version == OF10_VERSION_ID) { - LOGGER.debug("detected version: {}", version); + LOG.debug("detected version: {}", version); if (!filterPacketIns || OF_PACKETIN != in.getUnsignedByte(in.readerIndex())) { ByteBuf messageBuffer = in.slice(); out.add(new VersionMessageWrapper(version, messageBuffer)); messageBuffer.retain(); } else { - LOGGER.debug("dropped packetin"); + LOG.debug("dropped packetin"); statisticsCounters.incrementCounter(CounterEventTypes.US_DROPPED_PACKET_IN); } } else { - LOGGER.warn("detected version: {} - currently not supported", version); + LOG.warn("detected version: {} - currently not supported", version); } in.skipBytes(in.readableBytes()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java index b2c5a199..dbaa2070 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java @@ -34,7 +34,7 @@ public class SslContextFactory { private static final String PROTOCOL = "TLS"; private TlsConfiguration tlsConfig; - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(SslContextFactory.class); /** @@ -72,16 +72,16 @@ public SSLContext getServerContext() { serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); } catch (IOException e) { - LOGGER.warn("IOException - Failed to load keystore / truststore." + LOG.warn("IOException - Failed to load keystore / truststore." + " Failed to initialize the server-side SSLContext", e); } catch (NoSuchAlgorithmException e) { - LOGGER.warn("NoSuchAlgorithmException - Unsupported algorithm." + LOG.warn("NoSuchAlgorithmException - Unsupported algorithm." + " Failed to initialize the server-side SSLContext", e); } catch (CertificateException e) { - LOGGER.warn("CertificateException - Unable to access certificate (check password)." + LOG.warn("CertificateException - Unable to access certificate (check password)." + " Failed to initialize the server-side SSLContext", e); } catch (Exception e) { - LOGGER.warn("Exception - Failed to initialize the server-side SSLContext", e); + LOG.warn("Exception - Failed to initialize the server-side SSLContext", e); } return serverContext; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java index 589c23cd..e4efea9f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java @@ -24,7 +24,7 @@ */ public final class SslKeyStore { - private static final Logger LOGGER = LoggerFactory.getLogger(SslKeyStore.class); + private static final Logger LOG = LoggerFactory.getLogger(SslKeyStore.class); private SslKeyStore() { throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); @@ -48,7 +48,7 @@ public static InputStream asInputStream(String filename, PathType pathType) { } break; case PATH: - LOGGER.debug("Current dir using System:" + LOG.debug("Current dir using System:" + System.getProperty("user.dir")); File keystorefile = new File(filename); try { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 411a9b43..bb327361 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -58,7 +58,7 @@ */ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, ConnectionInitializer { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(SwitchConnectionProviderImpl.class); private SwitchConnectionHandler switchConnectionHandler; private ServerFacade serverFacade; @@ -88,15 +88,15 @@ public void setConfiguration(final ConnectionConfiguration connConfig) { @Override public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { - LOGGER.debug("setSwitchConnectionHandler"); + LOG.debug("setSwitchConnectionHandler"); this.switchConnectionHandler = switchConnectionHandler; } @Override public ListenableFuture shutdown() { - LOGGER.debug("Shutdown summoned"); + LOG.debug("Shutdown summoned"); if(serverFacade == null){ - LOGGER.warn("Can not shutdown - not configured or started"); + LOG.warn("Can not shutdown - not configured or started"); throw new IllegalStateException("SwitchConnectionProvider is not started or not configured."); } return serverFacade.shutdown(); @@ -104,7 +104,7 @@ public ListenableFuture shutdown() { @Override public ListenableFuture startup() { - LOGGER.debug("Startup summoned"); + LOG.debug("Startup summoned"); ListenableFuture result = null; try { serverFacade = createAndConfigureServer(); @@ -125,7 +125,7 @@ public ListenableFuture startup() { * @return */ private ServerFacade createAndConfigureServer() { - LOGGER.debug("Configuring .."); + LOG.debug("Configuring .."); ServerFacade server = null; final ChannelInitializerFactory factory = new ChannelInitializerFactory(); factory.setSwitchConnectionHandler(switchConnectionHandler); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 881f697a..376978d1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -31,7 +31,7 @@ */ public class TcpChannelInitializer extends ProtocolChannelInitializer { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(TcpChannelInitializer.class); private final DefaultChannelGroup allChannels; private final ConnectionAdapterFactory connectionAdapterFactory; @@ -58,21 +58,21 @@ protected void initChannel(final SocketChannel ch) { final InetAddress switchAddress = ch.remoteAddress().getAddress(); final int port = ch.localAddress().getPort(); final int remotePort = ch.remoteAddress().getPort(); - LOGGER.debug("Incoming connection from (remote address): {}:{} --> :{}", + LOG.debug("Incoming connection from (remote address): {}:{} --> :{}", switchAddress.toString(), remotePort, port); if (!getSwitchConnectionHandler().accept(switchAddress)) { ch.disconnect(); - LOGGER.debug("Incoming connection rejected"); + LOG.debug("Incoming connection rejected"); return; } } - LOGGER.debug("Incoming connection accepted - building pipeline"); + LOG.debug("Incoming connection accepted - building pipeline"); allChannels.add(ch); ConnectionFacade connectionFacade = null; connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null, useBarrier()); try { - LOGGER.debug("calling plugin: {}", getSwitchConnectionHandler()); + LOG.debug("calling plugin: {}", getSwitchConnectionHandler()); getSwitchConnectionHandler().onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); @@ -87,10 +87,10 @@ protected void initChannel(final SocketChannel ch) { engine.setUseClientMode(false); List suitesList = getTlsConfiguration().getCipherSuites(); if (suitesList != null && !suitesList.isEmpty()) { - LOGGER.debug("Requested Cipher Suites are: {}", suitesList); + LOG.debug("Requested Cipher Suites are: {}", suitesList); String[] suites = suitesList.toArray(new String[suitesList.size()]); engine.setEnabledCipherSuites(suites); - LOGGER.debug("Cipher suites enabled in SSLEngine are: {}", engine.getEnabledCipherSuites().toString()); + LOG.debug("Cipher suites enabled in SSLEngine are: {}", engine.getEnabledCipherSuites().toString()); } final SslHandler ssl = new SslHandler(engine); final Future handshakeFuture = ssl.handshakeFuture(); @@ -117,7 +117,7 @@ public void operationComplete(final Future future) throws Excep connectionFacade.fireConnectionReadyNotification(); } } catch (final Exception e) { - LOGGER.warn("Failed to initialize channel", e); + LOG.warn("Failed to initialize channel", e); ch.close(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java index c5905d60..d0a2fc63 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.openflowjava.protocol.impl.core; import io.netty.bootstrap.Bootstrap; @@ -20,7 +28,7 @@ public class TcpConnectionInitializer implements ServerFacade, ConnectionInitializer { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(TcpConnectionInitializer.class); private EventLoopGroup workerGroup; private ThreadConfiguration threadConfig; @@ -73,7 +81,7 @@ public void initiateConnection(String host, int port) { try { b.connect(host, port).sync(); } catch (InterruptedException e) { - LOGGER.error("Unable to initiate connection", e); + LOG.error("Unable to initiate connection", e); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index 00a3fd71..23914231 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -51,7 +51,7 @@ public class TcpHandler implements ServerFacade { */ private static final int DEFAULT_WRITE_SPIN_COUNT = 16; - private static final Logger LOGGER = LoggerFactory.getLogger(TcpHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(TcpHandler.class); private int port; private String address; @@ -122,7 +122,7 @@ public void run() { f = b.bind(port).sync(); } } catch (InterruptedException e) { - LOGGER.error("Interrupted while binding port {}", port, e); + LOG.error("Interrupted while binding port {}", port, e); return; } @@ -133,12 +133,12 @@ public void run() { // Update port, as it may have been specified as 0 this.port = isa.getPort(); - LOGGER.debug("address from tcphandler: {}", address); + LOG.debug("address from tcphandler: {}", address); isOnlineFuture.set(true); - LOGGER.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port); + LOG.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port); f.channel().closeFuture().sync(); } catch (InterruptedException e) { - LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); + LOG.error("Interrupted while waiting for port {} shutdown", port, e); } finally { shutdown(); } @@ -252,7 +252,7 @@ protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfigurat ((EpollEventLoopGroup)workerGroup).setIoRatio(100); return; } catch (Throwable ex) { - LOGGER.debug("Epoll initiation failed"); + LOG.debug("Epoll initiation failed"); } //Fallback mechanism diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 9339ba16..1dac7a59 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -36,7 +36,7 @@ */ public final class UdpHandler implements ServerFacade { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(UdpHandler.class); private int port; private EventLoopGroup group; @@ -82,7 +82,7 @@ public void run() { f = b.bind(port).sync(); } } catch (InterruptedException e) { - LOGGER.error("Interrupted while binding port {}", port, e); + LOG.error("Interrupted while binding port {}", port, e); return; } @@ -93,12 +93,12 @@ public void run() { // Update port, as it may have been specified as 0 this.port = isa.getPort(); - LOGGER.debug("Address from udpHandler: {}", address); + LOG.debug("Address from udpHandler: {}", address); isOnlineFuture.set(true); - LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); + LOG.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); f.channel().closeFuture().sync(); } catch (InterruptedException e) { - LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); + LOG.error("Interrupted while waiting for port {} shutdown", port, e); } finally { shutdown(); } @@ -186,7 +186,7 @@ protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfigurat } return; } catch (Throwable ex) { - LOGGER.debug("Epoll initiation failed"); + LOG.debug("Epoll initiation failed"); } //Fallback mechanism diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 64063943..34df0170 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -279,12 +279,12 @@ protected Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) { /* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */ private static final GenericFutureListener> LOG_ENCODER_LISTENER = new GenericFutureListener>() { - private final Logger LOGGER = LoggerFactory.getLogger("LogEncoderListener"); + private final Logger LOG = LoggerFactory.getLogger(GenericFutureListener.class); @Override public void operationComplete(final Future future) throws Exception { if (future.cause() != null) { - LOGGER.warn("Message encoding fail !", future.cause()); + LOG.warn("Message encoding fail !", future.cause()); } } }; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java index 6ee48183..7ba0f2c3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java @@ -29,7 +29,7 @@ */ public class DeserializerRegistryImpl implements DeserializerRegistry { - private static final Logger LOGGER = LoggerFactory.getLogger(DeserializerRegistryImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(DeserializerRegistryImpl.class); private Map registry; /** @@ -79,7 +79,7 @@ public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deser } OFGeneralDeserializer desInRegistry = registry.put(key, deserializer); if (desInRegistry != null) { - LOGGER.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key, + LOG.debug("Deserializer for key {} overwritten. Old deserializer: {}, new deserializer: {}", key, desInRegistry.getClass().getName(), deserializer.getClass().getName()); } if (deserializer instanceof DeserializerRegistryInjector) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java index 8c8ba389..5d3ecde7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java @@ -29,7 +29,9 @@ public EchoOutput deserialize(ByteBuf rawMessage) { builder.setXid(rawMessage.readUnsignedInt()); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { - builder.setData(rawMessage.readBytes(remainingBytes).array()); + byte[] data = new byte[remainingBytes]; + rawMessage.readBytes(data); + builder.setData(data); } return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java index 6e1e5597..446faf14 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java @@ -27,7 +27,9 @@ public EchoRequestMessage deserialize(ByteBuf rawMessage) { EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + byte[] data = new byte[rawMessage.readableBytes()]; + rawMessage.readBytes(data); + builder.setData(data); return builder.build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index daae3634..b11da58c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -63,8 +63,11 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { } decodeType(builder, errorType, type); decodeCode(rawMessage, builder, errorType); - if (rawMessage.readableBytes() > 0) { - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + int remainingBytes = rawMessage.readableBytes(); + if (remainingBytes > 0) { + byte[] data = new byte[remainingBytes]; + rawMessage.readBytes(data); + builder.setData(data); } return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java index ec45475e..107faa5a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java @@ -29,7 +29,9 @@ public EchoOutput deserialize(ByteBuf rawMessage) { builder.setXid(rawMessage.readUnsignedInt()); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { - builder.setData(rawMessage.readBytes(remainingBytes).array()); + byte[] data = new byte[remainingBytes]; + rawMessage.readBytes(data); + builder.setData(data); } return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java index a63c255d..a90044ca 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java @@ -27,7 +27,9 @@ public EchoRequestMessage deserialize(ByteBuf rawMessage) { EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + byte[] data = new byte[rawMessage.readableBytes()]; + rawMessage.readBytes(data); + builder.setData(data); return builder.build(); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java index db7376e6..aa8b9c8d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java @@ -40,8 +40,11 @@ public ErrorMessage deserialize(ByteBuf rawMessage) { ErrorTypeV10 errorType = ErrorTypeV10.forValue(type); decodeType(builder, errorType, type); decodeCode(rawMessage, builder, errorType); - if (rawMessage.readableBytes() > 0) { - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + int remainingBytes = rawMessage.readableBytes(); + if (remainingBytes > 0) { + byte[] data = new byte[remainingBytes]; + rawMessage.readBytes(data); + builder.setData(data); } return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java index 1f4d2c1e..94cce9b1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketOutInputMessageFactory.java @@ -47,7 +47,8 @@ public PacketOutInput deserialize(ByteBuf rawMessage) { rawMessage, keyMaker, registry); builder.setAction(actions); - byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array(); + byte[] data = new byte[rawMessage.readableBytes()]; + rawMessage.readBytes(data); if (data != null) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java index 44679569..a69baeea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java @@ -51,7 +51,9 @@ public PacketInMessage deserialize(final ByteBuf rawMessage) { OFDeserializer matchDeserializer = registry.getDeserializer(MATCH_KEY); builder.setMatch(matchDeserializer.deserialize(rawMessage)); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); - builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); + byte[] data = new byte[rawMessage.readableBytes()]; + rawMessage.readBytes(data); + builder.setData(data); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java index 6b1ddc94..919a8e74 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java @@ -38,7 +38,8 @@ public PacketOutInput deserialize(ByteBuf rawMessage) { List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, actions_len, rawMessage, keyMaker, registry); builder.setAction(actions); - byte[] data = rawMessage.readBytes(rawMessage.readableBytes()).array(); + byte[] data = new byte[rawMessage.readableBytes()]; + rawMessage.readBytes(data); if (data != null) { builder.setData(data); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java index 96307fa2..93831878 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializerRegistryImpl.java @@ -34,7 +34,7 @@ */ public class SerializerRegistryImpl implements SerializerRegistry { - private static final Logger LOGGER = LoggerFactory.getLogger(SerializerRegistryImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(SerializerRegistryImpl.class); private static final short OF10 = EncodeConstants.OF10_VERSION_ID; private static final short OF13 = EncodeConstants.OF13_VERSION_ID; private Map, OFGeneralSerializer> registry; @@ -83,7 +83,7 @@ public void registerSerializer(MessageTypeKey msgTypeKey, OFGeneralSerial } OFGeneralSerializer serInRegistry = registry.put(msgTypeKey, serializer); if (serInRegistry != null) { - LOGGER.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey, + LOG.debug("Serializer for key {} overwritten. Old serializer: {}, new serializer: {}", msgTypeKey, serInRegistry.getClass().getName(), serializer.getClass().getName()); } if (serializer instanceof SerializerRegistryInjector) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java index 32ecb5de..7022c98d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer.java @@ -32,7 +32,7 @@ * @author timotej.kubas */ public class OF13MatchSerializer implements OFSerializer, SerializerRegistryInjector { - private static final Logger LOGGER = LoggerFactory.getLogger(OF13MatchSerializer.class); + private static final Logger LOG = LoggerFactory.getLogger(OF13MatchSerializer.class); private static final byte STANDARD_MATCH_TYPE_CODE = 0; private static final byte OXM_MATCH_TYPE_CODE = 1; private SerializerRegistry registry; @@ -40,7 +40,7 @@ public class OF13MatchSerializer implements OFSerializer, SerializerRegis @Override public void serialize(Match match, ByteBuf outBuffer) { if (match == null) { - LOGGER.debug("Match is null"); + LOG.debug("Match is null"); return; } int matchStartIndex = outBuffer.writerIndex(); @@ -72,7 +72,7 @@ private static void serializeType(Match match, ByteBuf out) { */ public void serializeMatchEntries(List matchEntries, ByteBuf out) { if (matchEntries == null) { - LOGGER.debug("Match entries are null"); + LOG.debug("Match entries are null"); return; } for (MatchEntry entry : matchEntries) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index 3f900d80..d0c071e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -31,7 +31,7 @@ public final class StatisticsCounters implements StatisticsHandler { */ public static final int MINIMAL_LOG_REPORT_PERIOD = 500; private static StatisticsCounters instanceHolder; - private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCounters.class); + private static final Logger LOG = LoggerFactory.getLogger(StatisticsCounters.class); private Timer logReporter; private int logReportPeriod; @@ -70,7 +70,7 @@ private StatisticsCounters() { runCounting = false; this.logReportPeriod = 0; this.runLogReport = false; - LOGGER.debug("StaticsCounters has been created"); + LOG.debug("StaticsCounters has been created"); } /** @@ -83,7 +83,7 @@ public void startCounting(boolean reportToLogs, int logReportDelay){ return; } resetCounters(); - LOGGER.debug("Counting started..."); + LOG.debug("Counting started..."); if(reportToLogs){ startLogReport(logReportDelay); } @@ -95,7 +95,7 @@ public void startCounting(boolean reportToLogs, int logReportDelay){ */ public void stopCounting(){ runCounting = false; - LOGGER.debug("Stop counting..."); + LOG.debug("Stop counting..."); stopLogReport(); } @@ -127,7 +127,7 @@ public void startLogReport(int logReportDelay){ logReporter = new Timer("SC_Timer"); logReporter.schedule(new LogReporterTask(this), this.logReportPeriod, this.logReportPeriod); runLogReport = true; - LOGGER.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod); + LOG.debug("Statistics log reporter has been scheduled with period {} ms", this.logReportPeriod); } /** @@ -137,7 +137,7 @@ public void stopLogReport(){ if(runLogReport){ if(logReporter != null){ logReporter.cancel(); - LOGGER.debug("Statistics log reporter has been canceled"); + LOG.debug("Statistics log reporter has been canceled"); } runLogReport = false; } @@ -213,7 +213,7 @@ public void resetCounters() { for(CounterEventTypes cet : enabledCounters){ countersMap.get(cet).reset(); } - LOGGER.debug("StaticsCounters has been reset"); + LOG.debug("StaticsCounters has been reset"); } @Override @@ -241,7 +241,7 @@ public LogReporterTask(StatisticsCounters sc) { @Override public void run() { for(CounterEventTypes cet : sc.getEnabledCounters()){ - LOG.debug(cet.name() + ": " + sc.getCountersMap().get(cet).getStat()); + LOG.debug("{}: {}", cet.name(), sc.getCountersMap().get(cet).getStat()); } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java index 5de0a75f..e30b4d6b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/_switch/connection/provider/impl/rev140328/StatisticsCollectionModule.java @@ -11,7 +11,7 @@ */ public class StatisticsCollectionModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractStatisticsCollectionModule { - private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCollectionModule.class); + private static final Logger LOG = LoggerFactory.getLogger(StatisticsCollectionModule.class); public StatisticsCollectionModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); @@ -54,7 +54,7 @@ public int getLogReportDelay() { if (statsConfig != null) { statsCounter.startCounting(statsConfig.getStatisticsCollect(), statsConfig.getLogReportDelay()); } else { - LOGGER.debug("Unable to start StatisticCounter - wrong configuration"); + LOG.debug("Unable to start StatisticCounter - wrong configuration"); } /* Internal MXBean implementation */ @@ -93,11 +93,11 @@ public void close() { } catch (Exception e) { String errMsg = "Error by stoping StatisticsCollectionService."; - LOGGER.error(errMsg, e); + LOG.error(errMsg, e); throw new IllegalStateException(errMsg, e); } } - LOGGER.info("StatisticsCollection Service consumer (instance {} turn down.)", this); + LOG.info("StatisticsCollection Service consumer (instance {} turn down.)", this); } @Override @@ -112,7 +112,7 @@ public String printStatistics() { } AutoCloseable ret = new AutoClosableStatisticsCollection(); - LOGGER.info("StatisticsCollection service (instance {}) initialized.", ret); + LOG.info("StatisticsCollection service (instance {}) initialized.", ret); return ret; } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java index fcab9887..55ebf43d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/DummyDecoder.java @@ -23,13 +23,13 @@ */ public class DummyDecoder extends ByteToMessageDecoder { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(DummyDecoder.class); @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - LOGGER.debug("decoding"); + LOG.debug("decoding"); ctx.fireChannelReadComplete(); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java index 00785418..088201b3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java @@ -87,7 +87,7 @@ public void startUp() { new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); } - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(MultipartReplyMessageFactoryTest.class); /** @@ -678,7 +678,7 @@ public void testMultipartReplyMeterConfigBodyMulti(){ Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue()); Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue()); - LOGGER.info(message.getMeterConfig().get(0).getFlags().toString()); + LOG.info(message.getMeterConfig().get(0).getFlags().toString()); Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags()); Assert.assertEquals("Wrong meterId01", 7, diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java index cc0ba0df..0f70b3ea 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoOutputMessageFactoryTest.java @@ -47,7 +47,8 @@ public void testSerialize() throws Exception { ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); - Assert.assertArrayEquals("Wrong data", message.getData(), - serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + byte[] readData = new byte[serializedBuffer.readableBytes()]; + serializedBuffer.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java index 20f8b5fc..22135bb6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/EchoRequestMessageFactoryTest.java @@ -49,7 +49,8 @@ public void testSerialize() throws Exception { ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24); - Assert.assertArrayEquals("Wrong data", message.getData(), - serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + byte[] readData = new byte[serializedBuffer.readableBytes()]; + serializedBuffer.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java index ff3e70ea..929cbefe 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ErrorMessageFactoryTest.java @@ -52,7 +52,8 @@ public void testSerialize() throws Exception { BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28); Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort()); - Assert.assertArrayEquals("Wrong data", message.getData(), - serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + byte[] readData = new byte[serializedBuffer.readableBytes()]; + serializedBuffer.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java index d947b3fd..e9319a96 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactoryTest.java @@ -38,7 +38,7 @@ */ public class HelloInputMessageFactoryTest { - private static final Logger LOGGER = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class); + private static final Logger LOG = LoggerFactory.getLogger(HelloInputMessageFactoryTest.class); private SerializerRegistry registry; private OFSerializer helloFactory; @@ -84,8 +84,8 @@ public void testWith4BitVersionBitmap() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out)); + if (LOG.isDebugEnabled()) { + LOG.debug("bytebuf: {}", ByteBufUtils.byteBufToHexString(out)); } BufferHelper.checkHeaderV13(out, (byte) 0, 16); @@ -110,8 +110,8 @@ public void testWith64BitVersionBitmap() throws Exception { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); helloFactory.serialize(message, out); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out)); + if (LOG.isDebugEnabled()) { + LOG.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out)); } BufferHelper.checkHeaderV13(out, (byte) 0, 24); @@ -146,7 +146,7 @@ private static List createComparationElement(int lengthOfBitmap) { booleanList.add(false); } } - LOGGER.debug("boolsize {}", booleanList.size()); + LOG.debug("boolsize {}", booleanList.size()); elementsBuilder.setType(HelloElementType.forValue(1)); elementsBuilder.setVersionBitmap(booleanList); elementsList.add(elementsBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java index 5d3c3a8d..abe0055d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketInMessageFactoryTest.java @@ -58,7 +58,8 @@ public void testSerialize() throws Exception { Assert.assertEquals("Wrong port in", message.getInPort().intValue(), serializedBuffer.readUnsignedShort()); Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(1); - Assert.assertArrayEquals("Wrong data", message.getData(), - serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + byte[] readData = new byte[serializedBuffer.readableBytes()]; + serializedBuffer.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java index 6b1ff682..af4f139e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PacketOutInputMessageFactoryTest.java @@ -94,7 +94,9 @@ public void testPacketOutInputMessage() throws Exception { Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); - Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array()); + byte[] readData = new byte[out.readableBytes()]; + out.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); Assert.assertTrue("Unread data", out.readableBytes() == 0); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java index 550e9c72..8f917b7b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketInMessageFactoryTest.java @@ -121,8 +121,9 @@ public void testSerialize() throws Exception { Assert.assertEquals("Wrong oxm value", 4, serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(7); serializedBuffer.skipBytes(PADDING); - Assert.assertArrayEquals("Wrong data", message.getData(), - serializedBuffer.readBytes(serializedBuffer.readableBytes()).array()); + byte[] readData = new byte[serializedBuffer.readableBytes()]; + serializedBuffer.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java index 50c0839f..60ee5210 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PacketOutInputMessageFactoryTest.java @@ -96,7 +96,9 @@ public void testPacketOutInputMessage() throws Exception { Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(PADDING_IN_ACTION_HEADER); - Assert.assertArrayEquals("Wrong data", message.getData(), out.readBytes(out.readableBytes()).array()); + byte[] readData = new byte[out.readableBytes()]; + out.readBytes(readData); + Assert.assertArrayEquals("Wrong data", message.getData(), readData); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index 76fe9888..b9d2b0f5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -46,7 +46,7 @@ */ public class ActionsDeserializerTest { - private static final Logger LOGGER = LoggerFactory + private static final Logger LOG = LoggerFactory .getLogger(ActionsDeserializerTest.class); private DeserializerRegistry registry; @@ -82,7 +82,7 @@ public void test() { + "00 1B 00 08 00 00 00 00"); message.skipBytes(4); // skip XID - LOGGER.info("bytes: {}", message.readableBytes()); + LOG.info("bytes: {}", message.readableBytes()); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 999607d2..94b90b9d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -283,7 +283,7 @@ public void testIpv6Flabel() { byte[] label = new byte[4]; out.readBytes(label); - LOG.debug("label: "+ ByteBufUtils.bytesToHexString(label)); + LOG.debug("label: {}", ByteBufUtils.bytesToHexString(label)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[]{0, 0x0f, (byte) 0x9e, (byte) 0x8d}, label); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java index fb641622..6f2f772c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/statistics/StatisticsCountersTest.java @@ -21,7 +21,7 @@ */ public class StatisticsCountersTest { - private static final Logger LOGGER = LoggerFactory.getLogger(StatisticsCountersTest.class); + private static final Logger LOG = LoggerFactory.getLogger(StatisticsCountersTest.class); private StatisticsCounters statCounters; /** @@ -81,7 +81,7 @@ public void testCounterLastRead() { Assert.fail("No counter is enabled"); } incrementCounter(firstEnabledCET,testCount); - LOGGER.debug("Waiting to process event queue"); + LOG.debug("Waiting to process event queue"); Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); Assert.assertEquals("Wrong - bad value", testCount,statCounters.getCounter(firstEnabledCET).getCounterValue(false)); Assert.assertEquals("Wrong - bad last read value.", 0,statCounters.getCounter(firstEnabledCET).getCounterLastReadValue()); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java index 559c2279..5afb039f 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java @@ -29,7 +29,7 @@ */ public class ListeningSimpleClient implements OFClient { - private static final Logger LOGGER = LoggerFactory.getLogger(ListeningSimpleClient.class); + private static final Logger LOG = LoggerFactory.getLogger(ListeningSimpleClient.class); private int port; private boolean securedClient = false; private EventLoopGroup workerGroup; @@ -73,21 +73,21 @@ public void run() { isOnlineFuture.set(true); synchronized (scenarioHandler) { - LOGGER.debug("WAITING FOR SCENARIO"); + LOG.debug("WAITING FOR SCENARIO"); while (! scenarioHandler.isScenarioFinished()) { scenarioHandler.wait(); } } } catch (Exception ex) { - LOGGER.error(ex.getMessage(), ex); + LOG.error(ex.getMessage(), ex); } finally { - LOGGER.debug("listening client shutting down"); + LOG.debug("listening client shutting down"); try { workerGroup.shutdownGracefully().get(); bossGroup.shutdownGracefully().get(); - LOGGER.debug("listening client shutdown succesful"); + LOG.debug("listening client shutdown succesful"); } catch (InterruptedException | ExecutionException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); } } scenarioDone.set(true); @@ -97,7 +97,7 @@ public void run() { * @return close future */ public Future disconnect() { - LOGGER.debug("disconnecting client"); + LOG.debug("disconnecting client"); return workerGroup.shutdownGracefully(); } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 57865d88..44abb36d 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -25,7 +25,7 @@ */ public class ScenarioHandler extends Thread { - private static final Logger LOGGER = LoggerFactory.getLogger(ScenarioHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(ScenarioHandler.class); private Deque scenario; private BlockingQueue ofMsg; private ChannelHandlerContext ctx; @@ -45,19 +45,19 @@ public ScenarioHandler(Deque scenario) { public void run() { int freezeCounter = 0; while (!scenario.isEmpty()) { - LOGGER.debug("Running event #{}", eventNumber); + LOG.debug("Running event #{}", eventNumber); ClientEvent peek = scenario.peekLast(); if (peek instanceof WaitForMessageEvent) { - LOGGER.debug("WaitForMessageEvent"); + LOG.debug("WaitForMessageEvent"); try { WaitForMessageEvent event = (WaitForMessageEvent) peek; event.setHeaderReceived(ofMsg.poll(2000, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); break; } } else if (peek instanceof SendEvent) { - LOGGER.debug("Proceed - sendevent"); + LOG.debug("Proceed - sendevent"); SendEvent event = (SendEvent) peek; event.setCtx(ctx); } @@ -69,16 +69,16 @@ public void run() { freezeCounter++; } if (freezeCounter > 2) { - LOGGER.warn("Scenario frozen: {}", freezeCounter); + LOG.warn("Scenario frozen: {}", freezeCounter); break; } try { sleep(100); } catch (InterruptedException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); } } - LOGGER.debug("Scenario finished"); + LOG.debug("Scenario finished"); synchronized (this) { scenarioFinished = true; this.notify(); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index 3f456d12..9318d231 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -22,7 +22,7 @@ */ public class SendEvent implements ClientEvent { - protected static final Logger LOGGER = LoggerFactory.getLogger(SendEvent.class); + private static final Logger LOG = LoggerFactory.getLogger(SendEvent.class); protected byte[] msgToSend; protected ChannelHandlerContext ctx; @@ -38,15 +38,15 @@ public SendEvent(byte[] msgToSend) { @Override public boolean eventExecuted() { - LOGGER.debug("sending message"); - LOGGER.debug("start of run"); + LOG.debug("sending message"); + LOG.debug("start of run"); ByteBuf buffer = ctx.alloc().buffer(); buffer.writeBytes(msgToSend); ctx.writeAndFlush(buffer); - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend)); - LOGGER.debug("message sent"); + if (LOG.isDebugEnabled()) { + LOG.debug(">> {}", ByteBufUtils.bytesToHexString(msgToSend)); + LOG.debug("message sent"); } return true; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java index 5e98e3d6..fb0fda09 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java @@ -29,7 +29,7 @@ */ public class SimpleClient implements OFClient { - private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClient.class); + private static final Logger LOG = LoggerFactory.getLogger(SimpleClient.class); private final String host; private final int port; private boolean securedClient = false; @@ -72,20 +72,20 @@ public void run() { b.connect(host, port).sync(); synchronized (scenarioHandler) { - LOGGER.debug("WAITING FOR SCENARIO"); + LOG.debug("WAITING FOR SCENARIO"); while (! scenarioHandler.isScenarioFinished()) { scenarioHandler.wait(); } } } catch (Exception ex) { - LOGGER.error(ex.getMessage(), ex); + LOG.error(ex.getMessage(), ex); } finally { - LOGGER.debug("shutting down"); + LOG.debug("shutting down"); try { group.shutdownGracefully().get(); - LOGGER.debug("shutdown succesful"); + LOG.debug("shutdown succesful"); } catch (InterruptedException | ExecutionException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); } } scenarioDone.set(true); @@ -95,7 +95,7 @@ public void run() { * @return close future */ public Future disconnect() { - LOGGER.debug("disconnecting client"); + LOG.debug("disconnecting client"); return group.shutdownGracefully(); } @@ -115,8 +115,8 @@ public static void main(String[] args) throws Exception { int port; SimpleClient sc; if (args.length != 3) { - LOGGER.error("Usage: {} ", SimpleClient.class.getSimpleName()); - LOGGER.error("Trying to use default setting."); + LOG.error("Usage: {} ", SimpleClient.class.getSimpleName()); + LOG.error("Trying to use default setting."); InetAddress ia = InetAddress.getLocalHost(); InetAddress[] all = InetAddress.getAllByName(ia.getHostName()); host = all[0].getHostAddress(); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java index 1420ad8d..02c9cd98 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java @@ -28,34 +28,34 @@ public class SimpleClientFramer extends ByteToMessageDecoder { /** Length of OpenFlow 1.3 header */ public static final byte LENGTH_OF_HEADER = 8; private static final byte LENGTH_INDEX_IN_HEADER = 2; - private static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientFramer.class); + private static final Logger LOG = LoggerFactory.getLogger(SimpleClientFramer.class); /** * Constructor of class. */ public SimpleClientFramer() { - LOGGER.trace("Creating OFFrameDecoder"); + LOG.trace("Creating OFFrameDecoder"); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOGGER.warn("Unexpected exception from downstream.", cause); + LOG.warn("Unexpected exception from downstream.", cause); ctx.close(); } @Override protected void decode(ChannelHandlerContext chc, ByteBuf bb, List list) throws Exception { if (bb.readableBytes() < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes()); + LOG.debug("skipping bb - too few data for header: {}", bb.readableBytes()); return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { - LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); + LOG.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); return; } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java index acc53834..863f9aeb 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java @@ -25,7 +25,7 @@ */ public class SimpleClientHandler extends ChannelInboundHandlerAdapter { - protected static final Logger LOGGER = LoggerFactory.getLogger(SimpleClientHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(SimpleClientHandler.class); private static final int LENGTH_INDEX_IN_HEADER = 2; private SettableFuture isOnlineFuture; protected ScenarioHandler scenarioHandler; @@ -42,20 +42,20 @@ public SimpleClientHandler(SettableFuture isOnlineFuture, ScenarioHandl @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf bb = (ByteBuf) msg; - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("<< {}", ByteBufUtils.byteBufToHexString(bb)); + if (LOG.isDebugEnabled()) { + LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(bb)); } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); - LOGGER.trace("SimpleClientHandler - start of read"); + LOG.trace("SimpleClientHandler - start of read"); byte[] message = new byte[length]; bb.readBytes(message); scenarioHandler.addOfMsg(message); - LOGGER.trace("end of read"); + LOG.trace("end of read"); } @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - LOGGER.debug("Client is active"); + LOG.debug("Client is active"); if (isOnlineFuture != null) { isOnlineFuture.set(true); isOnlineFuture = null; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java index b1e1a50c..19229abc 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java @@ -18,7 +18,7 @@ */ public class SleepEvent implements ClientEvent { - private static final Logger LOGGER = LoggerFactory.getLogger(SleepEvent.class); + private static final Logger LOG = LoggerFactory.getLogger(SleepEvent.class); private long sleepTime; /** @@ -33,10 +33,10 @@ public SleepEvent(long sleepTime) { public boolean eventExecuted() { try { Thread.sleep(sleepTime); - LOGGER.debug("Sleeping"); + LOG.debug("Sleeping"); return true; } catch (InterruptedException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); } return false; } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java index e9d4644e..f7ff0a61 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java @@ -30,7 +30,7 @@ */ public class UdpSimpleClient implements OFClient { - private static final Logger LOGGER = LoggerFactory.getLogger(UdpSimpleClient.class); + private static final Logger LOG = LoggerFactory.getLogger(UdpSimpleClient.class); private final String host; private final int port; private EventLoopGroup group; @@ -73,20 +73,20 @@ public void run() { b.connect(host, port).sync(); synchronized (scenarioHandler) { - LOGGER.debug("WAITING FOR SCENARIO"); + LOG.debug("WAITING FOR SCENARIO"); while (! scenarioHandler.isScenarioFinished()) { scenarioHandler.wait(); } } } catch (Exception ex) { - LOGGER.error(ex.getMessage(), ex); + LOG.error(ex.getMessage(), ex); } finally { - LOGGER.debug("shutting down"); + LOG.debug("shutting down"); try { group.shutdownGracefully().get(); - LOGGER.debug("shutdown succesful"); + LOG.debug("shutdown succesful"); } catch (InterruptedException | ExecutionException e) { - LOGGER.error(e.getMessage(), e); + LOG.error(e.getMessage(), e); } } scenarioDone.set(true); @@ -96,7 +96,7 @@ public void run() { * @return close future */ public Future disconnect() { - LOGGER.debug("disconnecting client"); + LOG.debug("disconnecting client"); return group.shutdownGracefully(); } @@ -111,8 +111,8 @@ public static void main(String[] args) throws Exception { int port; UdpSimpleClient sc; if (args.length != 2) { - LOGGER.error("Usage: {} ", UdpSimpleClient.class.getSimpleName()); - LOGGER.error("Trying to use default setting."); + LOG.error("Usage: {} ", UdpSimpleClient.class.getSimpleName()); + LOG.error("Trying to use default setting."); InetAddress ia = InetAddress.getLocalHost(); InetAddress[] all = InetAddress.getAllByName(ia.getHostName()); host = all[0].getHostAddress(); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java index be73d27c..b893a8f3 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java @@ -29,18 +29,18 @@ public class UdpSimpleClientFramer extends MessageToMessageDecoder list) throws Exception { ByteBuf bb = msg.content(); if (bb.readableBytes() < LENGTH_OF_HEADER) { - LOGGER.debug("skipping bb - too few data for header: {}", bb.readableBytes()); + LOG.debug("skipping bb - too few data for header: {}", bb.readableBytes()); return; } int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); if (bb.readableBytes() < length) { - LOGGER.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); + LOG.debug("skipping bb - too few data for msg: {} < {}", bb.readableBytes(), length); return; } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + LOG.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); ByteBuf messageBuffer = bb.slice(bb.readerIndex(), length); list.add(messageBuffer); diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index b448111a..59228e36 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -20,7 +20,7 @@ */ public class WaitForMessageEvent implements ClientEvent { - private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class); + private static final Logger LOG = LoggerFactory.getLogger(WaitForMessageEvent.class); private byte[] headerExpected; private byte[] headerReceived; @@ -40,13 +40,13 @@ public boolean eventExecuted() { return false; } if (!Arrays.equals(headerExpected, headerReceived)) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected)); - LOGGER.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived)); + if (LOG.isDebugEnabled()) { + LOG.debug("expected msg: {}", ByteBufUtils.bytesToHexString(headerExpected)); + LOG.debug("received msg: {}", ByteBufUtils.bytesToHexString(headerReceived)); } return false; } - LOGGER.debug("Headers OK"); + LOG.debug("Headers OK"); return true; } From ea8f9bf63be76e855de63056f86c40d9d51fa7ea Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 5 May 2016 15:47:45 -0400 Subject: [PATCH 237/285] Remove unused property Change-Id: I219adf08931871495251d9bd0fb9100a40310bf0 Signed-off-by: Thanh Ha --- parent/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 1554d92b..cefc23be 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -49,7 +49,6 @@ - dav:http://nexus.opendaylight.org/content/sites/site UTF-8 ${project.build.directory}/yang-gen-config 1.7.0-SNAPSHOT From 89db8a3bf04990f7c4eebe7ff51c1faacd1343a1 Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Mon, 27 Jun 2016 15:28:59 +0200 Subject: [PATCH 238/285] Bug 5928 - Future error after OutboundQueueEntry.java failed In case that OutboundQueueEntry has failed and after that is called commit again on the same "entry" (completed entry) with callback, on this callback was never called onFailure. - try to store last OutboundQueueErorr - if commit called on completed entry and it has a callback send onFailure to the callback - added test for entire class Change-Id: Ie347811ac6dc2c95d58ad49bbf2aa4d69033b33c Signed-off-by: Jozef Bacigal --- .../core/connection/OutboundQueueEntry.java | 26 +++- .../connection/OutboundQueueEntryTest.java | 140 ++++++++++++++++++ 2 files changed, 161 insertions(+), 5 deletions(-) create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 70900cad..72efc18a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -7,6 +7,7 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; @@ -24,14 +25,22 @@ final class OutboundQueueEntry { private boolean completed; private boolean barrier; private volatile boolean committed; + private OutboundQueueException lastException = null; void commit(final OfHeader message, final FutureCallback callback) { - this.message = message; - this.callback = callback; - this.barrier = message instanceof BarrierInput; + if (this.completed) { + LOG.warn("Can't commit a completed message."); + if (callback != null) { + callback.onFailure(lastException); + } + } else { + this.message = message; + this.callback = callback; + this.barrier = message instanceof BarrierInput; - // Volatile write, needs to be last - committed = true; + // Volatile write, needs to be last + this.committed = true; + } } void reset() { @@ -103,6 +112,7 @@ boolean complete(final OfHeader response) { void fail(final OutboundQueueException cause) { if (!completed) { + lastException = cause; completed = true; if (callback != null) { callback.onFailure(cause); @@ -112,4 +122,10 @@ void fail(final OutboundQueueException cause) { LOG.warn("Ignoring failure {} for completed message", cause); } } + + @VisibleForTesting + /** This method is only for testing to prove that after queue entry is completed there is not callback future */ + boolean hasCallback() { + return (callback != null); + } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java new file mode 100644 index 00000000..7e0c71f7 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java @@ -0,0 +1,140 @@ +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import com.google.common.util.concurrent.FutureCallback; +import javax.annotation.Nullable; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * {@link OutboundQueueEntry} class test + */ +@RunWith(MockitoJUnitRunner.class) +public class OutboundQueueEntryTest { + + private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueEntryTest.class); + + private static final short VERSION = (short) 13; + private static final long VALUE = 1L; + + private Integer failCounter = 0; + + @Mock + private OfHeader ofHeader; + @Mock + private FutureCallback futureCallback; + + private final OutboundQueueEntry outboundQueueEntry = new OutboundQueueEntry(); + private final OfHeader barrierInput = new BarrierInputBuilder().setVersion(VERSION).setXid(VALUE).build(); + private final OfHeader packetOutInput = new PacketOutInputBuilder().setVersion(VERSION).setXid(VALUE).build(); + private final OfHeader multipartReplyMessage = + new MultipartReplyMessageBuilder().setVersion(VERSION).setXid(VALUE).setFlags(new MultipartRequestFlags(false)).build(); + private final OfHeader flowModInput = new FlowModInputBuilder().setVersion(VERSION).setXid(VALUE).build(); + private final OfHeader flowRemoved = new FlowRemovedMessageBuilder().setVersion(VERSION).setXid(VALUE).build(); + + @Test + public void commit() throws Exception { + outboundQueueEntry.commit(ofHeader, futureCallback); + Assert.assertTrue(outboundQueueEntry.isCommitted()); + Assert.assertFalse(outboundQueueEntry.isCompleted()); + Assert.assertFalse(outboundQueueEntry.isBarrier()); + } + + @Test + public void reset() throws Exception { + outboundQueueEntry.commit(ofHeader, futureCallback); + Assert.assertTrue(outboundQueueEntry.isCommitted()); + + outboundQueueEntry.reset(); + Assert.assertFalse(outboundQueueEntry.isCommitted()); + } + + @Test + public void isBarrier() throws Exception { + outboundQueueEntry.commit(barrierInput, futureCallback); + Assert.assertTrue(outboundQueueEntry.isBarrier()); + } + + @Test + public void takeMessage() throws Exception { + outboundQueueEntry.commit(packetOutInput, futureCallback); + outboundQueueEntry.takeMessage(); + Mockito.verify(futureCallback).onSuccess(Mockito.any()); + } + + @Test + public void complete() throws Exception { + final boolean result = outboundQueueEntry.complete(multipartReplyMessage); + Assert.assertTrue(result); + Assert.assertTrue(outboundQueueEntry.isCompleted()); + } + + @Test(expected = IllegalStateException.class) + public void completeTwice() throws Exception { + outboundQueueEntry.complete(multipartReplyMessage); + outboundQueueEntry.complete(multipartReplyMessage); + } + + @Test + public void fail() throws Exception { + outboundQueueEntry.commit(ofHeader, futureCallback); + outboundQueueEntry.fail(null); + Mockito.verify(futureCallback).onFailure(Mockito.any()); + } + + private Integer increaseFailCounter() { + return ++this.failCounter; + } + + @Test + public void test() throws Exception { + + final FutureCallback result = + new FutureCallback() { + + @Override + public void onSuccess(@Nullable OfHeader ofHeader) { + LOG.info("onSuccess: xid: {}", ofHeader.getXid()); + } + + @Override + public void onFailure(Throwable throwable) { + LOG.info("onFailure! Error: {}", throwable); + LOG.info("Failure called {} time", increaseFailCounter()); + } + }; + + /** This scenario creates entry with XID 1 then commit it, fail it and again commit it */ + /** Simulates behavior when entry is committed after fail */ + /** It shouldn't be in state completed and still have callback, it can consume all threads in thread pool */ + + /** Entry but no callback */ + outboundQueueEntry.commit(flowModInput, null); + /** Failed entry for whatever reason */ + outboundQueueEntry.fail(null); + /** Commit the same entry adding callback */ + outboundQueueEntry.commit(flowModInput, result); + + Assert.assertTrue(outboundQueueEntry.isCompleted()); + Assert.assertTrue(outboundQueueEntry.isCommitted()); + + /** This is check that no callback is in entry stuck */ + Assert.assertFalse(outboundQueueEntry.hasCallback()); + + Assert.assertTrue(this.failCounter == 1); + } + +} \ No newline at end of file From e4b17782624f8be78017d959a1bb5491e0f9e57c Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Wed, 29 Jun 2016 11:19:58 +0200 Subject: [PATCH 239/285] Prepare upgrade to Netty 4.1 We need to widen the range of allowed versions for odl-netty. Change-Id: I032697c714327a6ac0928da9f80a694e34d6fc76 Signed-off-by: Stephen Kitt --- features/src/main/features/features.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 111100a6..bd3b359e 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -17,7 +17,7 @@ odl-mdsal-models odl-config-api odl-mdsal-common - odl-netty + odl-netty mvn:org.opendaylight.openflowjava/openflow-protocol-api/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} From 7922eb22a643ae8f3806630a294f0cc7b6d37311 Mon Sep 17 00:00:00 2001 From: Lorand Jakab Date: Thu, 23 Jun 2016 15:08:57 -0500 Subject: [PATCH 240/285] Upgrade ietf-{inet,yang}-types to 2013-07-15 Change-Id: If7f7f70aa0ca0cc5937d4969ef143d21e959879f Signed-off-by: Lorand Jakab --- openflow-protocol-api/pom.xml | 4 ++-- .../SwitchConnectionProviderFactoryImpl.java | 2 +- .../match/OxmDeserializerHelper.java | 4 ++-- .../match/OxmIpDscpDeserializer.java | 2 +- .../match/OxmIpv6FlabelDeserializer.java | 2 +- .../match/OxmSctpDstDeserializer.java | 2 +- .../match/OxmSctpSrcDeserializer.java | 2 +- .../match/OxmTcpDstDeserializer.java | 2 +- .../match/OxmTcpSrcDeserializer.java | 2 +- .../match/OxmUdpDstDeserializer.java | 2 +- .../match/OxmUdpSrcDeserializer.java | 2 +- .../action/OF10SetDlDstActionSerializer.java | 2 +- .../action/OF10SetDlSrcActionSerializer.java | 2 +- .../action/OF10SetNwDstActionSerializer.java | 2 +- .../action/OF10SetNwSrcActionSerializer.java | 2 +- .../MultipartReplyMessageFactory.java | 2 +- .../OF10FeaturesReplyMessageFactory.java | 2 +- .../OF10PortModInputMessageFactory.java | 2 +- .../OF10PortStatusMessageFactory.java | 2 +- .../factories/PortModInputMessageFactory.java | 2 +- .../factories/PortStatusMessageFactory.java | 2 +- .../AbstractOxmIpv4AddressSerializer.java | 4 ++-- .../AbstractOxmMacAddressSerializer.java | 4 ++-- .../impl/util/OF10MatchSerializer.java | 4 ++-- ...nflow-switch-connection-provider-impl.yang | 4 ++-- .../OF10FeaturesReplyMessageFactoryTest.java | 4 ++-- .../OF10FlowModInputMessageFactoryTest.java | 4 ++-- .../OF10PortModInputMessageFactoryTest.java | 2 +- .../OF10PortStatusMessageFactoryTest.java | 4 ++-- ...StatsRequestInputAggregateFactoryTest.java | 4 ++-- .../OF10StatsRequestInputFlowFactoryTest.java | 4 ++-- .../PortModInputMessageFactoryTest.java | 2 +- .../PortStatusMessageFactoryTest.java | 2 +- .../multipart/MultipartReplyPortDescTest.java | 2 +- .../MultipartReplyMessageFactoryTest.java | 4 ++-- .../OF10FeaturesReplyMessageFactoryTest.java | 2 +- .../OF10FlowModInputMessageFactoryTest.java | 4 ++-- .../OF10FlowRemovedMessageFactoryTest.java | 4 ++-- .../OF10PortModInputMessageFactoryTest.java | 2 +- .../OF10PortStatusMessageFactoryTest.java | 2 +- .../OF10StatsReplyMessageFactoryTest.java | 4 ++-- .../OF10StatsRequestInputFactoryTest.java | 6 ++--- .../PortModInputMessageFactoryTest.java | 2 +- .../PortStatusMessageFactoryTest.java | 2 +- .../OF10StatsRequestAggregateTest.java | 6 ++--- .../match/OxmArpShaSerializerTest.java | 4 ++-- .../match/OxmArpSpaSerializerTest.java | 4 ++-- .../match/OxmArpThaSerializerTest.java | 4 ++-- .../match/OxmArpTpaSerializerTest.java | 4 ++-- .../match/OxmEthDstSerializerTest.java | 4 ++-- .../match/OxmEthSrcSerializerTest.java | 4 ++-- .../match/OxmIpDscpSerializerTest.java | 4 ++-- .../match/OxmIpv4DstSerializerTest.java | 4 ++-- .../match/OxmIpv4SrcSerializerTest.java | 4 ++-- .../match/OxmIpv6NdSllSerializerTest.java | 4 ++-- .../match/OxmIpv6NdTllSerializerTest.java | 4 ++-- .../match/OxmIpv6SrcSerializerTest.java | 2 +- .../match/OxmSctpDstSerializerTest.java | 4 ++-- .../match/OxmSctpSrcSerializerTest.java | 4 ++-- .../match/OxmTcpDstSerializerTest.java | 4 ++-- .../match/OxmTcpSrcSerializerTest.java | 4 ++-- .../match/OxmUdpDstSerializerTest.java | 4 ++-- .../match/OxmUdpSrcSerializerTest.java | 4 ++-- .../impl/util/MatchDeserializerTest.java | 6 ++--- .../util/OF10ActionsDeserializerTest.java | 2 +- .../impl/util/OF10ActionsSerializerTest.java | 6 ++--- .../impl/util/OF10MatchDeserializerTest.java | 4 ++-- .../impl/util/OF10MatchSerializerTest.java | 4 ++-- .../impl/util/OF13MatchSerializer02Test.java | 22 +++++++++---------- .../impl/util/OF13MatchSerializerTest.java | 8 +++---- .../openflow-switch-connection-config.yang | 4 ++-- .../openflowjava/util/ByteBufUtils.java | 14 ++++++------ 72 files changed, 134 insertions(+), 134 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 130523cf..c11aff87 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -54,11 +54,11 @@ org.opendaylight.mdsal.model - ietf-inet-types + ietf-inet-types-2013-07-15 org.opendaylight.mdsal.model - ietf-yang-types + ietf-yang-types-20130715 org.opendaylight.mdsal.model diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java index a3aae92e..79ad2665 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java index daeb2950..c28ba5c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmDeserializerHelper.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index b18a9de3..98c49af8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index 9016af5d..4ef1944a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -11,7 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index bbc137d5..cac4f806 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index 4a46edfd..8dc17a59 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index 55769578..7b3869b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index 57f44d16..5e8a7596 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index b631c815..9a978422 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index 29c722d8..501e70c3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java index d526eb01..f735a444 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java index 5e487c3f..dae1b318 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java index c7a2f34a..a0f9f53f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java index bf98a278..77e2be3d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java @@ -10,7 +10,7 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java index 52a547f0..4c5bd83a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactory.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java index 62de9328..0df774df 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactory.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java index be88873c..e4822a26 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactory.java @@ -12,7 +12,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java index 78d4e491..25d0f5ce 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactory.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index 3bb2f639..595a216c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -14,7 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java index e5a551c2..1a4e6fc8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactory.java @@ -13,7 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index 5dcba7ab..77e7651c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -9,8 +9,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; /** * Parent for Ipv4 address based match entry serializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index 487f6009..9dde0f0c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.match; import io.netty.buffer.ByteBuf; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; /** * Parent for MAC address based match entry serializers diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java index be005f06..a9db0af9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializer.java @@ -11,8 +11,8 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang index b41b3847..81e5b3e3 100644 --- a/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang +++ b/openflow-protocol-impl/src/main/yang/openflow-switch-connection-provider-impl.yang @@ -5,7 +5,7 @@ module openflow-switch-connection-provider-impl { import config {prefix config; revision-date 2013-04-05; } import openflow-switch-connection-provider {prefix openflow-switch-connection-provider; revision-date 2014-03-28; } - import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; } + import ietf-inet-types {prefix ietf-inet; revision-date 2013-07-15; } import openflow-configuration {prefix of-config; revision-date 2014-06-30; } import rpc-context { prefix rpcx; revision-date 2013-06-17; } @@ -189,4 +189,4 @@ module openflow-switch-connection-provider-impl { } } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index e759185e..594ca829 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; @@ -128,4 +128,4 @@ public void testWithNoPortsSet() { false, false, false, false, false, false), builtByFactory.getActionsV10()); Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java index 5f910a97..9ff3f055 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -20,8 +20,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java index 175245de..660ab5ce 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortModInputMessageFactoryTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java index 76b94b2c..9467e8d1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PortStatusMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; @@ -73,4 +73,4 @@ public void test(){ Assert.assertEquals("Wrong builtByFactory - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), builtByFactory.getPeerFeaturesV10()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java index 1c58e70d..5c8ce215 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputAggregateFactoryTest.java @@ -17,8 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java index e9c6dcb0..613ff4a1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFlowFactoryTest.java @@ -17,8 +17,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java index 6a0c9740..b27bb279 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortModInputMessageFactoryTest.java @@ -17,7 +17,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java index c3b16b9c..84653207 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java index 3f04e709..d601cfa5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -14,7 +14,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java index 05a106a0..a6e18bde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartReplyMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; @@ -1493,4 +1493,4 @@ private static MultipartReplyDescCase decodeDescBody(ByteBuf output) { descCase.setMultipartReplyDesc(desc.build()); return descCase.build(); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java index dc2758bc..ecfbcad5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -22,7 +22,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java index 0d765be1..b8343bbd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowModInputMessageFactoryTest.java @@ -25,8 +25,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java index fdd24fe9..ed54d82e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10FlowRemovedMessageFactoryTest.java @@ -20,8 +20,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java index 1b98d77d..da063fbd 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortModInputMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java index 8f97bc89..11688279 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10PortStatusMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java index eff1c0fe..8b52cb01 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -22,8 +22,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index da2486c4..c44b9f0c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -20,8 +20,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -300,4 +300,4 @@ public void testQueue() throws Exception { Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); Assert.assertTrue("Unread data", out.readableBytes() == 0); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index 12e756a5..3aebd727 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -20,7 +20,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java index dd872501..362d2fd8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortStatusMessageFactoryTest.java @@ -19,7 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 220a2af5..48106634 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -21,8 +21,8 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -99,4 +99,4 @@ public void test() throws Exception { out.skipBytes(1); Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java index 145772b7..a3100d65 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java index 176595da..5e5fcc4b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java index a753c964..062178ce 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java index 78812111..11b64a33 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java index c442608b..137c47aa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java index 263399dc..f171505a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java index 527252b8..b7cc4aef 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java index e4c184f9..233a5469 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java index c1c8f9eb..286cbab6 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -154,4 +154,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); } } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java index d625317c..5a1b6ca0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -112,4 +112,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java index 02680589..8d6d95cc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -112,4 +112,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java index 38ca6dc7..386d1cd4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializerTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java index dd51c957..b3a1fa90 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java index ca46f9ef..3c6eb1fb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java index adcdf7bb..c6033946 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java index 003c6e62..a0be555f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java index a77e20ec..10166595 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java index 9edfccb4..db7a60e0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; @@ -109,4 +109,4 @@ private static void checkHeader(ByteBuf buffer, boolean hasMask) { assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 6fa7be12..792f1f9d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -22,9 +22,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 9bc4b84b..8c0d4eaa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -15,7 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index f66aa061..07f11eba 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -20,8 +20,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder; @@ -219,4 +219,4 @@ public void test() { Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); } -} \ No newline at end of file +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java index 09a5c19f..d4f7b9be 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializerTest.java @@ -18,8 +18,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java index db16f9c5..4e27095e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchSerializerTest.java @@ -20,8 +20,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index a7bad7ae..e27c049a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -21,11 +21,11 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; @@ -345,7 +345,7 @@ public void test() { TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder(); TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder(); tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6653)); tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build()); entryBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); @@ -356,7 +356,7 @@ public void test() { TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder(); TcpDstBuilder tcpDstBuilder = new TcpDstBuilder(); tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6654)); tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build()); entryBuilder.setMatchEntryValue(tcpDstCaseBuilder.build()); entries.add(entryBuilder.build()); @@ -367,7 +367,7 @@ public void test() { UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder(); UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder(); udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6655)); udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build()); entryBuilder.setMatchEntryValue(udpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); @@ -378,7 +378,7 @@ public void test() { UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder(); UdpDstBuilder udpDstBuilder = new UdpDstBuilder(); udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6656)); udpDstCaseBuilder.setUdpDst(udpDstBuilder.build()); entryBuilder.setMatchEntryValue(udpDstCaseBuilder.build()); entries.add(entryBuilder.build()); @@ -389,7 +389,7 @@ public void test() { SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder(); SctpSrcBuilder sctpSrcBuilder = new SctpSrcBuilder(); sctpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6657)); sctpSrcCaseBuilder.setSctpSrc(sctpSrcBuilder.build()); entryBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build()); entries.add(entryBuilder.build()); @@ -400,7 +400,7 @@ public void test() { SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder(); SctpDstBuilder sctpDstBuilder = new SctpDstBuilder(); sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); + .xml.ns.yang.ietf.inet.types.rev130715.PortNumber(6658)); sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build()); entryBuilder.setMatchEntryValue(sctpDstCaseBuilder.build()); entries.add(entryBuilder.build()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 94b90b9d..5dce30ab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -23,9 +23,9 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; @@ -395,4 +395,4 @@ public void testSerializeExperimenterMatchEntry() { private class OxmMatchFieldClass extends MatchField { // only for testing purposes } -} \ No newline at end of file +} diff --git a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang index 53cfe088..091f02a5 100644 --- a/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang +++ b/openflow-protocol-spi/src/main/yang/openflow-switch-connection-config.yang @@ -3,7 +3,7 @@ module openflow-switch-connection-config { namespace "urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:config"; prefix "openflow-switch-connection-config"; - import ietf-inet-types {prefix ietf-inet; revision-date 2010-09-24; } + import ietf-inet-types {prefix ietf-inet; revision-date 2013-07-15; } import openflow-configuration {prefix of-config; revision-date 2014-06-30; } description @@ -113,4 +113,4 @@ module openflow-switch-connection-config { } } } -} \ No newline at end of file +} diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 032d87f9..f9ed9fb3 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -19,11 +19,11 @@ import java.util.Map; import java.util.Map.Entry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IetfInetUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.IetfYangUtil; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; /** Class for common operations on ByteBuf @@ -224,7 +224,7 @@ private static int hexValue(final char c) { /** * Converts macAddress to byte array. - * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress}. + * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress}. * * @param macAddress * @return byte representation of mac address @@ -280,7 +280,7 @@ private static void appendHexUnsignedShort(final StringBuilder sb, final int val /** * Converts a MAC address represented in bytes to String. - * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress}. + * See also {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress}. * * @param address * @return String representation of a MAC address From 3864b81c444e5c91ca750b76b391886dc847b554 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Fri, 22 Jul 2016 22:27:08 -0400 Subject: [PATCH 241/285] Add missing license headers Change-Id: Ia8907b48549f18b627d74c45df38c1bbf2e4d720 Signed-off-by: Thanh Ha --- .../openflowjava/protocol/api/keys/KeysTest.java | 7 +++++++ .../impl/core/connection/OutboundQueueEntryTest.java | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java index c23d4b3c..d2aefedb 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.openflowjava.protocol.api.keys; import org.junit.Assert; diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java index 7e0c71f7..08c98c41 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntryTest.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.util.concurrent.FutureCallback; @@ -137,4 +144,4 @@ public void onFailure(Throwable throwable) { Assert.assertTrue(this.failCounter == 1); } -} \ No newline at end of file +} From c1db8b191643be117b28bb82a3a6371d4b23d6e9 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Tue, 2 Aug 2016 11:25:28 +0200 Subject: [PATCH 242/285] Bug 5895 - Support of Ext109 openflow tcp flag matching - added openflow-approved-extensions.yang module - added (de)serializer for TCP flags match entry (ext-109) - also a reference material for adding other approved match entry extensions Change-Id: I042d71e5a8b56f6b6460ef235442568d411533da Signed-off-by: Michal Polkorab Also-By: Anil Vishnoi --- .../protocol/api/util/OxmMatchConstants.java | 9 +++ .../yang/openflow-approved-extensions.yang | 40 +++++++++++ .../MatchEntryDeserializerInitializer.java | 5 ++ ...OxmExperimenterMatchEntryDeserializer.java | 30 ++++++++ .../match/ext/OnfOxmTcpFlagsDeserializer.java | 68 +++++++++++++++++++ .../MatchEntriesInitializer.java | 7 ++ ...ctOxmExperimenterMatchEntrySerializer.java | 59 ++++++++++++++++ .../match/ext/OnfOxmTcpFlagsSerializer.java | 65 ++++++++++++++++++ .../MatchEntryDeserializerRegistryHelper.java | 8 +++ .../MatchEntrySerializerRegistryHelper.java | 14 ++++ .../impl/util/OF13MatchSerializerTest.java | 2 + 11 files changed, 307 insertions(+) create mode 100644 openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 3768f2f5..f4da03ce 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -115,6 +115,15 @@ public abstract class OxmMatchConstants { /** NXM TCP_Flag value */ public static final int NXM_NX_TCP_FLAG = 34; + /** + * ONF Approved Extensions Constants + */ + + /** ONFOXM_ET_TCP_FLAGS value */ + public static final int ONFOXM_ET_TCP_FLAGS = 42; + /** ONFOXM_ET_TCP_FLAGS Experimenter Id (0x4F4E4600) */ + public static final long ONFOXM_ET_TCP_FLAGS_EXP_ID = 1330529792; + private OxmMatchConstants() { //not called } diff --git a/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang new file mode 100644 index 00000000..d4afa880 --- /dev/null +++ b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang @@ -0,0 +1,40 @@ +module openflow-approved-extensions { + namespace "urn:opendaylight:openflow:approved:extensions"; + prefix "ofext"; + + import yang-ext {prefix ext;} + import ietf-inet-types {prefix inet;} + import ietf-yang-types {prefix yang;} + + import openflow-types {prefix oft;} + import openflow-protocol {prefix ofproto;} + import openflow-action {prefix ofaction;} + import openflow-instruction {prefix ofinstruction;} + import openflow-extensible-match {prefix oxm;} + import openflow-augments {prefix aug;} + + revision "2016-08-02" { + description "Openflow approved extensions definition"; + } + + //ONF Approved OpenFlow Extensions + + // Extension 109 - TCP FLAGS + identity tcp_flags { + base oxm:match-field; + description "TCP flags from the TCP header"; + } + + augment "/oxm:oxm-container/oxm:match-entry-value/aug:experimenter-id-case" { + ext:augment-identifier "tcp-flags-container"; + container tcp-flags { + leaf flags { + type uint16; + } + leaf mask { + type binary; + } + } + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index 21d9dcb1..dc1bae06 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -49,6 +49,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext.OnfOxmTcpFlagsDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; @@ -111,5 +112,9 @@ public static void registerMatchEntryDeserializers(DeserializerRegistry registry helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); + + // Register approved openflow match entry deserializers + helper.registerExperimenter(OxmMatchConstants.ONFOXM_ET_TCP_FLAGS, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID, + new OnfOxmTcpFlagsDeserializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java new file mode 100644 index 00000000..e9535d8e --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.AbstractOxmMatchEntryDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; + +/** + * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/26/16. + */ +public abstract class AbstractOxmExperimenterMatchEntryDeserializer extends AbstractOxmMatchEntryDeserializer { + + protected ExperimenterIdCaseBuilder createExperimenterIdCase(MatchEntryBuilder entryBuilder, ByteBuf input) { + ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder(); + ExperimenterBuilder expBuilder = new ExperimenterBuilder(); + expBuilder.setExperimenter(new ExperimenterId(input.readUnsignedInt())); + expCaseBuilder.setExperimenter(expBuilder.build()); + return expCaseBuilder; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java new file mode 100644 index 00000000..e03ed77a --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; + +/** + * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/26/16. + */ +public class OnfOxmTcpFlagsDeserializer extends AbstractOxmExperimenterMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntry deserialize(ByteBuf input) { + MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(deserializeHeader(input)); + ExperimenterIdCaseBuilder expCaseBuilder = createExperimenterIdCase(matchEntryBuilder, input); + addTcpFlagsAugmentation(input, expCaseBuilder, matchEntryBuilder.isHasMask()); + matchEntryBuilder.setMatchEntryValue(expCaseBuilder.build()); + return matchEntryBuilder.build(); + + } + + private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) { + TcpFlagsContainerBuilder flagsContainerBuilder = new TcpFlagsContainerBuilder(); + TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder(); + flagsBuilder.setFlags(input.readUnsignedShort()); + if (hasMask) { + byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES]; + input.readBytes(mask); + flagsBuilder.setMask(mask); + } + flagsContainerBuilder.setTcpFlags(flagsBuilder.build()); + expCaseBuilder.addAugmentation(TcpFlagsContainer.class, flagsContainerBuilder.build()); + } + + /** + * @return oxm_field class + */ + @Override + protected Class getOxmField() { + return TcpFlags.class; + } + + /** + * @return oxm_class class + */ + @Override + protected Class getOxmClass() { + return ExperimenterClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 55d92239..2ed24e59 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -9,6 +9,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; @@ -49,7 +50,9 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.ext.OnfOxmTcpFlagsSerializer; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa; @@ -152,5 +155,9 @@ public static void registerMatchEntrySerializers(SerializerRegistry serializerRe helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); + + // Register approved openflow match entry serializers + helper.registerExperimenterSerializer(TcpFlags.class, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID, + new OnfOxmTcpFlagsSerializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java new file mode 100644 index 00000000..fec3df21 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/AbstractOxmExperimenterMatchEntrySerializer.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match.ext; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.AbstractOxmMatchEntrySerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; + +/** + * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16. + */ +public abstract class AbstractOxmExperimenterMatchEntrySerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + serializeHeader(entry, outBuffer); + } + + @Override + public void serializeHeader(MatchEntry entry, ByteBuf outBuffer) { + outBuffer.writeShort(getOxmClassCode()); + writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), + getValueLength()); + } + + protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { + int fieldAndMask = fieldValue << 1; + int length = lengthArg; + if (hasMask) { + fieldAndMask |= 1; + length *= 2; + } + + //Add experimenter-id lenge + length = length + EncodeConstants.SIZE_OF_INT_IN_BYTES; + out.writeByte(fieldAndMask); + out.writeByte(length); + } + + protected ExperimenterIdCase serializeExperimenterId(MatchEntry matchEntry, ByteBuf out) { + ExperimenterIdCase expCase = (ExperimenterIdCase) matchEntry.getMatchEntryValue(); + out.writeInt(expCase.getExperimenter().getExperimenter().getValue().intValue()); + return expCase; + } + + /** + * @return Experimenter match entry ID + */ + protected abstract long getExperimenterId(); +} + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java new file mode 100644 index 00000000..340dc7ae --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.match.ext; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; + +/** + * Created by Anil Vishnoi (avishnoi@Brocade.com) on 7/25/16. + */ +public class OnfOxmTcpFlagsSerializer extends AbstractOxmExperimenterMatchEntrySerializer { + + @Override + public void serialize(MatchEntry entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + ExperimenterIdCase expCase = serializeExperimenterId(entry, outBuffer); + TcpFlags tcpFlags = expCase.getAugmentation(TcpFlagsContainer.class).getTcpFlags(); + outBuffer.writeShort(tcpFlags.getFlags()); + if (entry.isHasMask()) { + outBuffer.writeBytes(tcpFlags.getMask()); + } + } + + /** + * @return Experimenter match entry ID + */ + @Override + protected long getExperimenterId() { + return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID; + } + + /** + * @return numeric representation of oxm_field + */ + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS; + } + + /** + * @return numeric representation of oxm_class + */ + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.EXPERIMENTER_CLASS; + } + + /** + * @return match entry value length (without mask length) + */ + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index e666f11e..96d01c3d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -10,6 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** * @author michal.polkorab @@ -44,4 +45,11 @@ public void register(int oxmField, OFGeneralDeserializer deserializer) { key.setExperimenterId(null); registry.registerDeserializer(key, deserializer); } + + public void registerExperimenter(int oxmField, long expId, OFGeneralDeserializer deserializer) { + MatchEntryDeserializerKey key = + new MatchEntryDeserializerKey(version, OxmMatchConstants.EXPERIMENTER_CLASS, oxmField); + key.setExperimenterId(expId); + registry.registerDeserializer(key, deserializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 1c704bb2..d9c76295 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -10,6 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; @@ -46,4 +47,17 @@ public void registerSerializer( key.setExperimenterId(null); serializerRegistry.registerSerializer(key, serializer); } + + /** + * Registers ExperimenterClass type match serializer + * @param specificClass + * @param serializer + */ + public void registerExperimenterSerializer( + Class specificClass, long expId, OFGeneralSerializer serializer) { + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, ExperimenterClass.class, specificClass); + key.setExperimenterId(expId); + serializerRegistry.registerSerializer(key, serializer); + } + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java index 5dce30ab..0c2a6aa0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializerTest.java @@ -26,6 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; From 3c2af08bd8f5d0575d9ff32251f49ea6b0eef329 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Mon, 8 Aug 2016 17:50:19 -0400 Subject: [PATCH 243/285] Bump versions by 0.1.0 for next dev cycle Change-Id: I247e00fe7f3ff830760006711c6d61b8174cb4ba Signed-off-by: Thanh Ha --- artifacts/pom.xml | 4 ++-- features/pom.xml | 16 ++++++++-------- openflow-protocol-api/pom.xml | 8 ++++---- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-it/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- openflowjava-config/pom.xml | 2 +- openflowjava-util/pom.xml | 2 +- parent/pom.xml | 14 +++++++------- pom.xml | 2 +- simple-client/pom.xml | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 94856e82..5d88c467 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,13 +14,13 @@ org.opendaylight.odlparent odlparent-lite - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-artifacts - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT pom diff --git a/features/pom.xml b/features/pom.xml index f35b4d8a..78c6d669 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,21 +4,21 @@ org.opendaylight.odlparent features-parent - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT org.opendaylight.openflowjava features-openflowjava - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT jar - 0.5.0-SNAPSHOT - 1.4.0-SNAPSHOT - 2.1.0-SNAPSHOT - 1.4.0-SNAPSHOT - 0.9.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.5.0-SNAPSHOT + 2.2.0-SNAPSHOT + 1.5.0-SNAPSHOT + 0.10.0-SNAPSHOT @@ -36,7 +36,7 @@ org.opendaylight.odlparent odlparent-artifacts - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT import pom diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index c11aff87..3d815745 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.mdsal binding-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT org.opendaylight.openflowjava openflow-protocol-api - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT bundle Openflow Protocol Library - API @@ -18,8 +18,8 @@ - 2.1.0-SNAPSHOT - 0.9.0-SNAPSHOT + 2.2.0-SNAPSHOT + 0.10.0-SNAPSHOT diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 0c3fc442..e91846e0 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent openflow-protocol-impl diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index 12b0774f..b93ba9e6 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent openflow-protocol-it diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 1d82eefd..2e7057b6 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent openflow-protocol-spi diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index dc9de5fa..1f7bc3e0 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent openflowjava-config diff --git a/openflowjava-util/pom.xml b/openflowjava-util/pom.xml index f6bb3e54..27ffc9bc 100644 --- a/openflowjava-util/pom.xml +++ b/openflowjava-util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent bundle diff --git a/parent/pom.xml b/parent/pom.xml index cefc23be..00cfc5dc 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent odlparent - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT pom openflowjava @@ -51,13 +51,13 @@ UTF-8 ${project.build.directory}/yang-gen-config - 1.7.0-SNAPSHOT + 1.8.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - 0.5.0-SNAPSHOT - 1.4.0-SNAPSHOT - 0.9.0-SNAPSHOT - 1.0.0-SNAPSHOT + 0.6.0-SNAPSHOT + 1.5.0-SNAPSHOT + 0.10.0-SNAPSHOT + 1.1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index dc4ee45a..05052397 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT parent diff --git a/simple-client/pom.xml b/simple-client/pom.xml index a74dca65..5eb462b5 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.8.0-SNAPSHOT + 0.9.0-SNAPSHOT ../parent simple-client From 79f44f82601b1f12fa97bbb537ed771e5267a99a Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Tue, 6 Sep 2016 11:14:17 +0200 Subject: [PATCH 244/285] Bug 6638 Failed entries marked as completed also counted as completed Change-Id: Ia4a0f334d831313eb419b327cf9b8f5fa9a464b4 Signed-off-by: Andrej Leitner --- .../protocol/impl/core/connection/StackedSegment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java index c971c663..43aa002a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java @@ -180,6 +180,7 @@ int failAll(final OutboundQueueException cause) { if (!entry.isCompleted()) { entry.fail(cause); + completeCount++; ret++; } } From 76b6a1562776b15e65d753349f95906f443e5e51 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Tue, 6 Sep 2016 15:13:44 +0200 Subject: [PATCH 245/285] Bug 6646 Fix infinite reschedule of flush - sometimes (on disconnect) there can be still some unflushed segments but they are not able to be flushed if channel is not writable anymore and we get to infinite loop of flushing (but not writing) Change-Id: I74cac21b4635e22f5b8d63f3a602f40796108059 Signed-off-by: Andrej Leitner --- .../connection/AbstractOutboundQueueManager.java | 4 ++-- .../connection/AbstractStackedOutboundQueue.java | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java index 34df0170..bec266bb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java @@ -173,7 +173,7 @@ public void channelInactive(final ChannelHandlerContext ctx) throws Exception { // Then we start queue shutdown, start counting written messages (so that we don't keep sending messages // indefinitely) and failing not completed entries. shuttingDown = true; - final long entries = currentQueue.startShutdown(ctx.channel()); + final long entries = currentQueue.startShutdown(); LOG.debug("Cleared {} queue entries from channel {}", entries, ctx.channel()); // Finally, we schedule flush task that will take care of unflushed entries. We also cover the case, @@ -301,7 +301,7 @@ protected void flush() { rescheduleFlush(); } else { close(); - if (currentQueue.finishShutdown()) { + if (currentQueue.finishShutdown(parent.getChannel())) { LOG.debug("Channel {} shutdown complete", parent.getChannel()); } else { LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index 75963335..16106a1a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -244,7 +244,7 @@ boolean needsFlush() { return firstSegment.getEntry(flushOffset).isCommitted(); } - long startShutdown(final Channel channel) { + long startShutdown() { /* * We are dealing with a multi-threaded shutdown, as the user may still * be reserving entries in the queue. We are executing in a netty thread, @@ -268,18 +268,19 @@ long startShutdown(final Channel channel) { /** * Checks if the shutdown is in final phase -> all allowed entries (number of entries < shutdownOffset) are flushed * and fails all not completed entries (if in final phase) + * @param channel netty channel * @return true if in final phase, false if a flush is needed */ - boolean finishShutdown() { + boolean finishShutdown(final Channel channel) { boolean needsFlush; synchronized (unflushedSegments) { // Fails all entries, that were flushed in shutdownOffset (became uncompleted) // - they will never be completed due to disconnected channel. lockedFailSegments(uncompletedSegments.iterator()); - // If no further flush is needed, than we fail all unflushed segments, so that each enqueued entry - // is reported as unsuccessful due to channel disconnection. No further entries should be enqueued - // by this time. - needsFlush = needsFlush(); + // If no further flush is needed or we are not able to write to channel anymore, then we fail all unflushed + // segments, so that each enqueued entry is reported as unsuccessful due to channel disconnection. + // No further entries should be enqueued by this time. + needsFlush = channel.isWritable() && needsFlush(); if (!needsFlush) { lockedFailSegments(unflushedSegments.iterator()); } From e522c58d71ba5eed20ec5199b8cad6ad22550079 Mon Sep 17 00:00:00 2001 From: yunyunhan Date: Sat, 10 Sep 2016 01:34:15 +0800 Subject: [PATCH 246/285] Bug 6674 - the key of the serialization function registered by the vendor is not refinement enough Change-Id: Ibe9c63f03850730c7d7346820d37786d6711f861 Signed-off-by: yunyunhan (cherry picked from commit f93ddeaf5e4f25a0a47438786777d13c9b95e46d) --- ...perimenterIdMeterSubTypeSerializerKey.java | 62 +++++++++++++++++++ .../src/main/yang/openflow-augments.yang | 5 ++ .../src/main/yang/openflow-types.yang | 4 ++ .../MeterModInputMessageFactory.java | 30 ++++++--- .../ExperimenterSerializerKeyFactory.java | 9 ++- .../ExperimenterSerializerKeyFactoryTest.java | 30 +++++++++ 6 files changed, 130 insertions(+), 10 deletions(-) create mode 100755 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdMeterSubTypeSerializerKey.java mode change 100644 => 100755 openflow-protocol-api/src/main/yang/openflow-augments.yang mode change 100644 => 100755 openflow-protocol-api/src/main/yang/openflow-types.yang mode change 100644 => 100755 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java mode change 100644 => 100755 openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java mode change 100644 => 100755 openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdMeterSubTypeSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdMeterSubTypeSerializerKey.java new file mode 100755 index 00000000..f568a028 --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdMeterSubTypeSerializerKey.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016 ZTE, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.keys; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * Created by hyy on 2016/9/8. + */ +public class ExperimenterIdMeterSubTypeSerializerKey extends ExperimenterIdSerializerKey { + + private Class meterSubType; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of object to be serialized + * @param meterSubType vendor defined subtype + */ + public ExperimenterIdMeterSubTypeSerializerKey(short msgVersion, long experimenterId, + Class objectClass, Class meterSubType) { + super(msgVersion, experimenterId, objectClass); + this.meterSubType = meterSubType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((meterSubType == null) ? 0 : meterSubType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ExperimenterIdMeterSubTypeSerializerKey other = (ExperimenterIdMeterSubTypeSerializerKey) obj; + if (meterSubType == null) { + if (other.meterSubType != null) { + return false; + } + } else if (!meterSubType.equals(other.meterSubType)) { + return false; + } + return true; + } + +} diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang old mode 100644 new mode 100755 index e5be7e56..4a60c37e --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -127,5 +127,10 @@ leaf experimenter { type oft:experimenter-id; } + leaf sub-type { + type identityref { + base oft:experimenter-meter-band-sub-type; + } + } } } diff --git a/openflow-protocol-api/src/main/yang/openflow-types.yang b/openflow-protocol-api/src/main/yang/openflow-types.yang old mode 100644 new mode 100755 index 251a845e..7d11bafa --- a/openflow-protocol-api/src/main/yang/openflow-types.yang +++ b/openflow-protocol-api/src/main/yang/openflow-types.yang @@ -206,6 +206,10 @@ description "Base identity for action types"; } + identity experimenter-meter-band-sub-type { + description "The base identity for vendor's meter bands."; + } + typedef metadata { type binary; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java old mode 100644 new mode 100755 index 770c0cfd..36eb64f5 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MeterModInputMessageFactory.java @@ -9,9 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - -import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; @@ -19,6 +16,7 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterBandCommons; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput; @@ -30,6 +28,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemark; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenter; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; /** * Translates MeterMod messages @@ -39,6 +41,8 @@ public class MeterModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { + private static final Logger LOG = LoggerFactory + .getLogger(MeterModInputMessageFactory.class); private static final byte MESSAGE_TYPE = 29; private static final short LENGTH_OF_METER_BANDS = 16; private static final short PADDING_IN_METER_BAND_DROP = 4; @@ -81,12 +85,20 @@ private void serializeBands(final List bands, final ByteBuf outBuffer) { } else if (meterBand instanceof MeterBandExperimenterCase) { MeterBandExperimenterCase experimenterBandCase = (MeterBandExperimenterCase) meterBand; MeterBandExperimenter experimenterBand = experimenterBandCase.getMeterBandExperimenter(); - long expId = experimenterBand.getAugmentation(ExperimenterIdMeterBand.class) - .getExperimenter().getValue(); - OFSerializer serializer = registry.getSerializer( - ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF13_VERSION_ID, expId)); - serializer.serialize(experimenterBandCase, outBuffer); + ExperimenterIdMeterBand expIdMeterBand = experimenterBand.getAugmentation(ExperimenterIdMeterBand.class); + if (expIdMeterBand != null) { + long expId = expIdMeterBand.getExperimenter().getValue(); + Class meterBandSubType = expIdMeterBand.getSubType(); + try { + OFSerializer serializer = registry.getSerializer( + ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType)); + serializer.serialize(experimenterBandCase, outBuffer); + } catch (final IllegalStateException e) { + LOG.warn("Serializer for key: {} wasn't found, exception {}", ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF13_VERSION_ID, expId, meterBandSubType), e); + } + } } } } diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java old mode 100644 new mode 100755 index edc6f25e..0155893d --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -8,8 +8,10 @@ package org.opendaylight.openflowjava.util; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; @@ -59,6 +61,11 @@ public static ExperimenterIdSerializerKey createMultipar */ public static ExperimenterIdSerializerKey createMeterBandSerializerKey( short msgVersion, long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); + return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class, null); + } + + public static ExperimenterIdSerializerKey createMeterBandSerializerKey( + short msgVersion, long experimenterId, Class meterSubType) { + return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class, meterSubType); } } \ No newline at end of file diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java old mode 100644 new mode 100755 index 211186d7..471e4133 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -10,9 +10,11 @@ import org.junit.Assert; import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; @@ -71,4 +73,32 @@ public void testCreateMeterBandSerializerKey() throws Exception { 43L, MeterBandExperimenterCase.class); Assert.assertEquals("Wrong key created", comparationKey, createdKey); } + + @Test + public void testCreateMeterBandSubTypeSerializerKey() throws Exception { + ExperimenterIdSerializerKey createdKey; + ExperimenterIdSerializerKey comparationKey1; + ExperimenterIdSerializerKey comparationKey2; + ExperimenterIdSerializerKey comparationKey3; + ExperimenterIdSerializerKey comparationKey4; + ExperimenterIdSerializerKey comparationKey5; + + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, 43L, ExperimenterMeterBandSubType.class); + comparationKey1 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + 43L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class); + comparationKey2 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 42L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class); + comparationKey3 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, null, ExperimenterMeterBandSubType.class); + comparationKey4 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, MeterBandExperimenterCase.class, null); + comparationKey5 = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, MeterBandExperimenterCase.class, ExperimenterMeterBandSubType.class); + Assert.assertNotEquals("Wrong key created", comparationKey1, createdKey); + Assert.assertNotEquals("Wrong key created", comparationKey2, createdKey); + Assert.assertNotEquals("Wrong key created", comparationKey3, createdKey); + Assert.assertNotEquals("Wrong key created", comparationKey4, createdKey); + Assert.assertEquals("Wrong key created", comparationKey5, createdKey); + } } \ No newline at end of file From ad9cca452440aee4bc393dc4f8b4c848993e5691 Mon Sep 17 00:00:00 2001 From: yunyunhan Date: Tue, 20 Sep 2016 04:05:37 +0800 Subject: [PATCH 247/285] Bug 6744 - the parameters of the function of registerMeterBandSerializer need to be more refined Change-Id: I076906df05b26b407fe7209487b9181dec029d3a Signed-off-by: yunyunhan (cherry picked from commit 5e8b6a2c5218b2ea22343ec889ad7e7fb4112530) --- .../extensibility/SerializerExtensionProvider.java | 12 ++++++++++++ .../impl/core/SwitchConnectionProviderImpl.java | 12 ++++++++++++ .../SwitchConnectionProviderImpl02Test.java | 10 ++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) mode change 100644 => 100755 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java mode change 100644 => 100755 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java mode change 100644 => 100755 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java old mode 100644 new mode 100755 index 13162491..f108b7c8 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; @@ -92,10 +93,21 @@ void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, OFSerializer serializer); + + /** + * Registers meter band serializer (used in meter-mod messages) + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMeterBandSerializer(ExperimenterIdMeterSubTypeSerializerKey key, + OFSerializer serializer); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java old mode 100644 new mode 100755 index bb327361..7ecc39e1 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -25,6 +25,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; @@ -274,11 +275,22 @@ public void registerMultipartRequestTFSerializer(final ExperimenterIdSerializerK } @Override + /** + * @deprecated Since we have used ExperimenterIdMeterSubTypeSerializerKey as MeterBandSerializer's key, in order to avoid + * the occurrence of an error, we should discard this function + */ + @Deprecated public void registerMeterBandSerializer(final ExperimenterIdSerializerKey key, final OFSerializer serializer) { serializerRegistry.registerSerializer(key, serializer); } + @Override + public void registerMeterBandSerializer(final ExperimenterIdMeterSubTypeSerializerKey key, + final OFSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } + @Override public void initiateConnection(final String host, final int port) { connectionInitializer.initiateConnection(host, port); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java old mode 100644 new mode 100755 index 302c3e90..5b9dc17c --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -9,8 +9,6 @@ import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; -import java.net.InetAddress; -import java.net.UnknownHostException; import org.junit.Assert; import org.junit.Test; import org.mockito.Mock; @@ -25,6 +23,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; @@ -48,6 +47,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import java.net.InetAddress; +import java.net.UnknownHostException; + /** * @author madamjak * @author michal.polkorab @@ -228,8 +230,8 @@ public void testUnregisterExistingKeys(){ Assert.assertTrue("Wrong -- unregister MultipartRequestTFSerializer", provider.unregisterSerializer(key14)); Assert.assertFalse("Wrong -- unregister MultipartRequestTFSerializer by not existing key", provider.unregisterSerializer(key14)); // -- registerMeterBandSerializer - final ExperimenterIdSerializerKey key15 - = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MeterBandExperimenterCase.class); + final ExperimenterIdMeterSubTypeSerializerKey key15 + = new ExperimenterIdMeterSubTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,42L,MeterBandExperimenterCase.class,null); provider.registerMeterBandSerializer(key15, serializerMeterBandExpCase); Assert.assertTrue("Wrong -- unregister MeterBandSerializer", provider.unregisterSerializer(key15)); Assert.assertFalse("Wrong -- unregister MeterBandSerializer by not existing key", provider.unregisterSerializer(key15)); From 4de7239667ec58eef9e2759e1501b9d1cf862cdd Mon Sep 17 00:00:00 2001 From: Mohamed El-Serngawy Date: Tue, 4 Oct 2016 16:48:48 -0400 Subject: [PATCH 248/285] Move the Openflow connections blueprint to OpenflowJava project Moving the Openflow connections (defaultSwitchConnProvider and legacySwitchConnProvider) blueprint configuration to OpenflowJava project as its data model config "openflow-switch-connection-provider-impl" exist in OpenflowJava project Change-Id: I21529b5f8e312d4da0d4a76ef0e6bf02a1e551c5 Signed-off-by: Mohamed El-Serngawy --- artifacts/pom.xml | 14 ++++ features/pom.xml | 14 ++++ features/src/main/features/features.xml | 3 + openflowjava-blueprint-config/pom.xml | 66 +++++++++++++++++++ .../default-openflow-connection-config.xml | 17 +++++ .../legacy-openflow-connection-config.xml | 17 +++++ .../opendaylight/blueprint/openflowjava.xml | 34 ++++++++++ pom.xml | 1 + 8 files changed, 166 insertions(+) create mode 100644 openflowjava-blueprint-config/pom.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 5d88c467..a54a33e0 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -42,6 +42,20 @@ test-jar test + + org.opendaylight.openflowjava + openflowjava-blueprint-config + ${project.version} + xml + config + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + ${project.version} + xml + legacyConfig + ${project.groupId} openflow-protocol-spi diff --git a/features/pom.xml b/features/pom.xml index 78c6d669..099cebe7 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -126,6 +126,20 @@ org.opendaylight.openflowjava openflow-protocol-impl + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + config + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + legacyConfig + + org.opendaylight.openflowjava openflowjava-util diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index bd3b359e..63be9313 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -22,6 +22,9 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-util/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig diff --git a/openflowjava-blueprint-config/pom.xml b/openflowjava-blueprint-config/pom.xml new file mode 100644 index 00000000..c3e6c6ca --- /dev/null +++ b/openflowjava-blueprint-config/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + + org.opendaylight.openflowjava + openflowjava-parent + 0.9.0-SNAPSHOT + ../parent + + openflowjava-blueprint-config + Blueprint configuration files for openflowjava statistics + bundle + Openflow Protocol Library - Blueprint Config + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/initial/default-openflow-connection-config.xml + xml + config + + + ${project.build.directory}/classes/initial/legacy-openflow-connection-config.xml + xml + legacyConfig + + + + + + + + + diff --git a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml new file mode 100644 index 00000000..48f8bf55 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml @@ -0,0 +1,17 @@ + + openflow-switch-connection-provider-default-impl + 6633 + TCP + + configuration/ssl/ctl.jks + JKS + PATH + opendaylight + configuration/ssl/truststore.jks + JKS + PATH + opendaylight + opendaylight + + + \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml new file mode 100644 index 00000000..7772ecc8 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml @@ -0,0 +1,17 @@ + + openflow-switch-connection-provider-legacy-impl + 6653 + TCP + + configuration/ssl/ctl.jks + JKS + PATH + opendaylight + configuration/ssl/truststore.jks + JKS + PATH + opendaylight + opendaylight + + + \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml new file mode 100644 index 00000000..2cd5a070 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 05052397..0ed98352 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ artifacts features openflowjava-config + openflowjava-blueprint-config openflow-protocol-api openflow-protocol-impl openflow-protocol-it From 159164138dd0a64af5a3e2b96e1d7de5cad4b139 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Thu, 13 Oct 2016 16:01:30 +0000 Subject: [PATCH 249/285] Revert "Move the Openflow connections blueprint to OpenflowJava project" This reverts commit 4de7239667ec58eef9e2759e1501b9d1cf862cdd. Change-Id: I45a74aa32abb1ac16ab403fb4cac8a39a307b00c Signed-off-by: Michal Polkorab --- artifacts/pom.xml | 14 ---- features/pom.xml | 14 ---- features/src/main/features/features.xml | 3 - openflowjava-blueprint-config/pom.xml | 66 ------------------- .../default-openflow-connection-config.xml | 17 ----- .../legacy-openflow-connection-config.xml | 17 ----- .../opendaylight/blueprint/openflowjava.xml | 34 ---------- pom.xml | 1 - 8 files changed, 166 deletions(-) delete mode 100644 openflowjava-blueprint-config/pom.xml delete mode 100644 openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml delete mode 100644 openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml delete mode 100644 openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a54a33e0..5d88c467 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -42,20 +42,6 @@ test-jar test - - org.opendaylight.openflowjava - openflowjava-blueprint-config - ${project.version} - xml - config - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - ${project.version} - xml - legacyConfig - ${project.groupId} openflow-protocol-spi diff --git a/features/pom.xml b/features/pom.xml index 099cebe7..78c6d669 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -126,20 +126,6 @@ org.opendaylight.openflowjava openflow-protocol-impl - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - config - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - legacyConfig - - org.opendaylight.openflowjava openflowjava-util diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index 63be9313..bd3b359e 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -22,9 +22,6 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-util/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig diff --git a/openflowjava-blueprint-config/pom.xml b/openflowjava-blueprint-config/pom.xml deleted file mode 100644 index c3e6c6ca..00000000 --- a/openflowjava-blueprint-config/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - 4.0.0 - - - org.opendaylight.openflowjava - openflowjava-parent - 0.9.0-SNAPSHOT - ../parent - - openflowjava-blueprint-config - Blueprint configuration files for openflowjava statistics - bundle - Openflow Protocol Library - Blueprint Config - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - - - org.apache.felix - maven-bundle-plugin - true - - - * - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/initial/default-openflow-connection-config.xml - xml - config - - - ${project.build.directory}/classes/initial/legacy-openflow-connection-config.xml - xml - legacyConfig - - - - - - - - - diff --git a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml deleted file mode 100644 index 48f8bf55..00000000 --- a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml +++ /dev/null @@ -1,17 +0,0 @@ - - openflow-switch-connection-provider-default-impl - 6633 - TCP - - configuration/ssl/ctl.jks - JKS - PATH - opendaylight - configuration/ssl/truststore.jks - JKS - PATH - opendaylight - opendaylight - - - \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml deleted file mode 100644 index 7772ecc8..00000000 --- a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml +++ /dev/null @@ -1,17 +0,0 @@ - - openflow-switch-connection-provider-legacy-impl - 6653 - TCP - - configuration/ssl/ctl.jks - JKS - PATH - opendaylight - configuration/ssl/truststore.jks - JKS - PATH - opendaylight - opendaylight - - - \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml deleted file mode 100644 index 2cd5a070..00000000 --- a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0ed98352..05052397 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,6 @@ artifacts features openflowjava-config - openflowjava-blueprint-config openflow-protocol-api openflow-protocol-impl openflow-protocol-it From 70da9ef1c9fd20c0822a1c20b4e64d4f692116fe Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Fri, 14 Oct 2016 10:45:04 +0000 Subject: [PATCH 250/285] Revert "Revert "Move the Openflow connections blueprint to OpenflowJava project"" This reverts commit 159164138dd0a64af5a3e2b96e1d7de5cad4b139. Re-introducing the change Change-Id: I8b9e4bd2220890d173dec7471eaf3a6e8b837721 Signed-off-by: Michal Polkorab --- artifacts/pom.xml | 14 ++++ features/pom.xml | 14 ++++ features/src/main/features/features.xml | 3 + openflowjava-blueprint-config/pom.xml | 66 +++++++++++++++++++ .../default-openflow-connection-config.xml | 17 +++++ .../legacy-openflow-connection-config.xml | 17 +++++ .../opendaylight/blueprint/openflowjava.xml | 34 ++++++++++ pom.xml | 1 + 8 files changed, 166 insertions(+) create mode 100644 openflowjava-blueprint-config/pom.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml create mode 100644 openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 5d88c467..a54a33e0 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -42,6 +42,20 @@ test-jar test + + org.opendaylight.openflowjava + openflowjava-blueprint-config + ${project.version} + xml + config + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + ${project.version} + xml + legacyConfig + ${project.groupId} openflow-protocol-spi diff --git a/features/pom.xml b/features/pom.xml index 78c6d669..099cebe7 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -126,6 +126,20 @@ org.opendaylight.openflowjava openflow-protocol-impl + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + config + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + legacyConfig + + org.opendaylight.openflowjava openflowjava-util diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index bd3b359e..63be9313 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -22,6 +22,9 @@ mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-util/{{VERSION}} + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/{{VERSION}} mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig diff --git a/openflowjava-blueprint-config/pom.xml b/openflowjava-blueprint-config/pom.xml new file mode 100644 index 00000000..c3e6c6ca --- /dev/null +++ b/openflowjava-blueprint-config/pom.xml @@ -0,0 +1,66 @@ + + + + + 4.0.0 + + + org.opendaylight.openflowjava + openflowjava-parent + 0.9.0-SNAPSHOT + ../parent + + openflowjava-blueprint-config + Blueprint configuration files for openflowjava statistics + bundle + Openflow Protocol Library - Blueprint Config + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + + + org.apache.felix + maven-bundle-plugin + true + + + * + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/initial/default-openflow-connection-config.xml + xml + config + + + ${project.build.directory}/classes/initial/legacy-openflow-connection-config.xml + xml + legacyConfig + + + + + + + + + diff --git a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml new file mode 100644 index 00000000..48f8bf55 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml @@ -0,0 +1,17 @@ + + openflow-switch-connection-provider-default-impl + 6633 + TCP + + configuration/ssl/ctl.jks + JKS + PATH + opendaylight + configuration/ssl/truststore.jks + JKS + PATH + opendaylight + opendaylight + + + \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml new file mode 100644 index 00000000..7772ecc8 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml @@ -0,0 +1,17 @@ + + openflow-switch-connection-provider-legacy-impl + 6653 + TCP + + configuration/ssl/ctl.jks + JKS + PATH + opendaylight + configuration/ssl/truststore.jks + JKS + PATH + opendaylight + opendaylight + + + \ No newline at end of file diff --git a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml new file mode 100644 index 00000000..2cd5a070 --- /dev/null +++ b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 05052397..0ed98352 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ artifacts features openflowjava-config + openflowjava-blueprint-config openflow-protocol-api openflow-protocol-impl openflow-protocol-it From edd9ab5008fff039873cb208eeaa7fc64d1a2bd4 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Tue, 4 Oct 2016 17:38:03 +0200 Subject: [PATCH 251/285] Allow any hello mesage and extend hello support for v1.4, v1.5 - accept any (also unsupported version) hello message for handshake and negotiation - added version assignable factory - made HelloFactory version assignable - register deserializers for hello message of v1.4, v 1.5 - update logging - update tests Resolves: Bug 6805, Bug 4255 Change-Id: I228108908ecfb2c3a7f8afa866790b7c193f046c Signed-off-by: Andrej Leitner --- .../protocol/api/keys/MessageCodeKey.java | 8 +++ .../protocol/api/util/EncodeConstants.java | 13 +++- .../impl/core/DelegatingInboundHandler.java | 7 +- .../protocol/impl/core/OFDecoder.java | 14 ++-- .../protocol/impl/core/OFEncoder.java | 4 +- .../protocol/impl/core/OFFrameDecoder.java | 6 +- .../protocol/impl/core/OFVersionDetector.java | 23 +++--- .../impl/core/TcpChannelInitializer.java | 18 ++--- .../core/connection/ChannelOutboundQueue.java | 2 +- .../connection/ConnectionAdapterImpl.java | 23 +++--- .../MessageDeserializerInitializer.java | 25 ++++--- .../TypeToClassMapInitializer.java | 35 +++++---- .../factories/HelloMessageFactory.java | 13 ++-- .../SimpleDeserializerRegistryHelper.java | 19 ++--- .../impl/util/VersionAssignableFactory.java | 36 ++++++++++ .../impl/core/OFVersionDetectorTest.java | 72 +++++-------------- .../TypeToClassMapInitializerTest.java | 14 ++-- .../factories/HelloMessageFactoryTest.java | 55 +++++++------- .../protocol/impl/util/BufferHelper.java | 10 ++- .../util/DefaultDeserializerFactoryTest.java | 50 +++++++++++++ 20 files changed, 268 insertions(+), 179 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/VersionAssignableFactory.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java index 6597c19a..566b3623 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MessageCodeKey.java @@ -28,6 +28,14 @@ public MessageCodeKey(short version, int value, Class clazz) { this.clazz = clazz; } + public int getMsgType() { + return this.msgType; + } + + public Class getClazz() { + return this.clazz; + } + @Override public int hashCode() { final int prime = 31; diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index 82a09282..dad7b76f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -9,7 +9,7 @@ package org.opendaylight.openflowjava.protocol.api.util; /** - * Stores common constants + * Stores common constants. * @author michal.polkorab */ public abstract class EncodeConstants { @@ -20,6 +20,14 @@ public abstract class EncodeConstants { public static final byte OF10_VERSION_ID = 0x01; /** OpenFlow v1.3 wire protocol number */ public static final byte OF13_VERSION_ID = 0x04; + /** OpenFlow v1.4 wire protocol number */ + public static final byte OF14_VERSION_ID = 0x05; + /** OpenFlow v1.5 wire protocol number */ + public static final byte OF15_VERSION_ID = 0x06; + /** OpenFlow Hello message type value */ + public static final byte OF_HELLO_MESSAGE_TYPE_VALUE = 0; + /** OpenFlow PacketIn message type value */ + public static final byte OF_PACKETIN_MESSAGE_TYPE_VALUE = 10; /** Index of length in Openflow header */ public static final int OFHEADER_LENGTH_INDEX = 2; /** Size of Openflow header */ @@ -52,10 +60,9 @@ public abstract class EncodeConstants { /** Common experimenter value */ public static final int EXPERIMENTER_VALUE = 0xFFFF; - /** OF v1.0 maximal port name length */ public static final byte MAX_PORT_NAME_LENGTH = 16; - /** OF v1.3 lenght of experimenter_ids - see Multipart TableFeatures (properties) message */ + /** OF v1.3 length of experimenter_ids - see Multipart TableFeatures (properties) message */ public static final byte EXPERIMENTER_IDS_LENGTH = 8; private EncodeConstants() { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java index a0efc900..b0fee5c3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/DelegatingInboundHandler.java @@ -8,9 +8,9 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import com.google.common.base.Preconditions; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; - import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; @@ -18,8 +18,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; - /** * Holds reference to {@link ConnectionAdapterImpl} and passes messages for further processing. * Also informs on switch disconnection. @@ -28,12 +26,11 @@ public class DelegatingInboundHandler extends ChannelInboundHandlerAdapter { private static final Logger LOG = LoggerFactory.getLogger(DelegatingInboundHandler.class); - private final MessageConsumer consumer; private boolean inactiveMessageSent = false; /** - * Constructs class + creates and sets MessageConsumer + * Constructs class + creates and sets MessageConsumer. * @param connectionAdapter reference for adapter communicating with upper layers outside library */ public DelegatingInboundHandler(final MessageConsumer connectionAdapter) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java index ec1f43d3..90d0ab02 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java @@ -10,9 +10,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; - import java.util.List; - import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; import org.opendaylight.openflowjava.statistics.CounterEventTypes; import org.opendaylight.openflowjava.statistics.StatisticsCounters; @@ -22,7 +20,7 @@ import org.slf4j.LoggerFactory; /** - * Transforms OpenFlow Protocol messages to POJOs + * Transforms OpenFlow Protocol messages to POJOs. * @author michal.polkorab */ public class OFDecoder extends MessageToMessageDecoder { @@ -33,18 +31,14 @@ public class OFDecoder extends MessageToMessageDecoder { // TODO: make this final? private DeserializationFactory deserializationFactory; - /** - * Constructor of class - */ public OFDecoder() { - LOG.trace("Creating OF 1.3 Decoder"); - // TODO: pass as argument + LOG.trace("Creating OFDecoder"); + // TODO: pass as argument statisticsCounter = StatisticsCounters.getInstance(); } @Override - protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, - List out) throws Exception { + protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List out) throws Exception { statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA); if (LOG.isDebugEnabled()) { LOG.debug("VersionMessageWrapper received"); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java index 4c54732b..2f356693 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; /** - * Transforms OpenFlow Protocol messages to POJOs + * Transforms OpenFlow Protocol messages to POJOs. * @author michal.polkorab * @author timotej.kubas */ @@ -34,7 +34,7 @@ public class OFEncoder extends MessageToByteEncoder { /** Constructor of class */ public OFEncoder() { statisticsCounters = StatisticsCounters.getInstance(); - LOG.trace("Creating OF13Encoder"); + LOG.trace("Creating OFEncoder"); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java index 735070fa..a9c5ecd2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java @@ -12,9 +12,7 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; - import java.util.List; - import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.slf4j.Logger; @@ -26,7 +24,7 @@ */ public class OFFrameDecoder extends ByteToMessageDecoder { - /** Length of OpenFlow 1.3 header */ + /** Length of OpenFlow header */ public static final byte LENGTH_OF_HEADER = 8; private static final byte LENGTH_INDEX_IN_HEADER = 2; private static final Logger LOG = LoggerFactory.getLogger(OFFrameDecoder.class); @@ -36,7 +34,7 @@ public class OFFrameDecoder extends ByteToMessageDecoder { /** * Constructor of class. * @param connectionFacade ConnectionFacade that will be notified - * with ConnectionReadyNotification after TLS has been successfully set up. + * with ConnectionReadyNotification after TLS has been successfully set up. * @param tlsPresent true is TLS is required, false otherwise */ public OFFrameDecoder(ConnectionFacade connectionFacade, boolean tlsPresent) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index b635ef25..8e23566a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -11,6 +11,8 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.statistics.CounterEventTypes; @@ -19,23 +21,20 @@ import org.slf4j.LoggerFactory; /** - * Detects version of used OpenFlow Protocol and discards unsupported version messages + * Detects version of used OpenFlow Protocol and discards unsupported version messages. * @author michal.polkorab */ public class OFVersionDetector extends ByteToMessageDecoder { - /** Version number of OpenFlow 1.0 protocol */ - private static final byte OF10_VERSION_ID = EncodeConstants.OF10_VERSION_ID; - /** Version number of OpenFlow 1.3 protocol */ - private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID; - private static final short OF_PACKETIN = 10; private static final Logger LOG = LoggerFactory.getLogger(OFVersionDetector.class); + /** IDs of accepted OpenFlow protocol versions */ + private static final List OF_VERSIONS = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID + )); private final StatisticsCounters statisticsCounters; private volatile boolean filterPacketIns; - /** - * Constructor of class. - */ public OFVersionDetector() { LOG.trace("Creating OFVersionDetector"); statisticsCounters = StatisticsCounters.getInstance(); @@ -54,9 +53,10 @@ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final L } final byte version = in.readByte(); - if (version == OF13_VERSION_ID || version == OF10_VERSION_ID) { + final short messageType = in.getUnsignedByte(in.readerIndex()); + if (messageType == EncodeConstants.OF_HELLO_MESSAGE_TYPE_VALUE || OF_VERSIONS.contains(version)) { LOG.debug("detected version: {}", version); - if (!filterPacketIns || OF_PACKETIN != in.getUnsignedByte(in.readerIndex())) { + if (!filterPacketIns || EncodeConstants.OF_PACKETIN_MESSAGE_TYPE_VALUE != messageType) { ByteBuf messageBuffer = in.slice(); out.add(new VersionMessageWrapper(version, messageBuffer)); messageBuffer.retain(); @@ -69,4 +69,5 @@ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final L } in.skipBytes(in.readableBytes()); } + } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java index 376978d1..9540eeed 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java @@ -26,26 +26,24 @@ import org.slf4j.LoggerFactory; /** - * Initializes TCP / TLS channel + * Initializes TCP / TLS channel. * @author michal.polkorab */ public class TcpChannelInitializer extends ProtocolChannelInitializer { - private static final Logger LOG = LoggerFactory - .getLogger(TcpChannelInitializer.class); + private static final Logger LOG = LoggerFactory.getLogger(TcpChannelInitializer.class); private final DefaultChannelGroup allChannels; private final ConnectionAdapterFactory connectionAdapterFactory; /** - * default ctor + * Default constructor. */ public TcpChannelInitializer() { this( new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl() ); } /** - * Testing Constructor - * + * Testing constructor. */ protected TcpChannelInitializer( final DefaultChannelGroup channelGroup, final ConnectionAdapterFactory connAdaptorFactory ) { allChannels = channelGroup ; @@ -72,10 +70,11 @@ protected void initChannel(final SocketChannel ch) { ConnectionFacade connectionFacade = null; connectionFacade = connectionAdapterFactory.createConnectionFacade(ch, null, useBarrier()); try { - LOG.debug("calling plugin: {}", getSwitchConnectionHandler()); + LOG.debug("Calling OF plugin: {}", getSwitchConnectionHandler()); getSwitchConnectionHandler().onSwitchConnected(connectionFacade); connectionFacade.checkListeners(); - ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); + ch.pipeline().addLast(PipelineHandlers.IDLE_HANDLER.name(), + new IdleHandler(getSwitchIdleTimeout(), TimeUnit.MILLISECONDS)); boolean tlsPresent = false; // If this channel is configured to support SSL it will only support SSL @@ -112,7 +111,8 @@ public void operationComplete(final Future future) throws Excep final OFEncoder ofEncoder = new OFEncoder(); ofEncoder.setSerializationFactory(getSerializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofEncoder); - ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), new DelegatingInboundHandler(connectionFacade)); + ch.pipeline().addLast(PipelineHandlers.DELEGATING_INBOUND_HANDLER.name(), + new DelegatingInboundHandler(connectionFacade)); if (!tlsPresent) { connectionFacade.fireConnectionReadyNotification(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java index a3ce3d5e..5845dff8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java @@ -145,7 +145,7 @@ private void scheduleFlush(final EventExecutor executor) { */ private void conditionalFlush() { if (queue.isEmpty()) { - LOG.trace("Queue is empty, not flush needed"); + LOG.trace("Queue is empty, flush not needed"); return; } if (!channel.isWritable()) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 7c10be16..8d9c8746 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; /** - * Handles messages (notifications + rpcs) and connections + * Handles messages (notifications + rpcs) and connections. * @author mirehak * @author michal.polkorab */ @@ -53,11 +53,10 @@ public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics i private final boolean useBarrier; /** - * default ctor - * + * Default constructor. * @param channel the channel to be set - used for communication * @param address client address (used only in case of UDP communication, - * as there is no need to store address over tcp (stable channel)) + * as there is no need to store address over tcp (stable channel)) * @param useBarrier value is configurable by configSubsytem */ public ConnectionAdapterImpl(final Channel channel, final InetSocketAddress address, final boolean useBarrier) { @@ -84,7 +83,7 @@ public void setSystemListener(final SystemNotificationsListener systemListener) @Override public void consumeDeviceMessage(final DataObject message) { LOG.debug("ConsumeIntern msg on {}", channel); - if (disconnectOccured ) { + if (disconnectOccured) { return; } if (message instanceof Notification) { @@ -96,7 +95,7 @@ public void consumeDeviceMessage(final DataObject message) { disconnectOccured = true; } else if (message instanceof SwitchIdleEvent) { systemListener.onSwitchIdleEvent((SwitchIdleEvent) message); - // OpenFlow messages + // OpenFlow messages } else if (message instanceof EchoRequestMessage) { if (outputManager != null) { outputManager.onEchoRequest((EchoRequestMessage) message); @@ -116,7 +115,7 @@ public void consumeDeviceMessage(final DataObject message) { } else if (message instanceof FlowRemovedMessage) { messageListener.onFlowRemovedMessage((FlowRemovedMessage) message); } else if (message instanceof HelloMessage) { - LOG.info("Hello received / branch"); + LOG.info("Hello received"); messageListener.onHelloMessage((HelloMessage) message); } else if (message instanceof MultipartReplyMessage) { if (outputManager != null) { @@ -131,15 +130,15 @@ public void consumeDeviceMessage(final DataObject message) { LOG.warn("message listening not supported for type: {}", message.getClass()); } } else if (message instanceof OfHeader) { - LOG.debug("OFheader msg received"); + LOG.debug("OF header msg received"); if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { final RpcResponseKey key = createRpcResponseKey((OfHeader) message); final ResponseExpectedRpcListener listener = findRpcResponse(key); if (listener != null) { - LOG.debug("corresponding rpcFuture found"); + LOG.debug("Corresponding rpcFuture found"); listener.completed((OfHeader)message); - LOG.debug("after setting rpcFuture"); + LOG.debug("After setting rpcFuture"); responseCache.invalidate(key); } else { LOG.warn("received unexpected rpc response: {}", key); @@ -150,10 +149,6 @@ public void consumeDeviceMessage(final DataObject message) { } } - /** - * @param message - * @return - */ private static RpcResponseKey createRpcResponseKey(final OfHeader message) { return new RpcResponseKey(message.getXid(), message.getImplementedInterface().getName()); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 0e672024..3fd8508f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -55,8 +55,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; /** + * Util class for init registration of deserializers. * @author michal.polkorab - * */ public final class MessageDeserializerInitializer { @@ -65,15 +65,14 @@ private MessageDeserializerInitializer() { } /** - * Registers message deserializers - * - * @param registry - * registry to be filled with deserializers + * Registers message deserializers. + * @param registry registry to be filled with deserializers */ - public static void registerMessageDeserializers(DeserializerRegistry registry) { + public static void registerMessageDeserializers(final DeserializerRegistry registry) { + SimpleDeserializerRegistryHelper helper; + // register OF v1.0 message deserializers - SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, - registry); + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); @@ -88,7 +87,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); - // register Of v1.3 message deserializers + // register OF v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); @@ -105,5 +104,13 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + + // register OF v1.4 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + + // register OF v1.5 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 97ae5364..0d603cd2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -43,9 +43,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** + * Util class for init OF message type to class mapping. * @author michal.polkorab * @author giuseppex.petralia@intel.com - * */ public final class TypeToClassMapInitializer { @@ -54,13 +54,14 @@ private TypeToClassMapInitializer() { } /** - * Initializes type to class map - * - * @param messageClassMap + * Initializes standard types mapping. + * @param messageClassMap type to class map */ - public static void initializeTypeToClassMap(Map> messageClassMap) { + public static void initializeTypeToClassMap(final Map> messageClassMap) { + TypeToClassInitHelper helper; + // init OF v1.0 mapping - TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 1, ErrorMessage.class); helper.registerTypeToClass((short) 2, EchoRequestMessage.class); @@ -74,6 +75,7 @@ public static void initializeTypeToClassMap(Map> messag helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); helper.registerTypeToClass((short) 19, BarrierOutput.class); helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); + // init OF v1.3 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); @@ -91,17 +93,25 @@ public static void initializeTypeToClassMap(Map> messag helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class); helper.registerTypeToClass((short) 25, RoleRequestOutput.class); helper.registerTypeToClass((short) 27, GetAsyncOutput.class); + + // init OF v1.4 mapping + helper = new TypeToClassInitHelper(EncodeConstants.OF14_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); + + // init OF v1.5 mapping + helper = new TypeToClassInitHelper(EncodeConstants.OF15_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); } /** - * Initializes type to class map to associate OF code to Java Class for - * messages for additional deserializers. - * - * @param messageClassMap + * Initializes additional types mapping. + * @param messageClassMap type to class map */ - public static void initializeAdditionalTypeToClassMap(Map> messageClassMap) { + public static void initializeAdditionalTypeToClassMap(final Map> messageClassMap) { + TypeToClassInitHelper helper; + // init OF v1.0 mapping - TypeToClassInitHelper helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + helper = new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 5, GetFeaturesInput.class); helper.registerTypeToClass((short) 7, GetConfigInput.class); helper.registerTypeToClass((short) 9, SetConfigInput.class); @@ -111,6 +121,7 @@ public static void initializeAdditionalTypeToClassMap(Map { +public class HelloMessageFactory extends VersionAssignableFactory implements OFDeserializer { private static final byte HELLO_ELEMENT_HEADER_SIZE = 4; + @Override public HelloMessage deserialize(ByteBuf rawMessage) { HelloMessageBuilder builder = new HelloMessageBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); if (rawMessage.readableBytes() > 0) { builder.setElements(readElement(rawMessage)); @@ -70,7 +71,7 @@ private static List readVersionBitmap(int[] input){ for (int i = 0; i < input.length; i++) { int mask = input[i]; for (int j = 0; j < Integer.SIZE; j++) { - versionBitmapList.add((mask & (1< deserializedObjectClass, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new MessageCodeKey(version, code, - deserializedObjectClass), deserializer); + public void registerDeserializer(final int code, final Long experimenterID, final Class deserializedObjectClass, + final OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new MessageCodeKey(version, code, deserializedObjectClass), deserializer); + + if (deserializer instanceof VersionAssignableFactory) { + ((VersionAssignableFactory) deserializer).assignVersion(version); + } } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/VersionAssignableFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/VersionAssignableFactory.java new file mode 100644 index 00000000..d10f8fa6 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/VersionAssignableFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import javax.annotation.Nonnull; + +/** + * Abstract factory class to support OF protocol version assigning and reading. + */ +public abstract class VersionAssignableFactory { + private Short version; + + /** + * @param version OpenFlow protocol version + */ + public void assignVersion(@Nonnull final Short version) { + if (this.version == null) { + this.version = version; + } else { + throw new IllegalStateException("Version already assigned: " + this.version); + } + } + + /** + * @return OpenFlow protocol version + */ + protected Short getVersion() { + return this.version; + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java index 8cf3f75f..7b3d814a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetectorTest.java @@ -8,14 +8,13 @@ package org.opendaylight.openflowjava.protocol.impl.core; +import static org.junit.Assert.assertEquals; + import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; - import java.util.ArrayList; import java.util.List; - import org.junit.Assert; -import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,8 +23,7 @@ import org.opendaylight.openflowjava.util.ByteBufUtils; /** - * - * @author michal.polkorab + * Test for {@link org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector}. */ @RunWith(MockitoJUnitRunner.class) public class OFVersionDetectorTest { @@ -36,74 +34,40 @@ public class OFVersionDetectorTest { private OFVersionDetector detector; private List list = new ArrayList<>(); - /** - * Sets up test environment - */ @Before public void setUp() { list.clear(); detector = new OFVersionDetector(); } - /** - * Test of decode - * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) - * } - * - * @throws Exception - */ @Test - public void testDecode13ProtocolMessage() throws Exception { - detector.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"), - list); - - Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)) - .getMessageBuffer().readableBytes()); + public void testDecode13ProtocolMessage() { + detector.decode(channelHandlerContext, ByteBufUtils.hexStringToByteBuf("04 00 00 08 00 00 00 01"), list); + Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)).getMessageBuffer().readableBytes()); } - /** - * Test of decode - * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) - * } - * @throws Exception - */ @Test - public void testDecode10ProtocolMessage() throws Exception { - detector.decode(channelHandlerContext, - ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01"), - list); - - Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)) - .getMessageBuffer().readableBytes()); + public void testDecode10ProtocolMessage() { + detector.decode(channelHandlerContext, ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01"), list); + Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)).getMessageBuffer().readableBytes()); } - /** - * Test of decode - * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) - * } - * @throws Exception - */ @Test - public void testDecodeEmptyProtocolMessage() throws Exception { + public void testDecodeEmptyProtocolMessage() { ByteBuf byteBuffer = ByteBufUtils.hexStringToByteBuf("01 00 00 08 00 00 00 01").skipBytes(8); detector.decode(channelHandlerContext, byteBuffer, list); - - assertEquals( 0, byteBuffer.refCnt() ) ; + assertEquals(0, byteBuffer.refCnt()); } - /** - * Test of decode - * {@link OFVersionDetector#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List) - * } - * - * @throws Exception - */ @Test - public void testDecodeNotSupportedVersionProtocolMessage() throws Exception { - detector.decode(channelHandlerContext, ByteBufUtils.hexStringToByteBuf("02 00 00 08 00 00 00 01"), list); - + public void testDecodeNotSupportedVersionProtocolMessage() { + detector.decode(channelHandlerContext, ByteBufUtils.hexStringToByteBuf("02 01 00 08 00 00 00 01"), list); Assert.assertEquals("List is not empty", 0, list.size()); } + @Test + public void testDecodeHelloProtocolMessage() { + detector.decode(channelHandlerContext, ByteBufUtils.hexStringToByteBuf("05 00 00 08 00 00 00 01"), list); + Assert.assertEquals(7, ((VersionMessageWrapper) list.get(0)).getMessageBuffer().readableBytes()); + } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index cef8daa7..622b33ce 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -47,21 +47,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.TypeToClassMapInitializer}. * @author michal.polkorab * @author giuseppex.petralia@intel.com - * */ public class TypeToClassMapInitializerTest { private Map> messageClassMap; - /** - * Tests correct map initialization - */ @Test public void test() { messageClassMap = new HashMap<>(); TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); @@ -76,6 +74,7 @@ public void test() { assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + version = EncodeConstants.OF13_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); @@ -92,12 +91,19 @@ public void test() { assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); + + version = EncodeConstants.OF14_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + + version = EncodeConstants.OF15_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); } @Test public void testAdditionalTypes() { messageClassMap = new HashMap<>(); TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; assertEquals("Wrong class", GetFeaturesInput.class, messageClassMap.get(new TypeToClassKey(version, 5))); assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index 7dab76e2..d4ec69d4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -9,46 +9,54 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import java.util.Arrays; import java.util.List; - import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory}. * @author michal.polkorab * @author timotej.kubas * @author madamjak */ -public class HelloMessageFactoryTest { +public class HelloMessageFactoryTest extends DefaultDeserializerFactoryTest { - private OFDeserializer helloFactory; + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public HelloMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0, HelloMessage.class)); + } /** - * Initializes deserializer registry and lookups correct deserializer + * Testing {@link HelloMessageFactory} for correct header version. */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - helloFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0, HelloMessage.class)); + @Test + public void testVersion() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); + ByteBuf bb = BufferHelper.buildBuffer("00 01 " // type + + "00 08 " // length + + "00 00 00 11" // bitmap 1 + ); + testHeaderVersions(versions, bb); } /** - * Testing {@link HelloMessageFactory} for correct length without padding + * Testing {@link HelloMessageFactory} for correct length without padding. */ @Test public void testWithoutPadding() { @@ -56,15 +64,14 @@ public void testWithoutPadding() { + "00 08 " // length + "00 00 00 11" // bitmap 1 ); - HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); - BufferHelper.checkHeaderV13(builtByFactory); + HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); List element = createElement(4,HelloElementType.VERSIONBITMAP.getIntValue()); Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); } /** - * Testing {@link HelloMessageFactory} for correct length with padding + * Testing {@link HelloMessageFactory} for correct length with padding. */ @Test public void testWithPadding() { @@ -74,15 +81,14 @@ public void testWithPadding() { + "00 00 00 00 " // bitmap 2 + "00 00 00 00" // padding ); - HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); - BufferHelper.checkHeaderV13(builtByFactory); + HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); List element = createElement(8,HelloElementType.VERSIONBITMAP.getIntValue()); Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType()); Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap()); } /** - * Testing {@link HelloMessageFactory} if incorrect version is set + * Testing {@link HelloMessageFactory} if incorrect version is set. */ @Test public void testBadType(){ @@ -92,8 +98,7 @@ public void testBadType(){ + "00 00 00 00 " // bitmap 2 + "00 00 00 00" // padding ); - HelloMessage builtByFactory = BufferHelper.deserialize(helloFactory, bb); - BufferHelper.checkHeaderV13(builtByFactory); + HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb); Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.getElements().size()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java index dcdbec18..29d0da2f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/BufferHelper.java @@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; /** @@ -107,7 +108,12 @@ public static void checkHeaderV10(OfHeader ofHeader) { checkHeader(ofHeader, (short) EncodeConstants.OF10_VERSION_ID); } - private static void checkHeader(OfHeader ofHeader, Short version) { + /** + * Check version and xid of OFP header. + * @param ofHeader OpenFlow protocol header + * @param version OpenFlow protocol version + */ + public static void checkHeader(OfHeader ofHeader, Short version) { Assert.assertEquals("Wrong version", version, ofHeader.getVersion()); Assert.assertEquals("Wrong Xid", DEFAULT_XID, ofHeader.getXid()); } @@ -134,7 +140,7 @@ public static void setupHeader(Object builder, int version) throws NoSuchMethodE * @param bb data input buffer * @return message decoded pojo */ - public static E deserialize(OFDeserializer decoder, ByteBuf bb) { + public static E deserialize(OFDeserializer decoder, ByteBuf bb) { return decoder.deserialize(bb); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java new file mode 100644 index 00000000..2d424cde --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * Super class for common stuff of deserialization factories tests. + */ +public abstract class DefaultDeserializerFactoryTest { + + private DeserializerRegistry registry; + protected OFDeserializer factory; + private MessageCodeKey messageCodeKey; + + public DefaultDeserializerFactoryTest(final MessageCodeKey key) { + this.registry = new DeserializerRegistryImpl(); + this.registry.init(); + this.messageCodeKey = key; + this.factory = registry.getDeserializer(key); + } + + /** + * Test correct version after deserialization for all supported OF versions. + * @param versions supported OF versions + * @param buffer byte buffer to deserialze + */ + protected void testHeaderVersions(final List versions, final ByteBuf buffer) { + for (short version : versions) { + ByteBuf bb = buffer.copy(); + OFDeserializer factory = registry.getDeserializer( + new MessageCodeKey(version, messageCodeKey.getMsgType(), messageCodeKey.getClazz())); + T builtByFactory = BufferHelper.deserialize(factory, bb); + BufferHelper.checkHeader((OfHeader) builtByFactory, version); + } + } +} From 8944765e48f546cb46f3faf50795d90f44a89617 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Thu, 6 Oct 2016 15:37:06 +0200 Subject: [PATCH 252/285] Change EchoReq/Res factories to version assignable - made EchoRequest/EchoReply factories version assignable - removed OF10 factories duplicates - registered new deserializers - update tests Resolves: Bug 4255 Change-Id: Ic3e67c4e4db7f1fedcdfc125784219d42a59054c Signed-off-by: Andrej Leitner --- .../MessageDeserializerInitializer.java | 10 +-- .../TypeToClassMapInitializer.java | 4 ++ .../factories/EchoReplyMessageFactory.java | 10 +-- .../factories/EchoRequestMessageFactory.java | 10 +-- .../OF10EchoReplyMessageFactory.java | 39 ----------- .../OF10EchoRequestMessageFactory.java | 35 ---------- .../TypeToClassMapInitializerTest.java | 4 ++ .../EchoReplyMessageFactoryTest.java | 54 ++++++++------- .../EchoRequestMessageFactoryTest.java | 54 ++++++++------- .../OF10EchoReplyMessageFactoryTest.java | 66 ------------------- .../OF10EchoRequestMessageFactoryTest.java | 66 ------------------- 11 files changed, 85 insertions(+), 267 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 3fd8508f..8b0975a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -21,8 +21,6 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory; @@ -75,8 +73,8 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); helper.registerDeserializer(4, null, ExperimenterMessage.class, new VendorMessageFactory()); helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); @@ -108,9 +106,13 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis // register OF v1.4 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 0d603cd2..d65fd337 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -97,10 +97,14 @@ public static void initializeTypeToClassMap(final Map> // init OF v1.4 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF14_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); // init OF v1.5 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF15_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); } /** diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java index 5d3ecde7..217071fb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java @@ -9,23 +9,23 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder; /** - * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3) + * Translates EchoReply messages. + * OpenFlow protocol versions: 1.0, 1.3, 1.4, 1.5. * @author michal.polkorab * @author timotej.kubas */ -public class EchoReplyMessageFactory implements OFDeserializer { +public class EchoReplyMessageFactory extends VersionAssignableFactory implements OFDeserializer { @Override public EchoOutput deserialize(ByteBuf rawMessage) { EchoOutputBuilder builder = new EchoOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java index 446faf14..a765a2d3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java @@ -9,23 +9,23 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; /** - * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3) + * Translates EchoRequest messages. + * OpenFlow protocol versions: 1.0, 1.3, 1.4, 1.5. * @author michal.polkorab * @author timotej.kubas */ -public class EchoRequestMessageFactory implements OFDeserializer{ +public class EchoRequestMessageFactory extends VersionAssignableFactory implements OFDeserializer{ @Override public EchoRequestMessage deserialize(ByteBuf rawMessage) { EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); byte[] data = new byte[rawMessage.readableBytes()]; rawMessage.readBytes(data); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java deleted file mode 100644 index 107faa5a..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutputBuilder; - -/** - * Translates EchoReply messages (both OpenFlow v1.0 and OpenFlow v1.3) - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10EchoReplyMessageFactory implements OFDeserializer { - - @Override - public EchoOutput deserialize(ByteBuf rawMessage) { - EchoOutputBuilder builder = new EchoOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - int remainingBytes = rawMessage.readableBytes(); - if (remainingBytes > 0) { - byte[] data = new byte[remainingBytes]; - rawMessage.readBytes(data); - builder.setData(data); - } - return builder.build(); - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java deleted file mode 100644 index a90044ca..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; - -/** - * Translates EchoRequest messages (both OpenFlow v1.0 and OpenFlow v1.3) - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10EchoRequestMessageFactory implements OFDeserializer{ - - @Override - public EchoRequestMessage deserialize(ByteBuf rawMessage) { - EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - byte[] data = new byte[rawMessage.readableBytes()]; - rawMessage.readBytes(data); - builder.setData(data); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index 622b33ce..de5a03e9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -94,9 +94,13 @@ public void test() { version = EncodeConstants.OF14_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); version = EncodeConstants.OF15_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); } @Test diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java index 438ac186..8ec42cb1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactoryTest.java @@ -9,58 +9,64 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory}. * @author michal.polkorab * @author timotej.kubas */ -public class EchoReplyMessageFactoryTest { +public class EchoReplyMessageFactoryTest extends DefaultDeserializerFactoryTest { - private OFDeserializer echoFactory; + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public EchoReplyMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 3, EchoOutput.class)); + } /** - * Initializes deserializer registry and lookups correct deserializer + * Testing {@link EchoReplyMessageFactory} for correct header version. */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - echoFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 3, EchoOutput.class)); + @Test + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); + ByteBuf bb = BufferHelper.buildBuffer(); + testHeaderVersions(versions, bb); } /** - * Testing {@link EchoReplyMessageFactory} for correct translation into POJO + * Testing {@link EchoReplyMessageFactory} for correct translation into POJO. */ @Test public void testWithEmptyDataField() { ByteBuf bb = BufferHelper.buildBuffer(); - EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); + EchoOutput builtByFactory = BufferHelper.deserialize(factory, bb); + Assert.assertArrayEquals("Wrong data", null, builtByFactory.getData()); } /** - * Testing {@link EchoReplyMessageFactory} for correct translation into POJO + * Testing {@link EchoReplyMessageFactory} for correct translation into POJO. */ @Test public void testWithDataFieldSet() { byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; ByteBuf bb = BufferHelper.buildBuffer(data); - EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); + EchoOutput builtByFactory = BufferHelper.deserialize(factory, bb); Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java index 376d4dfd..fb8fc490 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactoryTest.java @@ -9,58 +9,66 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory}. * @author michal.polkorab * @author timotej.kubas */ -public class EchoRequestMessageFactoryTest { +public class EchoRequestMessageFactoryTest extends DefaultDeserializerFactoryTest { - private OFDeserializer echoFactory; + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public EchoRequestMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 2, EchoRequestMessage.class)); + } /** - * Initializes deserializer registry and lookups correct deserializer + * Testing {@link EchoRequestMessageFactory} for correct header version. */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - echoFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 2, EchoRequestMessage.class)); + @Test + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); + ByteBuf bb = BufferHelper.buildBuffer(); + testHeaderVersions(versions, bb); } /** - * Testing {@link EchoRequestMessageFactory} for correct translation into POJO + * Testing {@link EchoRequestMessageFactory} for correct translation into POJO. */ @Test public void testWithEmptyDataField() { + byte[] data = new byte[]{}; ByteBuf bb = BufferHelper.buildBuffer(); - EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb); + EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb); + Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); - BufferHelper.checkHeaderV13(builtByFactory); } /** - * Testing {@link EchoRequestMessageFactory} for correct translation into POJO + * Testing {@link EchoRequestMessageFactory} for correct translation into POJO. */ @Test public void testWithDataFieldSet() { byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; ByteBuf bb = BufferHelper.buildBuffer(data); - EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); + EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb); Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); } -} +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java deleted file mode 100644 index 3da76971..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoReplyMessageFactoryTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10EchoReplyMessageFactoryTest { - - private OFDeserializer echoFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - echoFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 3, EchoOutput.class)); - } - - /** - * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testWithEmptyDataFieldV10() { - ByteBuf bb = BufferHelper.buildBuffer(); - EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - } - - /** - * Testing {@link OF10EchoReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testWithDataFieldSetV10() { - byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; - ByteBuf bb = BufferHelper.buildBuffer(data); - EchoOutput builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java deleted file mode 100644 index 12113a37..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10EchoRequestMessageFactoryTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10EchoRequestMessageFactoryTest { - - private OFDeserializer echoFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - echoFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 2, EchoRequestMessage.class)); - } - - /** - * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO - */ - @Test - public void testWithEmptyDataFieldV10() { - ByteBuf bb = BufferHelper.buildBuffer(); - EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - } - - /** - * Testing {@link OF10EchoReplyMessageFactoryTest} for correct translation into POJO - */ - @Test - public void testWithDataFieldSetV10() { - byte[] data = new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; - ByteBuf bb = BufferHelper.buildBuffer(data); - EchoRequestMessage builtByFactory = BufferHelper.deserialize(echoFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData()); - } -} From 6052bb78a89a3efcd13bd0acc05d0e5f6e2fcf9b Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Fri, 7 Oct 2016 16:57:49 +0200 Subject: [PATCH 253/285] Change GetConfigReq/Res and SetConfig factories to version assignable - made SetConfig, GetConfigRequest and GetConfigReply factories version assignable - removed OF10 factories duplicates - registered new deserializers - update tests Resolves: Bug 4255 Change-Id: Ib4809c58d62aa4608d88894d01c6d107d2fff90c Signed-off-by: Andrej Leitner --- ...itionalMessageDeserializerInitializer.java | 22 +++++--- .../MessageDeserializerInitializer.java | 5 +- .../TypeToClassMapInitializer.java | 12 ++++ .../GetConfigInputMessageFactory.java | 8 ++- .../GetConfigReplyMessageFactory.java | 8 ++- .../OF10GetConfigInputMessageFactory.java | 29 ---------- .../OF10GetConfigReplyMessageFactory.java | 35 ------------ .../OF10SetConfigMessageFactory.java | 32 ----------- .../SetConfigInputMessageFactory.java | 8 ++- .../TypeToClassMapInitializerTest.java | 10 ++++ .../GetConfigInputMessageFactoryTest.java | 38 +++++++------ .../GetConfigReplyMessageFactoryTest.java | 45 ++++++++------- .../OF10GetConfigInputMessageFactoryTest.java | 42 -------------- .../OF10GetConfigReplyMessageFactoryTest.java | 56 ------------------- .../OF10SetConfigMessageFactoryTest.java | 45 --------------- ... => SetConfigInputMessageFactoryTest.java} | 40 ++++++++----- 16 files changed, 128 insertions(+), 307 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java rename openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/{SetConfigMessageFactoryTest.java => SetConfigInputMessageFactoryTest.java} (54%) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java index adbec25c..3dfc9882 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java @@ -21,11 +21,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesRequestMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetQueueConfigInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketOutInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortModInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10SetConfigMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsRequestInputFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketOutInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PortModInputMessageFactory; @@ -61,9 +59,7 @@ private AdditionalMessageDeserializerInitializer() { /** * Registers additional message deserializers. - * - * @param registry - * registry to be filled with deserializers + * @param registry registry to be filled with deserializers */ public static void registerMessageDeserializers(DeserializerRegistry registry) { @@ -72,8 +68,8 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { // register OF v1.0 message deserializers helper.registerDeserializer(5, null, GetFeaturesInput.class, new OF10FeaturesRequestMessageFactory()); - helper.registerDeserializer(7, null, GetConfigInput.class, new OF10GetConfigInputMessageFactory()); - helper.registerDeserializer(9, null, SetConfigInput.class, new OF10SetConfigMessageFactory()); + helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); helper.registerDeserializer(13, null, PacketOutInput.class, new OF10PacketOutInputMessageFactory()); helper.registerDeserializer(14, null, FlowModInput.class, new OF10FlowModInputMessageFactory()); helper.registerDeserializer(15, null, PortModInput.class, new OF10PortModInputMessageFactory()); @@ -81,7 +77,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(18, null, BarrierInput.class, new OF10BarrierInputMessageFactory()); helper.registerDeserializer(20, null, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory()); - // register Of v1.3 message deserializers + // register OF v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); helper.registerDeserializer(5, null, GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); @@ -98,6 +94,16 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(26, null, GetAsyncInput.class, new GetAsyncRequestMessageFactory()); helper.registerDeserializer(28, null, SetAsyncInput.class, new SetAsyncInputMessageFactory()); helper.registerDeserializer(29, null, MeterModInput.class, new MeterModInputMessageFactory()); + + // register OF v1.4 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); + helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); + + // register OF v1.5 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); + helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 8b0975a0..d924bc1f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -24,7 +24,6 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetConfigReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10HelloMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PacketInMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory; @@ -77,7 +76,7 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); helper.registerDeserializer(4, null, ExperimenterMessage.class, new VendorMessageFactory()); helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); @@ -108,11 +107,13 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index d65fd337..d8ca8c8a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -99,12 +99,14 @@ public static void initializeTypeToClassMap(final Map> helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 2, EchoRequestMessage.class); helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); // init OF v1.5 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF15_VERSION_ID, messageClassMap); helper.registerTypeToClass((short) 0, HelloMessage.class); helper.registerTypeToClass((short) 2, EchoRequestMessage.class); helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); } /** @@ -143,5 +145,15 @@ public static void initializeAdditionalTypeToClassMap(final Map { +public class GetConfigInputMessageFactory extends VersionAssignableFactory implements OFDeserializer { @Override public GetConfigInput deserialize(ByteBuf rawMessage) { GetConfigInputBuilder builder = new GetConfigInputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java index dc6e11a0..98fc2c99 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java @@ -12,21 +12,23 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder; /** - * Translates GetConfigReply messages (both OpenFlow v1.0 and OpenFlow v1.3) + * Translates GetConfigReply messages. + * OF protocol versions: 1.0, 1.3, 1.4, 1.5. * @author michal.polkorab * @author timotej.kubas */ -public class GetConfigReplyMessageFactory implements OFDeserializer { +public class GetConfigReplyMessageFactory extends VersionAssignableFactory implements OFDeserializer { @Override public GetConfigOutput deserialize(ByteBuf rawMessage) { GetConfigOutputBuilder builder = new GetConfigOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); builder.setMissSendLen(rawMessage.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java deleted file mode 100644 index d46dcac1..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10GetConfigInputMessageFactory implements OFDeserializer { - - @Override - public GetConfigInput deserialize(ByteBuf rawMessage) { - GetConfigInputBuilder builder = new GetConfigInputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java deleted file mode 100644 index 4c247c6a..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutputBuilder; - -/** - * Translates GetConfigReply messages (both OpenFlow v1.0 and OpenFlow v1.3) - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10GetConfigReplyMessageFactory implements OFDeserializer { - - @Override - public GetConfigOutput deserialize(ByteBuf rawMessage) { - GetConfigOutputBuilder builder = new GetConfigOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); - builder.setMissSendLen(rawMessage.readUnsignedShort()); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java deleted file mode 100644 index 23c4de21..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10SetConfigMessageFactory implements OFDeserializer { - - @Override - public SetConfigInput deserialize(ByteBuf rawMessage) { - SetConfigInputBuilder builder = new SetConfigInputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); - builder.setMissSendLen(rawMessage.readUnsignedShort()); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java index a0a8e36b..52e80b71 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java @@ -10,20 +10,22 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder; /** + * Translates SetConfig messages. + * OF protocol versions: 1.0, 1.3, 1.4, 1.5. * @author giuseppex.petralia@intel.com - * */ -public class SetConfigInputMessageFactory implements OFDeserializer { +public class SetConfigInputMessageFactory extends VersionAssignableFactory implements OFDeserializer { @Override public SetConfigInput deserialize(ByteBuf rawMessage) { SetConfigInputBuilder builder = new SetConfigInputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); builder.setMissSendLen(rawMessage.readUnsignedShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index de5a03e9..513bc29a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -96,11 +96,13 @@ public void test() { assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); version = EncodeConstants.OF15_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); } @Test @@ -135,6 +137,14 @@ public void testAdditionalTypes() { assertEquals("Wrong class", GetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 26))); assertEquals("Wrong class", SetAsyncInput.class, messageClassMap.get(new TypeToClassKey(version, 28))); assertEquals("Wrong class", MeterModInput.class, messageClassMap.get(new TypeToClassKey(version, 29))); + + version = EncodeConstants.OF14_VERSION_ID; + assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); + assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); + + version = EncodeConstants.OF15_VERSION_ID; + assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); + assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java index a2c9085a..9f2eb6ab 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactoryTest.java @@ -8,35 +8,41 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import org.junit.Before; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigInputMessageFactory}. * @author giuseppex.petralia@intel.com - * */ -public class GetConfigInputMessageFactoryTest { - private OFDeserializer factory; +public class GetConfigInputMessageFactoryTest extends DefaultDeserializerFactoryTest { - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 7, GetConfigInput.class)); + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public GetConfigInputMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 7, GetConfigInput.class)); } + /** + * Testing {@link GetConfigInputMessageFactory} for correct header version. + */ @Test - public void test() { + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); ByteBuf bb = BufferHelper.buildBuffer(); - GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV13(deserializedMessage); + testHeaderVersions(versions, bb); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java index 0d48e66d..be3d4faa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactoryTest.java @@ -9,46 +9,53 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory}. * @author michal.polkorab * @author timotej.kubas */ -public class GetConfigReplyMessageFactoryTest { +public class GetConfigReplyMessageFactoryTest extends DefaultDeserializerFactoryTest { - private OFDeserializer configFactory; + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public GetConfigReplyMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 8, GetConfigOutput.class)); + } /** - * Initializes deserializer registry and lookups correct deserializer + * Testing {@link GetConfigReplyMessageFactory} for correct header version. */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - configFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 8, GetConfigOutput.class)); + @Test + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03"); + testHeaderVersions(versions, bb); } /** - * Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO + * Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO. */ @Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03"); - GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); + GetConfigOutput builtByFactory = BufferHelper.deserialize(factory, bb); Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue()); } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java deleted file mode 100644 index 6ab22829..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigInputMessageFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10GetConfigInputMessageFactoryTest { - private OFDeserializer factory; - - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 7, GetConfigInput.class)); - } - - @Test - public void test() { - ByteBuf bb = BufferHelper.buildBuffer(); - GetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV10(deserializedMessage); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java deleted file mode 100644 index fe75abc4..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetConfigReplyMessageFactoryTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10GetConfigReplyMessageFactoryTest { - - private OFDeserializer configFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - configFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 8, GetConfigOutput.class)); - } - - /** - * Testing {@link OF10GetConfigReplyMessageFactory} for correct translation into POJO - */ - @Test - public void test() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03"); - GetConfigOutput builtByFactory = BufferHelper.deserialize(configFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue()); - Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue()); - } - -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java deleted file mode 100644 index 763210ce..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10SetConfigMessageFactoryTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10SetConfigMessageFactoryTest { - private OFDeserializer factory; - - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 9, SetConfigInput.class)); - } - - @Test - public void test() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03"); - SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV10(deserializedMessage); - Assert.assertEquals("Wrong switchConfigFlag", 0x01, deserializedMessage.getFlags().getIntValue()); - Assert.assertEquals("Wrong missSendLen", 0x03, deserializedMessage.getMissSendLen().intValue()); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactoryTest.java similarity index 54% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java rename to openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactoryTest.java index d15b8359..fe4b4bb8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactoryTest.java @@ -8,38 +8,50 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.SetConfigInputMessageFactory}. * @author giuseppex.petralia@intel.com - * */ -public class SetConfigMessageFactoryTest { - private OFDeserializer factory; +public class SetConfigInputMessageFactoryTest extends DefaultDeserializerFactoryTest { + + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public SetConfigInputMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class)); + } - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 9, SetConfigInput.class)); + /** + * Testing {@link SetConfigInputMessageFactory} for correct header version. + */ + @Test + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF10_VERSION_ID, + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); + ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a"); + testHeaderVersions(versions, bb); } @Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 02 " + "00 0a"); SetConfigInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV13(deserializedMessage); // Test Message Assert.assertEquals("Wrong flags ", SwitchConfigFlag.forValue(2), deserializedMessage.getFlags()); From 6505f1cd53248a4ebe0d6959c19a94f16243d447 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Mon, 10 Oct 2016 09:44:38 +0200 Subject: [PATCH 254/285] Change BarrierReq/Res factories to version assignable - made BarrierRequest/BarrierReply factories version assignable - removed OF10 factories duplicates - registered new deserializers - update tests - fix typo Resolves: Bug 4255 Change-Id: I248941b94ea6974679a27313cd6634baaa0fc034 Signed-off-by: Andrej Leitner --- ...itionalMessageDeserializerInitializer.java | 7 +-- .../MessageDeserializerInitializer.java | 5 +- .../TypeToClassMapInitializer.java | 4 ++ .../factories/BarrierInputMessageFactory.java | 9 ++-- .../factories/BarrierReplyMessageFactory.java | 10 ++-- .../OF10BarrierInputMessageFactory.java | 30 ----------- .../OF10BarrierReplyMessageFactory.java | 32 ----------- .../TypeToClassMapInitializerTest.java | 4 ++ .../BarrierInputMessageFactoryTest.java | 43 +++++++++------ .../BarrierReplyMessageFactoryTest.java | 43 +++++++-------- .../OF10BarrierInputMessageFactoryTest.java | 42 --------------- .../OF10BarrierReplyMessageFactoryTest.java | 53 ------------------- .../util/DefaultDeserializerFactoryTest.java | 2 +- 13 files changed, 75 insertions(+), 209 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java index 3dfc9882..10ec3f06 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java @@ -18,7 +18,6 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GroupModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MeterModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartRequestInputMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesRequestMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10GetQueueConfigInputMessageFactory; @@ -49,8 +48,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** + * Util class for init registration of additional deserializers. * @author giuseppex.petralia@intel.com - * */ public class AdditionalMessageDeserializerInitializer { private AdditionalMessageDeserializerInitializer() { @@ -74,7 +73,7 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper.registerDeserializer(14, null, FlowModInput.class, new OF10FlowModInputMessageFactory()); helper.registerDeserializer(15, null, PortModInput.class, new OF10PortModInputMessageFactory()); helper.registerDeserializer(16, null, MultipartRequestInput.class, new OF10StatsRequestInputFactory()); - helper.registerDeserializer(18, null, BarrierInput.class, new OF10BarrierInputMessageFactory()); + helper.registerDeserializer(18, null, BarrierInput.class, new BarrierInputMessageFactory()); helper.registerDeserializer(20, null, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory()); // register OF v1.3 message deserializers @@ -99,11 +98,13 @@ public static void registerMessageDeserializers(DeserializerRegistry registry) { helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index d924bc1f..c20f63df 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -20,7 +20,6 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.GetConfigReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10BarrierReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10ErrorMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FeaturesReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10FlowRemovedMessageFactory; @@ -81,7 +80,7 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); - helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); + helper.registerDeserializer(19, null, BarrierOutput.class, new BarrierReplyMessageFactory()); helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); // register OF v1.3 message deserializers @@ -108,6 +107,7 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); @@ -115,5 +115,6 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index d8ca8c8a..61cce25d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -100,6 +100,7 @@ public static void initializeTypeToClassMap(final Map> helper.registerTypeToClass((short) 2, EchoRequestMessage.class); helper.registerTypeToClass((short) 3, EchoOutput.class); helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 21, BarrierOutput.class); // init OF v1.5 mapping helper = new TypeToClassInitHelper(EncodeConstants.OF15_VERSION_ID, messageClassMap); @@ -107,6 +108,7 @@ public static void initializeTypeToClassMap(final Map> helper.registerTypeToClass((short) 2, EchoRequestMessage.class); helper.registerTypeToClass((short) 3, EchoOutput.class); helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 21, BarrierOutput.class); } /** @@ -150,10 +152,12 @@ public static void initializeAdditionalTypeToClassMap(final Map{ +public class BarrierInputMessageFactory extends VersionAssignableFactory implements OFDeserializer{ @Override public BarrierInput deserialize(ByteBuf rawMessage) { BarrierInputBuilder builder = new BarrierInputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java index 4c109ca6..4d5cf784 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java @@ -9,23 +9,23 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; /** - * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3) + * Translates BarrierReply messages. + * OF protocol versions: 1.0, 1.3, 1.4, 1.5. * @author michal.polkorab * @author timotej.kubas */ -public class BarrierReplyMessageFactory implements OFDeserializer { +public class BarrierReplyMessageFactory extends VersionAssignableFactory implements OFDeserializer { @Override public BarrierOutput deserialize(ByteBuf rawMessage) { BarrierOutputBuilder builder = new BarrierOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setVersion(getVersion()); builder.setXid(rawMessage.readUnsignedInt()); return builder.build(); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java deleted file mode 100644 index ab08ea30..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10BarrierInputMessageFactory implements OFDeserializer { - - @Override - public BarrierInput deserialize(ByteBuf rawMessage) { - BarrierInputBuilder builder = new BarrierInputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java deleted file mode 100644 index 59122817..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; - -/** - * Translates BarrierReply messages (both OpenFlow v1.0 and OpenFlow v1.3) - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10BarrierReplyMessageFactory implements OFDeserializer { - - @Override - public BarrierOutput deserialize(ByteBuf rawMessage) { - BarrierOutputBuilder builder = new BarrierOutputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index 513bc29a..9ff6e9e7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -97,12 +97,14 @@ public void test() { assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); version = EncodeConstants.OF15_VERSION_ID; assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); } @Test @@ -141,10 +143,12 @@ public void testAdditionalTypes() { version = EncodeConstants.OF14_VERSION_ID; assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); + assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 20))); version = EncodeConstants.OF15_VERSION_ID; assertEquals("Wrong class", GetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 7))); assertEquals("Wrong class", SetConfigInput.class, messageClassMap.get(new TypeToClassKey(version, 9))); + assertEquals("Wrong class", BarrierInput.class, messageClassMap.get(new TypeToClassKey(version, 20))); } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java index 1fbcfc1c..5e63639b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactoryTest.java @@ -8,35 +8,46 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; -import org.junit.Before; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierInputMessageFactory}. * @author giuseppex.petralia@intel.com - * */ -public class BarrierInputMessageFactoryTest { - private OFDeserializer factory; +public class BarrierInputMessageFactoryTest extends DefaultDeserializerFactoryTest { + - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 20, BarrierInput.class)); + /** + * Initializes deserializer registry and lookups OF13 deserializer. + */ + public BarrierInputMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 20, BarrierInput.class)); } + /** + * Testing of {@link BarrierInputMessageFactory} for correct header version. + */ @Test - public void test() { + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); ByteBuf bb = BufferHelper.buildBuffer(); - BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV13(deserializedMessage); + testHeaderVersions(versions, bb); + + // OFP v1.0 need to be tested separately cause of different message type value + messageCodeKey = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class); + testHeaderVersions(Collections.singletonList(EncodeConstants.OF10_VERSION_ID), bb); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java index a938d5cb..7edff8ed 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactoryTest.java @@ -9,45 +9,46 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - -import org.junit.Before; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; /** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory}. * @author michal.polkorab * @author timotej.kubas */ -public class BarrierReplyMessageFactoryTest { - - private OFDeserializer barrierFactory; +public class BarrierReplyMessageFactoryTest extends DefaultDeserializerFactoryTest { /** - * Initializes deserializer registry and lookups correct deserializer + * Initializes deserializer registry and lookups OF13 deserializer. */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - barrierFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 21, BarrierOutput.class)); + public BarrierReplyMessageFactoryTest() { + super(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 21, BarrierOutput.class)); } /** - * Testing of {@link BarrierReplyMessageFactory} for correct translation into POJO + * Testing of {@link BarrierReplyMessageFactory} for correct header version. */ @Test - public void test() { + public void testVersions() { + List versions = new ArrayList<>(Arrays.asList( + EncodeConstants.OF13_VERSION_ID, + EncodeConstants.OF14_VERSION_ID, + EncodeConstants.OF15_VERSION_ID + )); ByteBuf bb = BufferHelper.buildBuffer(); - BarrierOutput builtByFactory = BufferHelper.deserialize( - barrierFactory, bb); + testHeaderVersions(versions, bb); - BufferHelper.checkHeaderV13(builtByFactory); + // OFP v1.0 need to be tested separately cause of different message type value + messageCodeKey = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 19, BarrierOutput.class); + testHeaderVersions(Collections.singletonList(EncodeConstants.OF10_VERSION_ID), bb); } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java deleted file mode 100644 index 01f51840..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierInputMessageFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015 NetIDE Consortium and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; - -/** - * @author giuseppex.petralia@intel.com - * - */ -public class OF10BarrierInputMessageFactoryTest { - private OFDeserializer factory; - - @Before - public void startUp() { - DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); - desRegistry.init(); - factory = desRegistry - .getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 18, BarrierInput.class)); - } - - @Test - public void test() { - ByteBuf bb = BufferHelper.buildBuffer(); - BarrierInput deserializedMessage = BufferHelper.deserialize(factory, bb); - BufferHelper.checkHeaderV10(deserializedMessage); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java deleted file mode 100644 index ca1db522..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10BarrierReplyMessageFactoryTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * @author timotej.kubas - */ -public class OF10BarrierReplyMessageFactoryTest { - - private OFDeserializer barrierFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - barrierFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 19, BarrierOutput.class)); - } - - /** - * Testing of {@link OF10BarrierReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testV10() { - ByteBuf bb = BufferHelper.buildBuffer(); - BarrierOutput builtByFactory = BufferHelper.deserialize( - barrierFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - } -} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java index 2d424cde..b5eead74 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/DefaultDeserializerFactoryTest.java @@ -24,7 +24,7 @@ public abstract class DefaultDeserializerFactoryTest { private DeserializerRegistry registry; protected OFDeserializer factory; - private MessageCodeKey messageCodeKey; + protected MessageCodeKey messageCodeKey; public DefaultDeserializerFactoryTest(final MessageCodeKey key) { this.registry = new DeserializerRegistryImpl(); From b7aa041859f3b74f0951d57edc5e4a9662c214ab Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Tue, 25 Oct 2016 13:03:47 +0200 Subject: [PATCH 255/285] Add methods for experimenter (de)serializer registration + update comments + remove unused imports Change-Id: I87f432417a62cb5a58fe4e0103f9ee491e99017d Signed-off-by: Andrej Leitner --- .../keys/ExperimenterIdDeserializerKey.java | 8 +- .../ExperimenterIdTypeDeserializerKey.java | 9 ++- ...itionalMessageDeserializerInitializer.java | 67 ++++++++-------- .../MessageDeserializerInitializer.java | 76 +++++++++---------- .../GetConfigInputMessageFactory.java | 1 - .../GetConfigReplyMessageFactory.java | 2 - .../SetConfigInputMessageFactory.java | 1 - .../MessageFactoryInitializer.java | 16 ++-- .../MultipartRequestInputFactory.java | 26 +------ .../util/CommonMessageRegistryHelper.java | 24 ++++-- .../SimpleDeserializerRegistryHelper.java | 19 ++++- .../ExperimenterDeserializerKeyFactory.java | 1 - .../ExperimenterSerializerKeyFactory.java | 1 - 13 files changed, 122 insertions(+), 129 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java index 8f66900d..ec2cf3e1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdDeserializerKey.java @@ -13,10 +13,8 @@ /** * @author michal.polkorab - * */ -public class ExperimenterIdDeserializerKey extends MessageCodeKey - implements ExperimenterDeserializerKey { +public class ExperimenterIdDeserializerKey extends MessageCodeKey implements ExperimenterDeserializerKey { private long experimenterId; @@ -26,8 +24,8 @@ public class ExperimenterIdDeserializerKey extends MessageCodeKey * @param experimenterId experimenter / vendor ID * @param objectClass class of created object */ - public ExperimenterIdDeserializerKey(short version, - long experimenterId, Class objectClass) { + public ExperimenterIdDeserializerKey(final short version, final long experimenterId, + final Class objectClass) { super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); this.experimenterId = experimenterId; } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java index cb88b1ad..c956feb0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterIdTypeDeserializerKey.java @@ -18,14 +18,15 @@ public class ExperimenterIdTypeDeserializerKey extends ExperimenterIdDeserialize private long type; /** - * @param msgVersion protocol wire version + * @param type of target experimenter object + * @param version protocol wire version * @param experimenterId experimenter / vendor ID * @param type data type according to vendor implementation * @param objectClass class of object to be serialized */ - public ExperimenterIdTypeDeserializerKey(short msgVersion, - long experimenterId, long type, Class objectClass) { - super(msgVersion, experimenterId, objectClass); + public ExperimenterIdTypeDeserializerKey(final short version, final long experimenterId, + final long type, Class objectClass) { + super(version, experimenterId, objectClass); this.type = type; } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java index 10ec3f06..33fc1ac1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java @@ -60,51 +60,50 @@ private AdditionalMessageDeserializerInitializer() { * Registers additional message deserializers. * @param registry registry to be filled with deserializers */ - public static void registerMessageDeserializers(DeserializerRegistry registry) { - - SimpleDeserializerRegistryHelper helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, - registry); + public static void registerMessageDeserializers(final DeserializerRegistry registry) { + SimpleDeserializerRegistryHelper helper; // register OF v1.0 message deserializers - helper.registerDeserializer(5, null, GetFeaturesInput.class, new OF10FeaturesRequestMessageFactory()); - helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); - helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); - helper.registerDeserializer(13, null, PacketOutInput.class, new OF10PacketOutInputMessageFactory()); - helper.registerDeserializer(14, null, FlowModInput.class, new OF10FlowModInputMessageFactory()); - helper.registerDeserializer(15, null, PortModInput.class, new OF10PortModInputMessageFactory()); - helper.registerDeserializer(16, null, MultipartRequestInput.class, new OF10StatsRequestInputFactory()); - helper.registerDeserializer(18, null, BarrierInput.class, new BarrierInputMessageFactory()); - helper.registerDeserializer(20, null, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory()); + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(5, GetFeaturesInput.class, new OF10FeaturesRequestMessageFactory()); + helper.registerDeserializer(7, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(13, PacketOutInput.class, new OF10PacketOutInputMessageFactory()); + helper.registerDeserializer(14, FlowModInput.class, new OF10FlowModInputMessageFactory()); + helper.registerDeserializer(15, PortModInput.class, new OF10PortModInputMessageFactory()); + helper.registerDeserializer(16, MultipartRequestInput.class, new OF10StatsRequestInputFactory()); + helper.registerDeserializer(18, BarrierInput.class, new BarrierInputMessageFactory()); + helper.registerDeserializer(20, GetQueueConfigInput.class, new OF10GetQueueConfigInputMessageFactory()); // register OF v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(5, null, GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); - helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); - helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); - helper.registerDeserializer(13, null, PacketOutInput.class, new PacketOutInputMessageFactory()); - helper.registerDeserializer(14, null, FlowModInput.class, new FlowModInputMessageFactory()); - helper.registerDeserializer(15, null, GroupModInput.class, new GroupModInputMessageFactory()); - helper.registerDeserializer(16, null, PortModInput.class, new PortModInputMessageFactory()); - helper.registerDeserializer(17, null, TableModInput.class, new TableModInputMessageFactory()); - helper.registerDeserializer(18, null, MultipartRequestInput.class, new MultipartRequestInputMessageFactory()); - helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); - helper.registerDeserializer(22, null, GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); - helper.registerDeserializer(24, null, RoleRequestInput.class, new RoleRequestInputMessageFactory()); - helper.registerDeserializer(26, null, GetAsyncInput.class, new GetAsyncRequestMessageFactory()); - helper.registerDeserializer(28, null, SetAsyncInput.class, new SetAsyncInputMessageFactory()); - helper.registerDeserializer(29, null, MeterModInput.class, new MeterModInputMessageFactory()); + helper.registerDeserializer(5, GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + helper.registerDeserializer(7, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(13, PacketOutInput.class, new PacketOutInputMessageFactory()); + helper.registerDeserializer(14, FlowModInput.class, new FlowModInputMessageFactory()); + helper.registerDeserializer(15, GroupModInput.class, new GroupModInputMessageFactory()); + helper.registerDeserializer(16, PortModInput.class, new PortModInputMessageFactory()); + helper.registerDeserializer(17, TableModInput.class, new TableModInputMessageFactory()); + helper.registerDeserializer(18, MultipartRequestInput.class, new MultipartRequestInputMessageFactory()); + helper.registerDeserializer(20, BarrierInput.class, new BarrierInputMessageFactory()); + helper.registerDeserializer(22, GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); + helper.registerDeserializer(24, RoleRequestInput.class, new RoleRequestInputMessageFactory()); + helper.registerDeserializer(26, GetAsyncInput.class, new GetAsyncRequestMessageFactory()); + helper.registerDeserializer(28, SetAsyncInput.class, new SetAsyncInputMessageFactory()); + helper.registerDeserializer(29, MeterModInput.class, new MeterModInputMessageFactory()); // register OF v1.4 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); - helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); - helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); - helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); + helper.registerDeserializer(7, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(20, BarrierInput.class, new BarrierInputMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); - helper.registerDeserializer(7, null, GetConfigInput.class, new GetConfigInputMessageFactory()); - helper.registerDeserializer(9, null, SetConfigInput.class, new SetConfigInputMessageFactory()); - helper.registerDeserializer(20, null, BarrierInput.class, new BarrierInputMessageFactory()); + helper.registerDeserializer(7, GetConfigInput.class, new GetConfigInputMessageFactory()); + helper.registerDeserializer(9, SetConfigInput.class, new SetConfigInputMessageFactory()); + helper.registerDeserializer(20, BarrierInput.class, new BarrierInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index c20f63df..79873cc1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -69,52 +69,52 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis // register OF v1.0 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(4, null, ExperimenterMessage.class, new VendorMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); - helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); - helper.registerDeserializer(19, null, BarrierOutput.class, new BarrierReplyMessageFactory()); - helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(0, HelloMessage.class, new OF10HelloMessageFactory()); + helper.registerDeserializer(1, ErrorMessage.class, new OF10ErrorMessageFactory()); + helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(4, ExperimenterMessage.class, new VendorMessageFactory()); + helper.registerDeserializer(6, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, PacketInMessage.class, new OF10PacketInMessageFactory()); + helper.registerDeserializer(11, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); + helper.registerDeserializer(12, PortStatusMessage.class, new OF10PortStatusMessageFactory()); + helper.registerDeserializer(17, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); + helper.registerDeserializer(19, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(21, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); // register OF v1.3 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(4, null, ExperimenterMessage.class, new ExperimenterMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); - helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); - helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); - helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); - helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); - helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(1, ErrorMessage.class, new ErrorMessageFactory()); + helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(4, ExperimenterMessage.class, new ExperimenterMessageFactory()); + helper.registerDeserializer(6, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, PacketInMessage.class, new PacketInMessageFactory()); + helper.registerDeserializer(11, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); + helper.registerDeserializer(12, PortStatusMessage.class, new PortStatusMessageFactory()); + helper.registerDeserializer(19, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); + helper.registerDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(23, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory()); + helper.registerDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); // register OF v1.4 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory()); // register OF v1.5 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF15_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(2, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(8, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(21, BarrierOutput.class, new BarrierReplyMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java index 6fecf669..84bb66fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java @@ -9,7 +9,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigInputBuilder; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java index 98fc2c99..c8c8071c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java @@ -9,9 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java index 52e80b71..5dc4c9b5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/SetConfigInputMessageFactory.java @@ -9,7 +9,6 @@ import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index a150de89..23551bb7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -58,8 +58,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput; /** + * Util class for init registration of serializers. * @author michal.polkorab - * */ public final class MessageFactoryInitializer { @@ -68,15 +68,14 @@ private MessageFactoryInitializer() { } /** - * Registers message serializers into provided registry - * - * @param serializerRegistry - * registry to be initialized with message serializers + * Registers message serializers into provided registry. + * @param serializerRegistry registry to be initialized with message serializers */ public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { + CommonMessageRegistryHelper registryHelper; + // register OF v1.0 message serializers - short version = EncodeConstants.OF10_VERSION_ID; - CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF10_VERSION_ID, serializerRegistry); registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); @@ -92,8 +91,7 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); // register OF v1.3 message serializers - version = EncodeConstants.OF13_VERSION_ID; - registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF13_VERSION_ID, serializerRegistry); registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java index 2287a64a..d4f7ab54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/MultipartRequestInputFactory.java @@ -64,7 +64,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; /** - * Translates MultipartRequest messages + * Translates MultipartRequest messages. * @author timotej.kubas * @author michal.polkorab */ @@ -160,50 +160,26 @@ private static int createMultipartRequestFlagsBitmask(final MultipartRequestFlag return ByteBufUtils.fillBitMask(0, flags.isOFPMPFREQMORE()); } - /** - * @param multipartRequestBody - * @param output - */ private void serializeDescBody() { // The body of MultiPartRequestDesc is empty } - /** - * @param multipartRequestBody - * @param out - */ private void serializeTableBody() { // The body of MultiPartTable is empty } - /** - * @param multipartRequestBody - * @param out - */ private void serializeGroupDescBody() { // The body of MultiPartRequestGroupDesc is empty } - /** - * @param multipartRequestBody - * @param out - */ private void serializeGroupFeaturesBody() { // The body of MultiPartRequestGroupFeatures is empty } - /** - * @param multipartRequestBody - * @param out - */ private void serializeMeterFeaturesBody() { // The body of MultiPartMeterFeatures is empty } - /** - * @param multipartRequestBody - * @param out - */ private void serializePortDescBody() { // The body of MultiPartPortDesc is empty } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java index b19b47e4..260d1b3f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java @@ -10,10 +10,11 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; /** + * Helper class for serializer registration. * @author michal.polkorab - * */ public class CommonMessageRegistryHelper { @@ -21,8 +22,8 @@ public class CommonMessageRegistryHelper { private SerializerRegistry serializerRegistry; /** - * @param version - * @param serializerRegistry + * @param version wire protocol version + * @param serializerRegistry registry to be filled with message serializers */ public CommonMessageRegistryHelper(short version, SerializerRegistry serializerRegistry) { this.version = version; @@ -30,10 +31,23 @@ public CommonMessageRegistryHelper(short version, SerializerRegistry serializerR } /** - * @param msgType - * @param serializer + * Registers serializer in registry. + * @param msgType class of object that will be serialized by given serializer + * @param serializer serializer instance */ public void registerSerializer(Class msgType, OFGeneralSerializer serializer) { serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); } + + /** + * Registers experimenter serializer in registry. + * @param experimenterId experimenterID of experimenter message + * @param type type of experimenter message + * @param serializer serializer instance + */ + public void registerExperimenterSerializer(final long experimenterId, final long type, + final OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(ExperimenterSerializerKeyFactory + .createExperimenterMessageSerializerKey(version, experimenterId, type), serializer); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 9e2fc83b..25b29d1d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -10,9 +10,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; /** - * Helper class for deserializer registration assigning particular version if necessary. + * Helper class for deserializer registration. * @author michal.polkorab */ public class SimpleDeserializerRegistryHelper { @@ -32,11 +33,10 @@ public SimpleDeserializerRegistryHelper(final short version, final DeserializerR /** * Register deserializer in registry. If deserializer supports more protocol versions assign actual one. * @param code code / value to distinguish between deserializers - * @param experimenterID TODO * @param deserializedObjectClass class of object that will be deserialized by given deserializer * @param deserializer deserializer instance */ - public void registerDeserializer(final int code, final Long experimenterID, final Class deserializedObjectClass, + public void registerDeserializer(final int code, final Class deserializedObjectClass, final OFGeneralDeserializer deserializer) { registry.registerDeserializer(new MessageCodeKey(version, code, deserializedObjectClass), deserializer); @@ -44,4 +44,17 @@ public void registerDeserializer(final int code, final Long experimenterID, fina ((VersionAssignableFactory) deserializer).assignVersion(version); } } + + /** + * Register experimenter deserializer in registry. + * @param experimenterId experimenterID of experimenter message + * @param type type of experimenter message + * @param deserializer deserializer instance + */ + public void registerExperimenterDeserializer (final long experimenterId, final long type, + final OFGeneralDeserializer deserializer) { + registry.registerDeserializer(ExperimenterDeserializerKeyFactory + .createExperimenterMessageDeserializerKey(version, experimenterId, type), deserializer); + } + } diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 6c65deed..bbb9ee87 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -18,7 +18,6 @@ /** * @author michal.polkorab - * */ public abstract class ExperimenterDeserializerKeyFactory { diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 0155893d..613cd804 100755 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -18,7 +18,6 @@ /** * @author michal.polkorab - * */ public abstract class ExperimenterSerializerKeyFactory { From d17ee1296b9aeefa8d8c1dfa0ad52d9dac7feee9 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Mon, 24 Oct 2016 08:45:01 +0200 Subject: [PATCH 256/285] Add yang models for bundle messages - augmented model of experimenter message for ONF_ET_BUNDLE_CONTROL and ONF_ET_BUNDLE_ADD_MESSAGE messages - added related defined types (error codes, flags, properties, ...) Reference: ONF approved extension #230 Resolves: Bug 6806 Change-Id: I03761dc2630928623dbb55c55fd148c762b2489a Signed-off-by: Andrej Leitner --- .../protocol/api/util/EncodeConstants.java | 12 +- .../protocol/api/util/OxmMatchConstants.java | 12 +- .../yang/openflow-approved-extensions.yang | 191 ++++++++++++++++++ .../MatchEntryDeserializerInitializer.java | 10 +- .../MatchEntriesInitializer.java | 7 +- .../match/ext/OnfOxmTcpFlagsSerializer.java | 4 +- 6 files changed, 212 insertions(+), 24 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index dad7b76f..8c6539b6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -62,8 +62,16 @@ public abstract class EncodeConstants { /** OF v1.0 maximal port name length */ public static final byte MAX_PORT_NAME_LENGTH = 16; - /** OF v1.3 length of experimenter_ids - see Multipart TableFeatures (properties) message */ - public static final byte EXPERIMENTER_IDS_LENGTH = 8; + + /** ONF Approved Extensions Constants */ + /** Experimenter ID of ONF approved extensions */ + public static final long ONF_EXPERIMENTER_ID = 0x4F4E4600; + /** ONFOXM_ET_TCP_FLAGS value */ + public static final int ONFOXM_ET_TCP_FLAGS = 42; + /** ONF_ET_BUNDLE_CONTROL message type */ + public static final int ONF_ET_BUNDLE_CONTROL = 2300; + /** ONF_ET_BUNDLE_ADD_MESSAGE message type */ + public static final int ONF_ET_BUNDLE_ADD_MESSAGE = 2301; private EncodeConstants() { //not called diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index f4da03ce..e47b70d6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -8,9 +8,8 @@ package org.opendaylight.openflowjava.protocol.api.util; /** - * Stores oxm_match constants + * Stores oxm_match constants. * @author michal.polkorab - * */ public abstract class OxmMatchConstants { @@ -115,15 +114,6 @@ public abstract class OxmMatchConstants { /** NXM TCP_Flag value */ public static final int NXM_NX_TCP_FLAG = 34; - /** - * ONF Approved Extensions Constants - */ - - /** ONFOXM_ET_TCP_FLAGS value */ - public static final int ONFOXM_ET_TCP_FLAGS = 42; - /** ONFOXM_ET_TCP_FLAGS Experimenter Id (0x4F4E4600) */ - public static final long ONFOXM_ET_TCP_FLAGS_EXP_ID = 1330529792; - private OxmMatchConstants() { //not called } diff --git a/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang index d4afa880..17c89408 100644 --- a/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang +++ b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang @@ -19,6 +19,77 @@ module openflow-approved-extensions { //ONF Approved OpenFlow Extensions + // ONF experimenter error codes + typedef onf-experimenter-error-code { + description "Error codes for experimenter error type."; + type enumeration { + enum ONFERR_ET_UNKNOWN { + description "Unspecified error."; + value 2300; + } + enum ONFERR_ET_EPERM { + description "Permissions error."; + value 2301; + } + enum ONFERR_ET_BAD_ID { + description "Bundle ID doesn’t exist."; + value 2302; + } + enum ONFERR_ET_BUNDLE_EXIST { + description "Bundle ID already exist."; + value 2303; + } + enum ONFERR_ET_BUNDLE_CLOSED { + description "Bundle ID is closed."; + value 2304; + } + enum ONFERR_ET_OUT_OF_BUNDLES { + description "Too many bundles IDs."; + value 2305; + } + enum ONFERR_ET_BAD_TYPE { + description "Unsupported or unknown message control type."; + value 2306; + } + enum ONFERR_ET_BAD_FLAGS { + description "Unsupported, unknown, or inconsistent flags."; + value 2307; + } + enum ONFERR_ET_MSG_BAD_LEN { + description "Length problem in included message."; + value 2308; + } + enum ONFERR_ET_MSG_BAD_XID { + description "Inconsistent or duplicate XID."; + value 2309; + } + enum ONFERR_ET_MSG_UNSUP { + description "Unsupported message in this bundle."; + value 2310; + } + enum ONFERR_ET_MSG_CONFLICT { + description "Unsupported message combination in this bundle."; + value 2311; + } + enum ONFERR_ET_MSG_TOO_MANY { + description "Can not handle this many messages in bundle."; + value 2312; + } + enum ONFERR_ET_MSG_FAILED { + description "One message in bundle failed."; + value 2313; + } + enum ONFERR_ET_TIMEOUT { + description "Bundle is taking too long."; + value 2314; + } + enum ONFERR_ET_BUNDLE_IN_PROGRESS { + description "Bundle is locking the resource."; + value 2315; + } + } + } + // Extension 109 - TCP FLAGS identity tcp_flags { base oxm:match-field; @@ -37,4 +108,124 @@ module openflow-approved-extensions { } } + // Extension 230 - Bundle Extension (experimenterID 0x4F4E4600) + typedef bundle-id { + description "Identify the bundle."; + type uint32; + } + + typedef bundle-control-type { + description "Bundle control message type."; + type enumeration { + enum ONF_BCT_OPEN_REQUEST { + value 0; + } + enum ONF_BCT_OPEN_REPLY { + value 1; + } + enum ONF_BCT_CLOSE_REQUEST { + value 2; + } + enum ONF_BCT_CLOSE_REPLY { + value 3; + } + enum ONF_BCT_COMMIT_REQUEST { + value 4; + } + enum ONF_BCT_COMMIT_REPLY { + value 5; + } + enum ONF_BCT_DISCARD_REQUEST { + value 6; + } + enum ONF_BCT_DISCARD_REPLY { + value 7; + } + } + } + + typedef bundle-flags { + description "Bundle configuration flags."; + type bits { + bit atomic { + description "Execute atomically."; + position 0; + } + bit ordered { + description "Execute in specified order."; + position 1; + } + } + } + + typedef bundle-property-type { + description "Bundle property types."; + type enumeration { + enum ONF_ET_BPT_EXPERIMENTER { + description "Experimenter property."; + value 65535; //0xFFFF + } + } + } + + grouping bundle-properties { + list bundle-property { + description "Bundle properties list."; + leaf type { + type bundle-property-type; + } + choice bundle-property-entry { + case bundle-experimenter-property { + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + choice bundle-experimenter-property-data { + // to be augmented by vendors + } + } + } + } + } + + augment "/ofproto:experimenter/ofproto:input/ofproto:experimenter-data-of-choice" { + case bundle-control { + description "ONF_ET_BUNDLE_CONTROL message in OpenFlow Switch Extension 230."; + leaf bundle-id { + type bundle-id; + } + leaf type { + type bundle-control-type; + } + leaf flags { + type bundle-flags; + } + uses bundle-properties; + } + case bundle-add-message { + description "ONF_ET_BUNDLE_ADD_MESSAGE in OpenFlow Switch Extension 230."; + leaf bundle-id { + type bundle-id; + } + leaf flags { + type bundle-flags; + } + // Inner message + choice message { + description "Message added to the bundle."; + case flow-mod-case { + uses ofproto:flow-mod; + } + case group-mod-case { + uses ofproto:group-mod; + } + case port-mod-case { + uses ofproto:port-mod; + } + } + uses bundle-properties; + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index dc1bae06..98d1b34e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; @@ -48,14 +50,12 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext.OnfOxmTcpFlagsDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; /** + * Util class for init registration of match entry deserializers. * @author michal.polkorab - * */ public final class MatchEntryDeserializerInitializer { @@ -64,7 +64,7 @@ private MatchEntryDeserializerInitializer() { } /** - * Registers match entry deserializers + * Registers match entry deserializers. * @param registry registry to be filled with deserializers */ public static void registerMatchEntryDeserializers(DeserializerRegistry registry) { @@ -114,7 +114,7 @@ public static void registerMatchEntryDeserializers(DeserializerRegistry registry helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); // Register approved openflow match entry deserializers - helper.registerExperimenter(OxmMatchConstants.ONFOXM_ET_TCP_FLAGS, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID, + helper.registerExperimenter(EncodeConstants.ONFOXM_ET_TCP_FLAGS, EncodeConstants.ONF_EXPERIMENTER_ID, new OnfOxmTcpFlagsDeserializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 2ed24e59..a7879788 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -9,7 +9,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; @@ -96,7 +95,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid; /** - * Initializes serializer registry with match entry serializers + * Initializes serializer registry with match entry serializers. * @author michal.polkorab */ public final class MatchEntriesInitializer { @@ -106,7 +105,7 @@ private MatchEntriesInitializer() { } /** - * Registers match entry serializers into provided registry + * Registers match entry serializers into provided registry. * @param serializerRegistry registry to be initialized with match entry serializers */ public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { @@ -157,7 +156,7 @@ public static void registerMatchEntrySerializers(SerializerRegistry serializerRe helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); // Register approved openflow match entry serializers - helper.registerExperimenterSerializer(TcpFlags.class, OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID, + helper.registerExperimenterSerializer(TcpFlags.class, EncodeConstants.ONF_EXPERIMENTER_ID, new OnfOxmTcpFlagsSerializer()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java index 340dc7ae..f244cc42 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/ext/OnfOxmTcpFlagsSerializer.java @@ -36,7 +36,7 @@ public void serialize(MatchEntry entry, ByteBuf outBuffer) { */ @Override protected long getExperimenterId() { - return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS_EXP_ID; + return EncodeConstants.ONF_EXPERIMENTER_ID; } /** @@ -44,7 +44,7 @@ protected long getExperimenterId() { */ @Override protected int getOxmFieldCode() { - return OxmMatchConstants.ONFOXM_ET_TCP_FLAGS; + return EncodeConstants.ONFOXM_ET_TCP_FLAGS; } /** From ce4d2f2c0077fff015c3cde8c144fe543b915cba Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Tue, 25 Oct 2016 14:28:45 +0200 Subject: [PATCH 257/285] Add bundle messages serializers - created and registered serializers for ONF_ET_BUNDLE_CONTROL and ONF_ET_BUNDLE_ADD_MESSAGE messages - updated Flow/Group/PortMod facories to use more general objects - registered additional serializers for inner messages - added tests Reference: ONF approved extension #230 Resolves: Bug 6806 Change-Id: I1e98332eed24e18f17157e9a16ac8d246c72af2c Signed-off-by: Andrej Leitner --- .../MessageFactoryInitializer.java | 16 +++ .../AbstractBundleMessageFactory.java | 80 +++++++++++++ .../experimenter/BundleAddMessageFactory.java | 55 +++++++++ .../experimenter/BundleControlFactory.java | 29 +++++ .../factories/FlowModInputMessageFactory.java | 14 +-- .../GroupModInputMessageFactory.java | 13 +-- .../factories/PortModInputMessageFactory.java | 9 +- .../AbstractBundleMessageFactoryTest.java | 82 ++++++++++++++ .../BundleAddMessageFactoryTest.java | 105 ++++++++++++++++++ .../BundleControlFactoryTest.java | 97 ++++++++++++++++ .../ExperimenterSerializerKeyFactory.java | 12 ++ 11 files changed, 494 insertions(+), 18 deletions(-) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 23551bb7..08b9bc54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -9,6 +9,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleAddMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleControlFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory; @@ -37,6 +39,9 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.VendorInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.FlowModCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.GroupModCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -111,5 +116,16 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); + + // register ONF approved experimenter serializers + registryHelper.registerExperimenterSerializer(EncodeConstants.ONF_EXPERIMENTER_ID, + EncodeConstants.ONF_ET_BUNDLE_CONTROL, new BundleControlFactory()); + registryHelper.registerExperimenterSerializer(EncodeConstants.ONF_EXPERIMENTER_ID, + EncodeConstants.ONF_ET_BUNDLE_ADD_MESSAGE, new BundleAddMessageFactory()); + + // register serializers for inner messages of BundleAddMessage + registryHelper.registerSerializer(FlowModCase.class, new FlowModInputMessageFactory()); + registryHelper.registerSerializer(GroupModCase.class, new GroupModInputMessageFactory()); + registryHelper.registerSerializer(PortModCase.class, new PortModInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java new file mode 100644 index 00000000..3fc2896a --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Abstract class for common stuff of bundle messages. + */ +public abstract class AbstractBundleMessageFactory implements OFSerializer, + SerializerRegistryInjector { + + private static final Logger LOG = LoggerFactory.getLogger(AbstractBundleMessageFactory.class); + protected SerializerRegistry serializerRegistry; + + @Override + public void serialize(T input, ByteBuf outBuffer) { + // to be extended + } + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + this.serializerRegistry = serializerRegistry; + } + + protected static void writeBundleFlags(final BundleFlags bundleFlags, final ByteBuf outBuffer) { + int flagsBitMap = ByteBufUtils.fillBitMask(0, bundleFlags.isAtomic(), bundleFlags.isOrdered()); + outBuffer.writeShort(flagsBitMap); + } + + protected void writeBundleProperties(final List properties, final ByteBuf outBuffer) { + for (BundleProperty property : properties) { + BundlePropertyType type = property.getType(); + if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(type.getIntValue()); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + writeBundleExperimenterProperty(property, outBuffer); + outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); + } else { + LOG.warn("lTrying to serialize unknown bundle property (type: {}), skipping", type.getIntValue() ); + } + } + } + + protected void writeBundleExperimenterProperty(final BundleProperty bundleProperty, final ByteBuf outBuffer) { + BundleExperimenterProperty property = (BundleExperimenterProperty) bundleProperty.getBundlePropertyEntry(); + int experimenterId = property.getExperimenter().getValue().intValue(); + int expType = property.getExpType().intValue(); + outBuffer.writeInt(experimenterId); + outBuffer.writeInt(expType); + OFSerializer serializer = serializerRegistry.getSerializer( + ExperimenterSerializerKeyFactory.createBundlePropertySerializerKey(EncodeConstants.OF13_VERSION_ID, + experimenterId, expType)); + serializer.serialize(property.getBundleExperimenterPropertyData(), outBuffer); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java new file mode 100644 index 00000000..9ceec4de --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.Message; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * Translates BundleAddMessage messages (OpenFlow v1.3 extension #230). + */ +public class BundleAddMessageFactory extends AbstractBundleMessageFactory { + + @Override + public void serialize(BundleAddMessage input, ByteBuf outBuffer) { + outBuffer.writeInt(input.getBundleId().getValue().intValue()); + outBuffer.writeZero(2); + writeBundleFlags(input.getFlags(), outBuffer); + + int msgStart = outBuffer.writerIndex(); + serializeInnerMessage(input.getMessage(), outBuffer, input.getMessage().getImplementedInterface()); + int msgLength = outBuffer.writerIndex() - msgStart; + + List bundleProperties = input.getBundleProperty(); + if (bundleProperties != null && !bundleProperties.isEmpty()) { + outBuffer.writeZero(paddingNeeded(msgLength)); + writeBundleProperties(input.getBundleProperty(), outBuffer); + } + } + + private void serializeInnerMessage(final Message innerMessage, final ByteBuf outBuffer, + final Class clazz) { + OFSerializer serializer = serializerRegistry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, clazz)); + serializer.serialize((T)innerMessage, outBuffer); + } + + private static int paddingNeeded(final int length) { + int paddingRemainder = length % EncodeConstants.PADDING; + return (paddingRemainder != 0) ? (EncodeConstants.PADDING - paddingRemainder) : 0; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java new file mode 100644 index 00000000..069f34fe --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; + +/** + * Translates BundleControl messages (OpenFlow v1.3 extension #230). + */ +public class BundleControlFactory extends AbstractBundleMessageFactory { + + @Override + public void serialize(BundleControl input, ByteBuf outBuffer) { + outBuffer.writeInt(input.getBundleId().getValue().intValue()); + outBuffer.writeShort(input.getType().getIntValue()); + writeBundleFlags(input.getFlags(), outBuffer); + if (input.getBundleProperty() != null) { + writeBundleProperties(input.getBundleProperty(), outBuffer); + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 79f831ba..62fab014 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -9,7 +9,6 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; @@ -22,14 +21,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowMod; /** - * Translates FlowMod messages + * Translates FlowMod messages. + * OF protocol versions: 1.3. * @author timotej.kubas * @author michal.polkorab */ -public class FlowModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { +public class FlowModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private static final byte MESSAGE_TYPE = 14; private static final byte PADDING_IN_FLOW_MOD_MESSAGE = 2; private static final TypeKeyMaker INSTRUCTION_KEY_MAKER = @@ -37,14 +37,14 @@ public class FlowModInputMessageFactory implements OFSerializer, S private SerializerRegistry registry; @Override - public void serialize(final FlowModInput message, final ByteBuf outBuffer) { + public void serialize(final FlowMod message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeLong(message.getCookieMask().longValue()); outBuffer.writeByte(message.getTableId().getValue().byteValue()); outBuffer.writeByte(message.getCommand().getIntValue()); - outBuffer.writeShort(message.getIdleTimeout().intValue()); - outBuffer.writeShort(message.getHardTimeout().intValue()); + outBuffer.writeShort(message.getIdleTimeout()); + outBuffer.writeShort(message.getHardTimeout()); outBuffer.writeShort(message.getPriority()); outBuffer.writeInt(message.getBufferId().intValue()); outBuffer.writeInt(message.getOutPort().getValue().intValue()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java index 93e4c741..95a3b7db 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java @@ -9,32 +9,31 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.factories; import io.netty.buffer.ByteBuf; - import java.util.List; - import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupMod; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList; /** - * Translates GroupMod messages + * Translates GroupMod messages. + * OF protocol versions: 1.3. * @author timotej.kubas * @author michal.polkorab */ -public class GroupModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { +public class GroupModInputMessageFactory implements OFSerializer, SerializerRegistryInjector { private static final byte MESSAGE_TYPE = 15; private static final byte PADDING_IN_GROUP_MOD_MESSAGE = 1; private static final byte PADDING_IN_BUCKET = 4; private SerializerRegistry registry; @Override - public void serialize(GroupModInput message, ByteBuf outBuffer) { + public void serialize(GroupMod message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getCommand().getIntValue()); outBuffer.writeByte(message.getType().getIntValue()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index 595a216c..ded3af6d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -17,21 +17,22 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortMod; /** - * Translates PortMod messages + * Translates PortMod messages. + * OF protocol versions: 1.3. * @author timotej.kubas * @author michal.polkorab */ -public class PortModInputMessageFactory implements OFSerializer { +public class PortModInputMessageFactory implements OFSerializer { private static final byte MESSAGE_TYPE = 16; private static final byte PADDING_IN_PORT_MOD_MESSAGE_01 = 4; private static final byte PADDING_IN_PORT_MOD_MESSAGE_02 = 2; private static final byte PADDING_IN_PORT_MOD_MESSAGE_03 = 4; @Override - public void serialize(final PortModInput message, final ByteBuf outBuffer) { + public void serialize(final PortMod message, final ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPortNo().getValue().intValue()); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java new file mode 100644 index 00000000..3de49975 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundlePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterPropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yangtools.yang.binding.DataContainer; + +/** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.AbstractBundleMessageFactory} + * and util methods. + */ +public class AbstractBundleMessageFactoryTest { + + @Test + public void writeBundleFlags() throws Exception { + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + AbstractBundleMessageFactory.writeBundleFlags(new BundleFlags(true, true), out); + Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort()); + } + + public static List createListWithBundleExperimenterProperty(BundleExperimenterPropertyData data) { + BundlePropertyBuilder propertyBuilder = new BundlePropertyBuilder(); + propertyBuilder.setType(BundlePropertyType.ONFETBPTEXPERIMENTER); + BundleExperimenterPropertyBuilder experimenterPropertyBuilder = new BundleExperimenterPropertyBuilder(); + experimenterPropertyBuilder.setExperimenter(new ExperimenterId(1L)); + experimenterPropertyBuilder.setExpType(2L); + + experimenterPropertyBuilder.setBundleExperimenterPropertyData(data); + propertyBuilder.setBundlePropertyEntry(experimenterPropertyBuilder.build()); + return new ArrayList<>(Collections.singleton(propertyBuilder.build())); + } + + public static BundleExperimenterPropertyData createBundleExperimenterPropertyData() { + return new BundleExperimenterPropertyData() { + @Override + public Class getImplementedInterface() { + return null; + } + }; + } + + public static PortModCase createPortModCase() { + PortModCaseBuilder caseBuilder = new PortModCaseBuilder(); + caseBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + caseBuilder.setXid(3L); + caseBuilder.setPortNo(new PortNumber(9L)); + caseBuilder.setHwAddress(new MacAddress("08:00:27:00:B0:EB")); + caseBuilder.setConfig(new PortConfig(true, false, true, false)); + caseBuilder.setMask(new PortConfig(false, true, false, true)); + caseBuilder.setAdvertise(new PortFeatures(true, false, false, false, + false, false, false, true, + false, false, false, false, + false, false, false, false)); + return caseBuilder.build(); + } +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java new file mode 100644 index 00000000..9e662519 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.Message; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortMod; + +/** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleAddMessageFactory}. + */ +@RunWith(MockitoJUnitRunner.class) +public class BundleAddMessageFactoryTest { + + private OFSerializer factory; + @Mock + SerializerRegistry registry; + @Mock + OFSerializer portModSerializer; + @Mock + OFSerializer propertySerializer; + + @Before + public void setUp() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, + EncodeConstants.ONF_ET_BUNDLE_ADD_MESSAGE)); + } + + @Test + public void testSerializeWithoutProperties() { + BundleAddMessageBuilder builder = new BundleAddMessageBuilder(); + builder.setBundleId(new BundleId(1L)); + builder.setFlags(new BundleFlags(true, false)); + + Message innerMessage = AbstractBundleMessageFactoryTest.createPortModCase(); + builder.setMessage(innerMessage); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))).thenReturn(portModSerializer); + ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); + factory.serialize(builder.build(), out); + + Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt()); + long padding = out.readUnsignedShort(); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + Mockito.verify(portModSerializer, Mockito.times(1)).serialize((PortMod)innerMessage, out); + } + + @Test + public void testSerializeWithExperimenterProperty() { + BundleAddMessageBuilder builder = new BundleAddMessageBuilder(); + builder.setBundleId(new BundleId(2L)); + builder.setFlags(new BundleFlags(true, false)); + + Message innerMessage = AbstractBundleMessageFactoryTest.createPortModCase(); + builder.setMessage(innerMessage); + + BundleExperimenterPropertyData data = AbstractBundleMessageFactoryTest.createBundleExperimenterPropertyData(); + builder.setBundleProperty(AbstractBundleMessageFactoryTest.createListWithBundleExperimenterProperty(data)); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))) + .thenReturn(portModSerializer) + .thenReturn(propertySerializer); + ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); + factory.serialize(builder.build(), out); + + Assert.assertEquals("Wrong bundle ID", 2L, out.readUnsignedInt()); + long padding = out.readUnsignedShort(); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + Mockito.verify(portModSerializer, Mockito.times(1)).serialize((PortMod)innerMessage, out); + Mockito.verify(propertySerializer, Mockito.times(1)).serialize(data, out); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java new file mode 100644 index 00000000..180d915a --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControlBuilder; + +/** + * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleControlFactory}. + */ +@RunWith(MockitoJUnitRunner.class) +public class BundleControlFactoryTest { + + private OFSerializer factory; + @Mock + SerializerRegistry registry; + @Mock + OFSerializer serializer; + + @Before + public void setUp() throws Exception { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + factory = registry.getSerializer(ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, EncodeConstants.ONF_ET_BUNDLE_CONTROL)); + } + + @Test + public void testSerializeWithoutProperties() { + BundleControlBuilder builder = new BundleControlBuilder(); + builder.setBundleId(new BundleId(1L)); + builder.setType(BundleControlType.ONFBCTOPENREQUEST); + builder.setFlags(new BundleFlags(true, true)); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(builder.build(), out); + + Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt()); + Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREQUEST.getIntValue(), out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort()); + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } + + @Test + public void testSerializeWithExperimenterProperty() { + BundleControlBuilder builder = new BundleControlBuilder(); + builder.setBundleId(new BundleId(3L)); + builder.setType(BundleControlType.ONFBCTCOMMITREQUEST); + builder.setFlags(new BundleFlags(false, true)); + + BundleExperimenterPropertyData data = AbstractBundleMessageFactoryTest.createBundleExperimenterPropertyData(); + builder.setBundleProperty(AbstractBundleMessageFactoryTest.createListWithBundleExperimenterProperty(data)); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))).thenReturn(serializer); + ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); + factory.serialize(builder.build(), out); + + Assert.assertEquals("Wrong bundle ID", 3L, out.readUnsignedInt()); + Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREQUEST.getIntValue(), out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong property type", BundlePropertyType.ONFETBPTEXPERIMENTER.getIntValue(), out.readUnsignedShort()); + int length = out.readUnsignedShort(); + Assert.assertEquals("Wrong experimenter ID", 1, out.readUnsignedInt()); + Assert.assertEquals("Wrong experimenter type", 2, out.readUnsignedInt()); + Mockito.verify(serializer, Mockito.times(1)).serialize(data, out); + } + +} \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 613cd804..24e78deb 100755 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -11,6 +11,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -67,4 +68,15 @@ public static ExperimenterIdSerializerKey createMeter short msgVersion, long experimenterId, Class meterSubType) { return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class, meterSubType); } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter ID + * @param type experimenter type according to vendor implementation + * @return key instance + */ + public static ExperimenterIdSerializerKey createBundlePropertySerializerKey( + short msgVersion, long experimenterId, long type) { + return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, BundleExperimenterPropertyData.class); + } } \ No newline at end of file From f20523147f895af10cdd882f6c6d26ce1f9d18f5 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Thu, 27 Oct 2016 11:43:07 +0200 Subject: [PATCH 258/285] Add bundle control and ONF experimenter error deserializers - created and registered deserializers for ONF_ET_BUNDLE_CONTROL message and ONF experimenter errors - added tests Reference: ONF approved extension #230 Resolves: Bug 6806 Change-Id: Iaa584aae6ee2e9962f962803d363f3213d99fa2e Signed-off-by: Andrej Leitner --- .../MessageDeserializerInitializer.java | 8 + .../experimenter/BundleControlFactory.java | 96 ++++++++++++ .../OnfExperimenterErrorFactory.java | 72 +++++++++ .../SimpleDeserializerRegistryHelper.java | 11 ++ .../BundleControlFactoryTest.java | 100 +++++++++++++ .../OnfExperimenterErrorFactoryTest.java | 140 ++++++++++++++++++ .../ExperimenterDeserializerKeyFactory.java | 12 ++ 7 files changed, 439 insertions(+) create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java create mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java create mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 79873cc1..488db9c6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -9,6 +9,8 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.BundleControlFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.OnfExperimenterErrorFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory; @@ -101,6 +103,12 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory()); helper.registerDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + // register ONF approved experimenter serializers + helper.registerExperimenterErrorDeserializer(EncodeConstants.ONF_EXPERIMENTER_ID, + new OnfExperimenterErrorFactory()); + helper.registerExperimenterDeserializer(EncodeConstants.ONF_EXPERIMENTER_ID, + EncodeConstants.ONF_ET_BUNDLE_CONTROL, new BundleControlFactory()); + // register OF v1.4 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java new file mode 100644 index 00000000..0d52e0c8 --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; + +import io.netty.buffer.ByteBuf; +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundlePropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterPropertyBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControlBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; + +/** + * Translates BundleControl messages (OpenFlow v1.3 extension #230). + */ +public class BundleControlFactory implements OFDeserializer, DeserializerRegistryInjector { + + private DeserializerRegistry deserializerRegistry; + + @Override + public BundleControl deserialize(ByteBuf message) { + BundleId bundleId = new BundleId(message.readUnsignedInt()); + BundleControlType type = BundleControlType.forValue(message.readUnsignedShort()); + BundleFlags flags = createBundleFlags(message.readUnsignedShort()); + BundleControlBuilder builder = new BundleControlBuilder(); + List properties = createBundleProperties(message); + return builder.setBundleId(bundleId) + .setType(type) + .setFlags(flags) + .setBundleProperty(properties) + .build(); + } + + private static BundleFlags createBundleFlags(final int flags) { + Boolean isAtomic = (flags & (1 << 0)) != 0; + Boolean isOrdered = (flags & (1 << 1)) != 0; + return new BundleFlags(isAtomic, isOrdered); + } + + private List createBundleProperties(final ByteBuf message) { + List properties = new ArrayList<>(); + while (message.readableBytes() > 0) { + BundlePropertyType type = BundlePropertyType.forValue(message.readUnsignedShort()); + int length = message.readUnsignedShort(); + if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) { + properties.add(createExperimenterBundleProperty(length, message)); + } else { + message.skipBytes(length); + } + } + return properties; + } + + private BundleProperty createExperimenterBundleProperty(final int length, final ByteBuf message) { + BundleExperimenterPropertyBuilder experimenterProperty = new BundleExperimenterPropertyBuilder(); + long experimenterId = message.readUnsignedInt(); + long expType = message.readUnsignedInt(); + experimenterProperty.setExperimenter(new ExperimenterId(experimenterId)); + experimenterProperty.setExpType(expType); + + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createBundlePropertyDeserializerKey(EncodeConstants.OF13_VERSION_ID, + experimenterId, expType)); + experimenterProperty.setBundleExperimenterPropertyData(deserializer.deserialize(message.readBytes(length - 12))); + + return new BundlePropertyBuilder().setType(BundlePropertyType.ONFETBPTEXPERIMENTER) + .setBundlePropertyEntry(experimenterProperty.build()) + .build(); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } + +} + + diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java new file mode 100644 index 00000000..a104531d --- /dev/null +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.OnfExperimenterErrorCode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdError; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdErrorBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Translates (ONF approved) experimenter error messages. + */ +public class OnfExperimenterErrorFactory implements OFDeserializer { + + private static final Logger LOG = LoggerFactory.getLogger(OnfExperimenterErrorFactory.class); + private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE"; + private static final String UNKNOWN_CODE = "UNKNOWN_CODE"; + + @Override + public ErrorMessage deserialize(ByteBuf message) { + ErrorMessageBuilder builder = new ErrorMessageBuilder(); + builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + builder.setXid(message.readUnsignedInt()); + + int type = message.readUnsignedShort(); + ErrorType errorType = ErrorType.forValue(type); + if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) { + builder.setType(errorType.getIntValue()); + builder.setTypeString(errorType.getName()); + } else { + LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(), + this.getClass().getCanonicalName()); + builder.setType(type); + builder.setTypeString(UNKNOWN_TYPE); + } + + int code = message.readUnsignedShort(); + OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code); + if (errorCode != null) { + builder.setCode(errorCode.getIntValue()); + builder.setCodeString(errorCode.getName()); + } else { + builder.setCode(code); + builder.setCodeString(UNKNOWN_CODE); + } + + builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder() + .setExperimenter(new ExperimenterId(message.readUnsignedInt())) + .build()); + + if (message.readableBytes() > 0) { + byte[] data = new byte[message.readableBytes()]; + message.readBytes(data); + builder.setData(data); + } + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 25b29d1d..752ac3e3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -57,4 +57,15 @@ public void registerExperimenterDeserializer (final long experimenterId, final l .createExperimenterMessageDeserializerKey(version, experimenterId, type), deserializer); } + /** + * Register experimenter error deserializer in registry. + * @param experimenterId experimenterID of experimenter message + * @param deserializer deserializer instance + */ + public void registerExperimenterErrorDeserializer (final long experimenterId, + final OFGeneralDeserializer deserializer) { + registry.registerDeserializer(ExperimenterDeserializerKeyFactory + .createExperimenterErrorDeserializerKey(version, experimenterId), deserializer); + } + } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java new file mode 100644 index 00000000..77aca382 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; + +/** + * Tests for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.BundleControlFactory}. + */ +@RunWith(MockitoJUnitRunner.class) +public class BundleControlFactoryTest { + + private OFDeserializer factory; + @Mock + DeserializerRegistry registry; + @Mock + OFDeserializer experimenterPropertyDeserializer; + + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, EncodeConstants.ONF_ET_BUNDLE_CONTROL)); + } + + @Test + public void testDeserializeWithoutProperties() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 01 " // bundle ID + + "00 01 " // type + + "00 03"); // flags + BundleControl builtByFactory = factory.deserialize(buffer); + Assert.assertEquals(1, builtByFactory.getBundleId().getValue().intValue()); + BundleFlags flags = new BundleFlags(true, true); + Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getFlags().isAtomic()); + Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getFlags().isOrdered()); + Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREPLY, builtByFactory.getType()); + Assert.assertTrue("Properties not empty", builtByFactory.getBundleProperty().isEmpty()); + } + + @Test + public void testDeserializeWithProperties() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 01 " // bundle ID + + "00 05 " // type + + "00 02 " // flags + + "ff ff " // type 1 + + "00 0c " // length 1 + + "00 00 00 01 " // experimenter ID 1 + + "00 00 00 02 " // experimenter type 1 + + "00 00 00 00 " // experimenter data 1 + + "00 00 " // type 2 + + "00 04 " // length 2 + + "00 00 00 00"); // data 2 + Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(experimenterPropertyDeserializer); + ((DeserializerRegistryInjector)factory).injectDeserializerRegistry(registry); + BundleControl builtByFactory = BufferHelper.deserialize(factory, buffer); + Assert.assertEquals(1, builtByFactory.getBundleId().getValue().intValue()); + BundleFlags flags = new BundleFlags(false, true); + Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getFlags().isAtomic()); + Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getFlags().isOrdered()); + Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREPLY, builtByFactory.getType()); + BundleProperty property = builtByFactory.getBundleProperty().get(0); + Assert.assertEquals("Wrong bundle property type", BundlePropertyType.ONFETBPTEXPERIMENTER, property.getType()); + BundleExperimenterProperty experimenterProperty = (BundleExperimenterProperty) property.getBundlePropertyEntry(); + Assert.assertEquals("Wrong experimenter ID", 1, experimenterProperty.getExperimenter().getValue().intValue()); + Assert.assertEquals("Wrong experimenter type", 2, experimenterProperty.getExpType().longValue()); + Mockito.verify(experimenterPropertyDeserializer, Mockito.times(1)).deserialize(buffer); + } + +} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java new file mode 100644 index 00000000..69891413 --- /dev/null +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; + +import io.netty.buffer.ByteBuf; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdError; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; + +/** + * Tests for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.OnfExperimenterErrorFactory}. + */ +public class OnfExperimenterErrorFactoryTest { + + private OFDeserializer factory; + + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( + EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID)); + } + + @Test + public void testVersion() { + ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 00 00 00 01"); + ErrorMessage builtByFactory = factory.deserialize(buffer); + BufferHelper.checkHeaderV13(builtByFactory); + } + + @Test + public void testDeserializeBase() { + ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 4f 4e 46 00"); + ErrorMessage builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong type", EncodeConstants.EXPERIMENTER_VALUE, builtByFactory.getType().intValue()); + Assert.assertEquals("Wrong type string", "EXPERIMENTER", builtByFactory.getTypeString()); + Assert.assertEquals("Wrong experimenter ID", EncodeConstants.ONF_EXPERIMENTER_ID, + builtByFactory.getAugmentation(ExperimenterIdError.class).getExperimenter().getValue().intValue()); + Assert.assertNull("Data is not null", builtByFactory.getData()); + } + + @Test + public void testDeserializeCodes() { + ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 00 00 00 01"); + ErrorMessage builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2300, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_UNKNOWN", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 08 fd 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2301, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_EPERM", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 08 fe 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2302, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_ID", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 08 ff 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2303, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_EXIST", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 00 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2304, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_CLOSED", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 01 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2305, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_OUT_OF_BUNDLES", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 02 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2306, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_TYPE", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 03 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2307, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_FLAGS", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 04 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2308, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_BAD_LEN", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 05 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2309, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_BAD_XID", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 06 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2310, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_UNSUP", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 07 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2311, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_CONFLICT", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 08 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2312, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_TOO_MANY", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 09 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2313, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_FAILED", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 0a 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2314, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_TIMEOUT", builtByFactory.getCodeString()); + + buffer = BufferHelper.buildBuffer("ff ff 09 0b 00 00 00 01"); + builtByFactory = factory.deserialize(buffer); + Assert.assertEquals("Wrong code", 2315, builtByFactory.getCode().intValue()); + Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_IN_PROGRESS", builtByFactory.getCodeString()); + } + +} \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index bbb9ee87..75ada6fb 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -10,6 +10,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -106,4 +107,15 @@ public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( short version, Long experimenterId) { return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); } + + /** + * @param version openflow wire version + * @param experimenterId experimenter ID + * @param type experimenter type according to vendor implementation + * @return key instance + */ + public static ExperimenterIdTypeDeserializerKey createBundlePropertyDeserializerKey( + short version, long experimenterId, long type) { + return new ExperimenterIdTypeDeserializerKey(version, experimenterId, type, BundleExperimenterPropertyData.class); + } } \ No newline at end of file From 8cf76973848254c17175f6fb5093ed069ea2805e Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Thu, 1 Dec 2016 09:28:46 +0100 Subject: [PATCH 259/285] Fix default/legacy openflow ports Change-Id: I9718d09c389689ec5fc0a45a4a116aabab15410e Signed-off-by: Andrej Leitner --- .../resources/initial/default-openflow-connection-config.xml | 2 +- .../resources/initial/legacy-openflow-connection-config.xml | 2 +- .../resources/org/opendaylight/blueprint/openflowjava.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml index 48f8bf55..08b8a52e 100644 --- a/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml +++ b/openflowjava-blueprint-config/src/main/resources/initial/default-openflow-connection-config.xml @@ -1,6 +1,6 @@ openflow-switch-connection-provider-default-impl - 6633 + 6653 TCP configuration/ssl/ctl.jks diff --git a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml index 7772ecc8..13860139 100644 --- a/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml +++ b/openflowjava-blueprint-config/src/main/resources/initial/legacy-openflow-connection-config.xml @@ -1,6 +1,6 @@ openflow-switch-connection-provider-legacy-impl - 6653 + 6633 TCP configuration/ssl/ctl.jks diff --git a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml index 2cd5a070..e1d3c000 100644 --- a/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml +++ b/openflowjava-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowjava.xml @@ -5,7 +5,7 @@ - + @@ -18,7 +18,7 @@ - + From 55ede46616f6b0e82f08fad5b168c9bd4f78fd4c Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Mon, 7 Mar 2016 14:29:07 +0100 Subject: [PATCH 260/285] Add test device connections utility Change-Id: I89933b0ce057679e959cf2ef576fe10c8a1cc122 Signed-off-by: Jozef Bacigal --- parent/pom.xml | 6 + simple-client/pom.xml | 4 + .../protocol/impl/clients/CallableClient.java | 119 ++++++++++ .../clients/ControllerConnectionTestTool.java | 207 ++++++++++++++++++ .../impl/clients/ScenarioFactory.java | 22 ++ .../impl/clients/ScenarioHandler.java | 22 +- .../impl/clients/WaitForMessageEvent.java | 8 +- 7 files changed, 383 insertions(+), 5 deletions(-) create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java diff --git a/parent/pom.xml b/parent/pom.xml index 00cfc5dc..5822d278 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -58,6 +58,7 @@ 1.5.0-SNAPSHOT 0.10.0-SNAPSHOT 1.1.0-SNAPSHOT + 0.7.0 @@ -90,6 +91,11 @@ import pom + + net.sourceforge.argparse4j + argparse4j + ${argparse4j.version} + diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 5eb462b5..76dd3575 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -45,5 +45,9 @@ org.slf4j slf4j-log4j12 + + net.sourceforge.argparse4j + argparse4j + diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java new file mode 100644 index 00000000..24b1da3c --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.net.InetAddress; +import java.util.concurrent.Callable; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.SettableFuture; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; +import org.slf4j.LoggerFactory; + + +/** + * Callable client class, inspired by SimpleClient class + * Simulating device/switch connected to controller + * @author Jozef Bacigal + * Date: 4.3.2016. + */ +public class CallableClient implements Callable, OFClient { + + private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(CallableClient.class); + + private int port = 6653; + private boolean securedClient = false; + private InetAddress ipAddress = null; + private String name = "Empty name"; + + private EventLoopGroup workerGroup; + private SettableFuture isOnlineFuture; + private SettableFuture scenarioDone; + private ScenarioHandler scenarioHandler = null; + private Bootstrap bootstrap = null; + + public CallableClient( + final int port, + final boolean securedClient, + final InetAddress ipAddress, + final String name, + final ScenarioHandler scenarioHandler, + final Bootstrap bootstrap, + final EventLoopGroup eventExecutors) { + + Preconditions.checkNotNull(ipAddress, "IP address cannot be null"); + Preconditions.checkNotNull(scenarioHandler, "Scenario handler cannot be null"); + this.port = port; + this.securedClient = securedClient; + this.ipAddress = ipAddress; + this.workerGroup = eventExecutors; + this.bootstrap = bootstrap; + this.name = name; + this.scenarioHandler = scenarioHandler; + } + + @Override + public SettableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + @Override + public SettableFuture getScenarioDone() { + return scenarioDone; + } + + @Override + public void setScenarioHandler(final ScenarioHandler scenario) { + this.scenarioHandler = scenario; + } + + @Override + public void setSecuredClient(final boolean securedClient) { + this.securedClient = securedClient; + } + + + @Override + public Boolean call() throws Exception { + Preconditions.checkNotNull(bootstrap); + Preconditions.checkNotNull(workerGroup); + LOG.info("Switch {} trying connect to controller", this.name); + SimpleClientInitializer clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient); + clientInitializer.setScenario(scenarioHandler); + try { + bootstrap.group(workerGroup) + .channel(NioSocketChannel.class) + .handler(clientInitializer); + + bootstrap.connect(ipAddress, port).sync(); + synchronized (scenarioHandler) { + LOG.debug("WAITING FOR SCENARIO"); + while (!scenarioHandler.isScenarioFinished()) { + scenarioHandler.wait(); + } + } + } catch (Exception ex) { + LOG.error(ex.getMessage(), ex); + return false; + } + if (scenarioHandler.isFinishedOK()) { + LOG.info("Device {} finished scenario OK", this.name); + } else { + LOG.error("Device {} finished scenario with error", this.name); + } + return scenarioHandler.isFinishedOK(); + + } + + @Override + public void run() { + throw new UnsupportedOperationException(); + } +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java new file mode 100644 index 00000000..67367b82 --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import static com.google.common.base.Preconditions.checkArgument; + +import javax.annotation.Nullable; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import net.sourceforge.argparse4j.ArgumentParsers; +import net.sourceforge.argparse4j.annotation.Arg; +import net.sourceforge.argparse4j.inf.ArgumentParser; +import net.sourceforge.argparse4j.inf.ArgumentParserException; +import org.slf4j.LoggerFactory; + +/** + * ControllerConnectionTestTool class, utilities for testing device's connect + * @author Jozef Bacigal + * Date: 4.3.2016. + */ +public class ControllerConnectionTestTool { + + private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ControllerConnectionTestTool.class); + + public static class Params { + + @Arg(dest = "controller-ip") + public String controllerIP; + + @Arg(dest = "devices-count") + public int deviceCount; + + @Arg(dest = "ssl") + public boolean ssl; + + @Arg(dest = "threads") + public int threads; + + @Arg(dest = "port") + public int port; + + @Arg(dest = "timeout") + public int timeout; + + @Arg(dest = "freeze") + public int freeze; + + @Arg(dest = "sleep") + public long sleep; + + static ArgumentParser getParser() throws UnknownHostException { + final ArgumentParser parser = ArgumentParsers.newArgumentParser("openflowjava test-tool"); + + parser.description("Openflowjava switch -> controller connector simulator"); + + parser.addArgument("--device-count") + .type(Integer.class) + .setDefault(1) + .help("Number of simulated switches. Has to be more than 0") + .dest("devices-count"); + + parser.addArgument("--controller-ip") + .type(String.class) + .setDefault("127.0.0.1") + .help("ODL controller ip address") + .dest("controller-ip"); + + parser.addArgument("--ssl") + .type(Boolean.class) + .setDefault(false) + .help("Use secured connection") + .dest("ssl"); + + parser.addArgument("--threads") + .type(Integer.class) + .setDefault(1) + .help("Number of threads: MAX 1024") + .dest("threads"); + + parser.addArgument("--port") + .type(Integer.class) + .setDefault(6653) + .help("Connection port") + .dest("port"); + + parser.addArgument("--timeout") + .type(Integer.class) + .setDefault(60) + .help("Timeout in seconds") + .dest("timeout"); + + parser.addArgument("--scenarioTries") + .type(Integer.class) + .setDefault(3) + .help("Number of tries in scenario, while waiting for response") + .dest("freeze"); + + parser.addArgument("--timeBetweenScenario") + .type(Long.class) + .setDefault(100) + .help("Waiting time in milliseconds between tries.") + .dest("sleep"); + + return parser; + } + + void validate() { + checkArgument(deviceCount > 0, "Switch count has to be > 0"); + checkArgument(threads > 0 && threads < 1024, "Switch count has to be > 0 and < 1024"); + } + } + + public static void main(final String[] args) { + + List> callableList = new ArrayList<>(); + final EventLoopGroup workerGroup = new NioEventLoopGroup(); + + try { + final Params params = parseArgs(args, Params.getParser()); + params.validate(); + + for(int loop=0;loop < params.deviceCount; loop++){ + + CallableClient cc = new CallableClient( + params.port, + params.ssl, + InetAddress.getByName(params.controllerIP), + "Switch no." + String.valueOf(loop), + new ScenarioHandler(ScenarioFactory.createHandshakeScenarioWithBarrier(), params.freeze, params.sleep), + new Bootstrap(), + workerGroup); + + callableList.add(cc); + + } + + ExecutorService executorService = Executors.newFixedThreadPool(params.threads); + final ListeningExecutorService listeningExecutorService = MoreExecutors.listeningDecorator(executorService); + + final List> listenableFutures = new ArrayList<>(); + for (Callable booleanCallable : callableList) { + listenableFutures.add(listeningExecutorService.submit(booleanCallable)); + } + final ListenableFuture> summaryFuture = Futures.successfulAsList(listenableFutures); + List booleanList = summaryFuture.get(params.timeout, TimeUnit.SECONDS); + Futures.addCallback(summaryFuture, new FutureCallback>() { + @Override + public void onSuccess(@Nullable final List booleanList) { + LOG.info("Tests finished"); + workerGroup.shutdownGracefully(); + LOG.info("Summary:"); + int testsOK = 0; + int testFailure = 0; + for (Boolean aBoolean : booleanList) { + if (aBoolean) { + testsOK++; + } else { + testFailure++; + } + } + LOG.info("Tests OK: {}", testsOK); + LOG.info("Tests failure: {}", testFailure); + System.exit(0); + } + + @Override + public void onFailure(final Throwable throwable) { + LOG.warn("Tests call failure"); + workerGroup.shutdownGracefully(); + System.exit(1); + } + }); + } catch (Exception e) { + LOG.warn("Exception has been thrown: {}", e); + System.exit(1); + } + } + + private static Params parseArgs(final String[] args, final ArgumentParser parser) throws ArgumentParserException { + final Params opt = new Params(); + parser.parseArgs(args, opt); + return opt; + } + + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 5b4e669a..4e28c4cd 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -44,6 +44,28 @@ public static Deque createHandshakeScenario() { return stack; } + /** + * Creates stack with handshake needed messages. XID of messages: + *
            + *
          1. hello sent - 00000001 + *
          2. hello waiting - 00000021 + *
          3. featuresrequest waiting - 00000002 + *
          4. featuresreply sent - 00000002 + *
          + * @return stack filled with Handshake messages + */ + public static Deque createHandshakeScenarioWithBarrier() { + Deque stack = new ArrayDeque<>(); + stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01"))); + stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12"))); //Hello message 21 + stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02"))); + stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 02 " + + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03"))); + stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 14 00 08 00 00 00 00"))); //Barrier request + stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 15 00 08 00 00 00 04"))); //Barrier reply + return stack; + } + /** * Creates stack with handshake needed messages. XID of messages: *
            diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 44abb36d..9692cb8e 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -31,6 +31,9 @@ public class ScenarioHandler extends Thread { private ChannelHandlerContext ctx; private int eventNumber; private boolean scenarioFinished = false; + private int freeze = 2; + private long sleepBetweenTries = 100l; + private boolean finishedOK = true; /** * @@ -41,6 +44,13 @@ public ScenarioHandler(Deque scenario) { ofMsg = new LinkedBlockingQueue<>(); } + public ScenarioHandler(Deque scenario, int freeze, long sleepBetweenTries){ + this.scenario = scenario; + ofMsg = new LinkedBlockingQueue<>(); + this.sleepBetweenTries = sleepBetweenTries; + this.freeze = freeze; + } + @Override public void run() { int freezeCounter = 0; @@ -62,18 +72,22 @@ public void run() { event.setCtx(ctx); } if (peek.eventExecuted()) { + LOG.info("Scenario step finished OK, moving to next step."); scenario.removeLast(); eventNumber++; freezeCounter = 0; + finishedOK = true; } else { freezeCounter++; } - if (freezeCounter > 2) { + if (freezeCounter > freeze) { LOG.warn("Scenario frozen: {}", freezeCounter); + LOG.warn("Scenario step not finished NOT OK!", freezeCounter); + this.finishedOK = false; break; } try { - sleep(100); + sleep(sleepBetweenTries); } catch (InterruptedException e) { LOG.error(e.getMessage(), e); } @@ -126,4 +140,8 @@ public void addOfMsg(byte[] message) { public boolean isScenarioFinished() { return scenarioFinished; } + + public boolean isFinishedOK() { + return finishedOK; + } } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index 59228e36..f57b738f 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -54,9 +54,11 @@ public boolean eventExecuted() { * @param headerReceived header (first 8 bytes) of expected message */ public void setHeaderReceived(byte[] headerReceived) { - this.headerReceived = new byte[headerReceived.length]; - for (int i = 0; i < headerReceived.length; i++) { - this.headerReceived[i] = headerReceived[i]; + if (headerReceived != null) { + this.headerReceived = new byte[headerReceived.length]; + for (int i = 0; i < headerReceived.length; i++) { + this.headerReceived[i] = headerReceived[i]; + } } } } From 507241523b0a175d1a807a3e56d4c5b2d3000d6f Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Mon, 7 Mar 2016 14:29:07 +0100 Subject: [PATCH 261/285] Update utility to test device connections * Helper class to defining command line parameters * Parameters: * --device-count : number of devices connection to the controller * --controller-ip : controller IP address * --ssl : * --threads : number of thread shall be used for executor * --port * --timeout : timeout in seconds for whole test * --scenarioTries : number of tries of each step of scenario * --timeBetweenScenario : time in milliseconds between tries of steps of scenario * --configurationName : required parameter if using configuration load or configuration save * --configurationLoad * --configurationSave 3/9/16 - Checkstyle corrections Change-Id: Iec24bf37bb6cce534ce87ca80585d0f53d0dd638 Signed-off-by: Jozef Bacigal Signed-off-by: Jozef Bacigal --- .../openflowjava/tools/ConfigurationType.java | 162 ++++++++++++++ .../openflowjava/tools/Configurations.java | 58 +++++ .../ConnectionToolConfigurationService.java | 39 ++++ ...onnectionToolConfigurationServiceImpl.java | 127 +++++++++++ .../openflowjava/tools/ObjectFactory.java | 48 ++++ .../src/main/resources/configuration.xml | 23 ++ .../src/main/resources/configuration.xsd | 32 +++ .../clients/ControllerConnectionTestTool.java | 207 ------------------ 8 files changed, 489 insertions(+), 207 deletions(-) create mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConfigurationType.java create mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/Configurations.java create mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationService.java create mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java create mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java create mode 100644 openflowjava-tools/src/main/resources/configuration.xml create mode 100644 openflowjava-tools/src/main/resources/configuration.xsd delete mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConfigurationType.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConfigurationType.java new file mode 100644 index 00000000..3b7bc68a --- /dev/null +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConfigurationType.java @@ -0,0 +1,162 @@ + +package org.opendaylight.openflowjava.tools; + +import java.math.BigInteger; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for configurationType complex type. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "configurationType", propOrder = { + "controllerIp", + "devicesCount", + "ssl", + "threads", + "port", + "timeout", + "freeze", + "sleep" +}) +public class ConfigurationType { + + @XmlElement(name = "controller-ip", required = true, defaultValue = "127.0.0.1") + String controllerIp; + @XmlElement(name = "devices-count", required = true, defaultValue = "1") + @XmlSchemaType(name = "positiveInteger") + BigInteger devicesCount; + @XmlElement(defaultValue = "false") + Boolean ssl; + @XmlElement(defaultValue = "1") + @XmlSchemaType(name = "positiveInteger") + BigInteger threads; + @XmlElement(required = true, defaultValue = "6653") + @XmlSchemaType(name = "positiveInteger") + BigInteger port; + @XmlElement(defaultValue = "1000") + @XmlSchemaType(name = "positiveInteger") + BigInteger timeout; + @XmlElement(defaultValue = "3") + @XmlSchemaType(name = "positiveInteger") + BigInteger freeze; + @XmlElement(defaultValue = "100") + Long sleep; + @XmlAttribute(name = "name", required = true) + String name; + + /** + * Gets the value of the controllerIp property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getControllerIp() { + return controllerIp; + } + + /** + * Gets the value of the devicesCount property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getDevicesCount() { + return devicesCount; + } + + /** + * Gets the value of the ssl property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSsl() { + return ssl; + } + + /** + * Gets the value of the threads property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getThreads() { + return threads; + } + + /** + * Gets the value of the port property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getPort() { + return port; + } + + /** + * Gets the value of the timeout property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getTimeout() { + return timeout; + } + + /** + * Gets the value of the freeze property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getFreeze() { + return freeze; + } + + /** + * Gets the value of the sleep property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getSleep() { + return sleep; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + +} diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/Configurations.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/Configurations.java new file mode 100644 index 00000000..5f284e57 --- /dev/null +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/Configurations.java @@ -0,0 +1,58 @@ + +package org.opendaylight.openflowjava.tools; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for anonymous complex type. + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "configuration" +}) +@XmlRootElement(name = "configurations") +public class Configurations { + + @XmlElement(required = true) + private List configuration; + + /** + * Gets the value of the configuration property. + * + *

            + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the configuration property. + * + *

            + * For example, to add a new item, do as follows: + *

            +     *    getConfiguration().add(newItem);
            +     * 
            + * + * + *

            + * Objects of the following type(s) are allowed in the list + * {@link ConfigurationType } + * + * + */ + public List getConfiguration() { + if (configuration == null) { + configuration = new ArrayList<>(); + } + return this.configuration; + } + + public void setConfiguration(List configuration) { + this.configuration = configuration; + } +} diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationService.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationService.java new file mode 100644 index 00000000..6733afd7 --- /dev/null +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationService.java @@ -0,0 +1,39 @@ +package org.opendaylight.openflowjava.tools; + +import org.xml.sax.SAXException; + +import javax.xml.bind.JAXBException; + +/** + * + * @author Jozef Bacigal + * Date: 8.3.2016 + */ +interface ConnectionToolConfigurationService { + + + String OPENFLOWJAVA_TOOLS_SRC_MAIN_RESOURCES = "openflowjava-tools/src/main/resources/"; + String OPENFLOWJAVA_TOOLS_SRC_MAIN_RESOURCES1 = "openflowjava-tools/src/main/resources/"; + String CONFIGURATION_XSD = "configuration.xsd"; + String CONFIGURATION_XML = "configuration.xml"; + String XML_FILE_PATH_WITH_FILE_NAME = OPENFLOWJAVA_TOOLS_SRC_MAIN_RESOURCES + CONFIGURATION_XML; + String XSD_SCHEMA_PATH_WITH_FILE_NAME = OPENFLOWJAVA_TOOLS_SRC_MAIN_RESOURCES1 + CONFIGURATION_XSD; + + /** + * Method to save configuration into XML configuration file + * @param params {@link ConnectionTestTool.Params} + * @param configurationName {@link String} + * @throws JAXBException + * @throws SAXException + */ + void marshallData(ConnectionTestTool.Params params, String configurationName) throws JAXBException, SAXException; + + /** + * Method to load data from XML configuration file. Each configuration has a name. + * @param configurationName {@link String} + * @return parameters + * @throws SAXException + * @throws JAXBException + */ + ConnectionTestTool.Params unMarshallData(String configurationName) throws SAXException, JAXBException; +} diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java new file mode 100644 index 00000000..4a486def --- /dev/null +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java @@ -0,0 +1,127 @@ +package org.opendaylight.openflowjava.tools; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; +import java.math.BigInteger; +import java.util.List; + +/** + * @author Jozef Bacigal + * Date: 8.3.2016 + */ +public class ConnectionToolConfigurationServiceImpl implements ConnectionToolConfigurationService { + + private static final Logger LOG = LoggerFactory.getLogger(ConnectionToolConfigurationServiceImpl.class); + + @Override + public void marshallData(ConnectionTestTool.Params params, String configurationName) throws JAXBException, SAXException { + File file = new File(XML_FILE_PATH_WITH_FILE_NAME); + LOG.info("Marshaling configuration data to: {}", XML_FILE_PATH_WITH_FILE_NAME); + + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(new File(XSD_SCHEMA_PATH_WITH_FILE_NAME)); + LOG.info("with schema: {}", XSD_SCHEMA_PATH_WITH_FILE_NAME); + + JAXBContext jaxbContext = JAXBContext.newInstance(Configurations.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); + + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, CONFIGURATION_XSD); + + jaxbMarshaller.setSchema(schema); + + ObjectFactory objectFactory = new ObjectFactory(); + Configurations configurations = objectFactory.createConfigurations(); + + List configurationTypes = configurations.getConfiguration(); + + for (ConfigurationType configurationType : this.getSavedConfigurations()) { + configurationTypes.add(configurationType); + } + + ConfigurationType configurationType = new ConfigurationType(); + configurationType.name = configurationName; + + configurationType.controllerIp = params.controllerIP; + configurationType.devicesCount = BigInteger.valueOf(params.deviceCount); + configurationType.freeze = BigInteger.valueOf(params.freeze); + configurationType.port = BigInteger.valueOf(params.port); + configurationType.sleep = params.sleep; + configurationType.ssl = params.ssl; + configurationType.threads = BigInteger.valueOf(params.threads); + configurationType.timeout = BigInteger.valueOf(params.timeout); + + configurationTypes.add(configurationType); + + configurations.setConfiguration(configurationTypes); + jaxbMarshaller.marshal(configurations, file); + + } + + @Override + public ConnectionTestTool.Params unMarshallData(String configurationName) throws SAXException, JAXBException { + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(new File(XSD_SCHEMA_PATH_WITH_FILE_NAME)); + LOG.debug("Loading schema from: {}", XSD_SCHEMA_PATH_WITH_FILE_NAME); + + JAXBContext jc = JAXBContext.newInstance(Configurations.class); + + Unmarshaller unmarshaller = jc.createUnmarshaller(); + unmarshaller.setSchema(schema); + + Configurations configurations = (Configurations) unmarshaller.unmarshal(new File(XML_FILE_PATH_WITH_FILE_NAME)); + LOG.debug("Configurations ({}) are un-marshaled from {}", configurations.getConfiguration().size(), XML_FILE_PATH_WITH_FILE_NAME); + + boolean foundConfiguration = false; + ConfigurationType configuration = null; + for (ConfigurationType configurationType : configurations.getConfiguration()) { + if (configurationType.getName().equals(configurationName)) { + configuration = configurationType; + foundConfiguration = true; + } + } + ConnectionTestTool.Params params = null; + if (foundConfiguration) { + LOG.info("Configuration {} found, loading parameters.", configurationName); + params = new ConnectionTestTool.Params(); + params.controllerIP = configuration.getControllerIp(); + params.deviceCount = configuration.getDevicesCount().intValue(); + params.freeze = configuration.getFreeze().intValue(); + params.port = configuration.getPort().intValue(); + params.sleep = configuration.getSleep(); + params.ssl = configuration.isSsl(); + params.threads = configuration.getThreads().intValue(); + params.timeout = configuration.getTimeout().intValue(); + } else { + LOG.warn("Configuration {} not found. Using default parameters.", configurationName); + } + + return params; + } + + private List getSavedConfigurations() throws SAXException, JAXBException{ + + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(new File(XSD_SCHEMA_PATH_WITH_FILE_NAME)); + + JAXBContext jc = JAXBContext.newInstance(Configurations.class); + + Unmarshaller unmarshaller = jc.createUnmarshaller(); + unmarshaller.setSchema(schema); + + Configurations configurations = (Configurations) unmarshaller.unmarshal(new File(XML_FILE_PATH_WITH_FILE_NAME)); + + return configurations.getConfiguration(); + + } +} diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java new file mode 100644 index 00000000..48c782e2 --- /dev/null +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java @@ -0,0 +1,48 @@ + +package org.opendaylight.openflowjava.tools; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.opendaylight.openflowjava.tools package. + *

            An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.opendaylight.openflowjava.tools + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Configurations } + * + */ + public Configurations createConfigurations() { + return new Configurations(); + } + + /** + * Create an instance of {@link ConfigurationType } + * + */ + public ConfigurationType createConfigurationType() { + return new ConfigurationType(); + } + +} diff --git a/openflowjava-tools/src/main/resources/configuration.xml b/openflowjava-tools/src/main/resources/configuration.xml new file mode 100644 index 00000000..55ecd9b8 --- /dev/null +++ b/openflowjava-tools/src/main/resources/configuration.xml @@ -0,0 +1,23 @@ + + + + 127.0.0.1 + 30 + false + 100 + 6653 + 1000 + 2 + 100 + + + 127.0.0.1 + 1 + false + 1 + 6653 + 1000 + 3 + 100 + + diff --git a/openflowjava-tools/src/main/resources/configuration.xsd b/openflowjava-tools/src/main/resources/configuration.xsd new file mode 100644 index 00000000..dcbb49f1 --- /dev/null +++ b/openflowjava-tools/src/main/resources/configuration.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java deleted file mode 100644 index 67367b82..00000000 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ControllerConnectionTestTool.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.clients; - -import static com.google.common.base.Preconditions.checkArgument; - -import javax.annotation.Nullable; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import net.sourceforge.argparse4j.ArgumentParsers; -import net.sourceforge.argparse4j.annotation.Arg; -import net.sourceforge.argparse4j.inf.ArgumentParser; -import net.sourceforge.argparse4j.inf.ArgumentParserException; -import org.slf4j.LoggerFactory; - -/** - * ControllerConnectionTestTool class, utilities for testing device's connect - * @author Jozef Bacigal - * Date: 4.3.2016. - */ -public class ControllerConnectionTestTool { - - private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ControllerConnectionTestTool.class); - - public static class Params { - - @Arg(dest = "controller-ip") - public String controllerIP; - - @Arg(dest = "devices-count") - public int deviceCount; - - @Arg(dest = "ssl") - public boolean ssl; - - @Arg(dest = "threads") - public int threads; - - @Arg(dest = "port") - public int port; - - @Arg(dest = "timeout") - public int timeout; - - @Arg(dest = "freeze") - public int freeze; - - @Arg(dest = "sleep") - public long sleep; - - static ArgumentParser getParser() throws UnknownHostException { - final ArgumentParser parser = ArgumentParsers.newArgumentParser("openflowjava test-tool"); - - parser.description("Openflowjava switch -> controller connector simulator"); - - parser.addArgument("--device-count") - .type(Integer.class) - .setDefault(1) - .help("Number of simulated switches. Has to be more than 0") - .dest("devices-count"); - - parser.addArgument("--controller-ip") - .type(String.class) - .setDefault("127.0.0.1") - .help("ODL controller ip address") - .dest("controller-ip"); - - parser.addArgument("--ssl") - .type(Boolean.class) - .setDefault(false) - .help("Use secured connection") - .dest("ssl"); - - parser.addArgument("--threads") - .type(Integer.class) - .setDefault(1) - .help("Number of threads: MAX 1024") - .dest("threads"); - - parser.addArgument("--port") - .type(Integer.class) - .setDefault(6653) - .help("Connection port") - .dest("port"); - - parser.addArgument("--timeout") - .type(Integer.class) - .setDefault(60) - .help("Timeout in seconds") - .dest("timeout"); - - parser.addArgument("--scenarioTries") - .type(Integer.class) - .setDefault(3) - .help("Number of tries in scenario, while waiting for response") - .dest("freeze"); - - parser.addArgument("--timeBetweenScenario") - .type(Long.class) - .setDefault(100) - .help("Waiting time in milliseconds between tries.") - .dest("sleep"); - - return parser; - } - - void validate() { - checkArgument(deviceCount > 0, "Switch count has to be > 0"); - checkArgument(threads > 0 && threads < 1024, "Switch count has to be > 0 and < 1024"); - } - } - - public static void main(final String[] args) { - - List> callableList = new ArrayList<>(); - final EventLoopGroup workerGroup = new NioEventLoopGroup(); - - try { - final Params params = parseArgs(args, Params.getParser()); - params.validate(); - - for(int loop=0;loop < params.deviceCount; loop++){ - - CallableClient cc = new CallableClient( - params.port, - params.ssl, - InetAddress.getByName(params.controllerIP), - "Switch no." + String.valueOf(loop), - new ScenarioHandler(ScenarioFactory.createHandshakeScenarioWithBarrier(), params.freeze, params.sleep), - new Bootstrap(), - workerGroup); - - callableList.add(cc); - - } - - ExecutorService executorService = Executors.newFixedThreadPool(params.threads); - final ListeningExecutorService listeningExecutorService = MoreExecutors.listeningDecorator(executorService); - - final List> listenableFutures = new ArrayList<>(); - for (Callable booleanCallable : callableList) { - listenableFutures.add(listeningExecutorService.submit(booleanCallable)); - } - final ListenableFuture> summaryFuture = Futures.successfulAsList(listenableFutures); - List booleanList = summaryFuture.get(params.timeout, TimeUnit.SECONDS); - Futures.addCallback(summaryFuture, new FutureCallback>() { - @Override - public void onSuccess(@Nullable final List booleanList) { - LOG.info("Tests finished"); - workerGroup.shutdownGracefully(); - LOG.info("Summary:"); - int testsOK = 0; - int testFailure = 0; - for (Boolean aBoolean : booleanList) { - if (aBoolean) { - testsOK++; - } else { - testFailure++; - } - } - LOG.info("Tests OK: {}", testsOK); - LOG.info("Tests failure: {}", testFailure); - System.exit(0); - } - - @Override - public void onFailure(final Throwable throwable) { - LOG.warn("Tests call failure"); - workerGroup.shutdownGracefully(); - System.exit(1); - } - }); - } catch (Exception e) { - LOG.warn("Exception has been thrown: {}", e); - System.exit(1); - } - } - - private static Params parseArgs(final String[] args, final ArgumentParser parser) throws ArgumentParserException { - final Params opt = new Params(); - parser.parseArgs(args, opt); - return opt; - } - - -} From 1d319215f6fc1d47bd521f8241e569bede132347 Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Wed, 9 Mar 2016 15:11:42 +0100 Subject: [PATCH 262/285] Scenarios in XML files -prepared XSD file -updated scenarioFactory -added types for unmarshaling XML -added new parameter to testing tool --xmlScenarioFile 03/15/2016 -renamed ScenarioType to Scenario -renamed StepType to Step Change-Id: I169f6b40e65e80533e6cc3a1978bb34f84164abc Signed-off-by: Jozef Bacigal Signed-off-by: Jozef Bacigal --- ...onnectionToolConfigurationServiceImpl.java | 3 +- .../openflowjava/tools/ObjectFactory.java | 48 -------- .../openflowjava/util/ByteBufUtils.java | 11 ++ .../protocol/impl/clients/CallableClient.java | 2 +- .../impl/clients/ClientSslContextFactory.java | 2 +- .../protocol/impl/clients/EventType.java | 41 +++++++ .../protocol/impl/clients/Scenario.java | 80 +++++++++++++ .../impl/clients/ScenarioFactory.java | 30 ++++- .../impl/clients/ScenarioHandler.java | 6 +- .../impl/clients/ScenarioService.java | 33 ++++++ .../impl/clients/ScenarioServiceImpl.java | 81 +++++++++++++ .../protocol/impl/clients/Scenarios.java | 51 +++++++++ .../protocol/impl/clients/SendEvent.java | 4 +- .../impl/clients/SimpleClientInitializer.java | 2 +- .../protocol/impl/clients/Step.java | 108 ++++++++++++++++++ .../impl/clients/WaitForMessageEvent.java | 8 +- simple-client/src/main/resources/scenario.xml | 42 +++++++ simple-client/src/main/resources/scenario.xsd | 40 +++++++ 18 files changed, 521 insertions(+), 71 deletions(-) delete mode 100644 openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/EventType.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenario.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioService.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenarios.java create mode 100644 simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Step.java create mode 100644 simple-client/src/main/resources/scenario.xml create mode 100644 simple-client/src/main/resources/scenario.xsd diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java index 4a486def..f309a7dd 100644 --- a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java +++ b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ConnectionToolConfigurationServiceImpl.java @@ -40,8 +40,7 @@ public void marshallData(ConnectionTestTool.Params params, String configurationN jaxbMarshaller.setSchema(schema); - ObjectFactory objectFactory = new ObjectFactory(); - Configurations configurations = objectFactory.createConfigurations(); + Configurations configurations = new Configurations(); List configurationTypes = configurations.getConfiguration(); diff --git a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java b/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java deleted file mode 100644 index 48c782e2..00000000 --- a/openflowjava-tools/src/main/java/org/opendaylight/openflowjava/tools/ObjectFactory.java +++ /dev/null @@ -1,48 +0,0 @@ - -package org.opendaylight.openflowjava.tools; - -import javax.xml.bind.annotation.XmlRegistry; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.opendaylight.openflowjava.tools package. - *

            An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -class ObjectFactory { - - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.opendaylight.openflowjava.tools - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link Configurations } - * - */ - public Configurations createConfigurations() { - return new Configurations(); - } - - /** - * Create an instance of {@link ConfigurationType } - * - */ - public ConfigurationType createConfigurationType() { - return new ConfigurationType(); - } - -} diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index f9ed9fb3..66c4272e 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -15,6 +15,10 @@ import com.google.common.primitives.UnsignedBytes; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -366,4 +370,11 @@ public static MacAddress readIetfMacAddress(final ByteBuf buf) { buf.readBytes(tmp); return IetfYangUtil.INSTANCE.macAddressFor(tmp); } + + public static byte[] serializableList(final List list) throws IOException{ + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(list); + return byteArrayOutputStream.toByteArray(); + } } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java index 24b1da3c..67142e38 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java @@ -33,7 +33,7 @@ public class CallableClient implements Callable, OFClient { private InetAddress ipAddress = null; private String name = "Empty name"; - private EventLoopGroup workerGroup; + private final EventLoopGroup workerGroup; private SettableFuture isOnlineFuture; private SettableFuture scenarioDone; private ScenarioHandler scenarioHandler = null; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java index 9b46d6c0..64217d8e 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java @@ -64,7 +64,7 @@ private ClientSslContextFactory() { } /** - * @return cliencontext + * @return client context */ public static SSLContext getClientContext() { return CLIENT_CONTEXT; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/EventType.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/EventType.java new file mode 100644 index 00000000..ff83c6bf --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/EventType.java @@ -0,0 +1,41 @@ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for eventType. + */ +@XmlType(name = "eventType") +@XmlEnum +public enum EventType { + + @XmlEnumValue("sleepEvent") + SLEEP_EVENT("sleepEvent"), + @XmlEnumValue("waitForMessageEvent") + WAIT_FOR_MESSAGE_EVENT("waitForMessageEvent"), + @XmlEnumValue("sendEvent") + SEND_EVENT("sendEvent"); + private final String value; + + EventType(String v) { + value = v; + } + + public String value() { + return value; + } + + public static EventType fromValue(String v) { + for (EventType c: EventType.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenario.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenario.java new file mode 100644 index 00000000..f11890ba --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenario.java @@ -0,0 +1,80 @@ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for scenarioType complex type. + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "scenario", propOrder = { + "step" +}) +public class Scenario { + + @XmlElement(required = true) + protected List step; + @XmlAttribute(name = "name", required = true) + protected String name; + + /** + * Gets the value of the step property. + * + *

            + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the step property. + * + *

            + * For example, to add a new item, do as follows: + *

            +     *    getStep().add(newItem);
            +     * 
            + * + * + *

            + * Objects of the following type(s) are allowed in the list + * {@link Step } + * + * + */ + public List getStep() { + if (step == null) { + step = new ArrayList<>(); + } + return this.step; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java index 4e28c4cd..3e01cfa5 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java @@ -8,10 +8,15 @@ package org.opendaylight.openflowjava.protocol.impl.clients; +import java.io.IOException; import java.util.ArrayDeque; import java.util.Deque; +import java.util.Map; import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.xml.sax.SAXException; + +import javax.xml.bind.JAXBException; /** * Class for providing prepared handshake scenario @@ -29,8 +34,8 @@ private ScenarioFactory() { *

              *
            1. hello sent - 00000001 *
            2. hello waiting - 00000002 - *
            3. featuresrequest waiting - 00000003 - *
            4. featuresreply sent - 00000003 + *
            5. features request waiting - 00000003 + *
            6. features reply sent - 00000003 *
            * @return stack filled with Handshake messages */ @@ -49,8 +54,8 @@ public static Deque createHandshakeScenario() { *
              *
            1. hello sent - 00000001 *
            2. hello waiting - 00000021 - *
            3. featuresrequest waiting - 00000002 - *
            4. featuresreply sent - 00000002 + *
            5. features request waiting - 00000002 + *
            6. features reply sent - 00000002 *
            * @return stack filled with Handshake messages */ @@ -66,13 +71,26 @@ public static Deque createHandshakeScenarioWithBarrier() { return stack; } + /** + * Creates stack from XML file + * @return stack filled with Handshake messages + */ + public static Deque getScenarioFromXml(String scenarioName, String scenarioFile) throws JAXBException, SAXException, IOException { + ScenarioService scenarioService = new ScenarioServiceImpl(scenarioFile); + Deque stack = new ArrayDeque<>(); + for (Map.Entry clientEvent : scenarioService.getEventsFromScenario(scenarioService.unMarshallData(scenarioName)).entrySet()) { + stack.addFirst(clientEvent.getValue()); + } + return stack; + } + /** * Creates stack with handshake needed messages. XID of messages: *
              *
            1. hello sent - 00000001 *
            2. hello waiting - 00000002 - *
            3. featuresrequest waiting - 00000003 - *
            4. featuresreply sent - 00000003 + *
            5. features request waiting - 00000003 + *
            6. features reply sent - 00000003 *
            * @param auxiliaryId auxiliaryId wanted in featuresReply message * @return stack filled with Handshake messages (featuresReply with auxiliaryId set) diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 9692cb8e..88fd9b64 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -27,17 +27,17 @@ public class ScenarioHandler extends Thread { private static final Logger LOG = LoggerFactory.getLogger(ScenarioHandler.class); private Deque scenario; - private BlockingQueue ofMsg; + private final BlockingQueue ofMsg; private ChannelHandlerContext ctx; private int eventNumber; private boolean scenarioFinished = false; private int freeze = 2; - private long sleepBetweenTries = 100l; + private long sleepBetweenTries = 100L; private boolean finishedOK = true; /** * - * @param scenario + * @param scenario {@link Deque} */ public ScenarioHandler(Deque scenario) { this.scenario = scenario; diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioService.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioService.java new file mode 100644 index 00000000..0221acfc --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioService.java @@ -0,0 +1,33 @@ +package org.opendaylight.openflowjava.protocol.impl.clients; + +import org.xml.sax.SAXException; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.util.SortedMap; + +/** + * + * @author Jozef Bacigal + * Date: 8.3.2016 + */ +interface ScenarioService { + + String SIMPLE_CLIENT_SRC_MAIN_RESOURCES = "simple-client/src/main/resources/"; + String SIMPLE_CLIENT_SRC_MAIN_RESOURCES1 = "simple-client/src/main/resources/"; + String SCENARIO_XSD = "scenario.xsd"; + String SCENARIO_XML = "scenario.xml"; + String XSD_SCHEMA_PATH_WITH_FILE_NAME = SIMPLE_CLIENT_SRC_MAIN_RESOURCES1 + SCENARIO_XSD; + + /** + * Method to load data from XML configuration file. Each configuration has a name. + * @param scenarioName {@link String} + * @return scenarios + * @throws SAXException + * @throws JAXBException + */ + Scenario unMarshallData(String scenarioName) throws SAXException, JAXBException; + + SortedMap getEventsFromScenario(Scenario scenario) throws IOException; + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java new file mode 100644 index 00000000..897cc698 --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java @@ -0,0 +1,81 @@ +package org.opendaylight.openflowjava.protocol.impl.clients; + +import com.google.common.base.Preconditions; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import java.io.File; +import java.io.IOException; +import java.util.*; + +/** + * @author Jozef Bacigal + * Date: 9.3.2016 + */ +public class ScenarioServiceImpl implements ScenarioService { + + private static final Logger LOG = LoggerFactory.getLogger(ScenarioServiceImpl.class); + + private String XML_FILE_PATH_WITH_FILE_NAME = SIMPLE_CLIENT_SRC_MAIN_RESOURCES + SCENARIO_XML; + + public ScenarioServiceImpl(String scenarioFile){ + if (null != scenarioFile && !scenarioFile.isEmpty()) { + this.XML_FILE_PATH_WITH_FILE_NAME = scenarioFile; + } + } + + @Override + public Scenario unMarshallData(String scenarioName) throws SAXException, JAXBException { + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(new File(XSD_SCHEMA_PATH_WITH_FILE_NAME)); + LOG.debug("Loading schema from: {}", XSD_SCHEMA_PATH_WITH_FILE_NAME); + + JAXBContext jc = JAXBContext.newInstance(Scenarios.class); + + Unmarshaller unmarshaller = jc.createUnmarshaller(); + unmarshaller.setSchema(schema); + + Scenarios scenarios = (Scenarios) unmarshaller.unmarshal(new File(XML_FILE_PATH_WITH_FILE_NAME)); + LOG.debug("Scenarios ({}) are un-marshaled from {}", scenarios.getScenario().size(), XML_FILE_PATH_WITH_FILE_NAME); + + boolean foundConfiguration = false; + Scenario scenarioType = null; + for (Scenario scenario : scenarios.getScenario()) { + if (scenario.getName().equals(scenarioName)) { + scenarioType = scenario; + foundConfiguration = true; + } + } + if (!foundConfiguration) { + LOG.warn("Scenario {} not found.", scenarioName); + } else { + LOG.info("Scenario {} found with {} steps.", scenarioName, scenarioType.getStep().size()); + } + return scenarioType; + } + + @Override + public SortedMap getEventsFromScenario(Scenario scenario) throws IOException { + Preconditions.checkNotNull(scenario, "Scenario name not found. Check XML file, scenario name or directories."); + SortedMap events = new TreeMap<>(); + Integer counter = 0; + for (Step stepType : scenario.getStep()) { + LOG.debug("Step {}: {}, type {}, bytes {}", stepType.getOrder(), stepType.getName(), stepType.getEvent().value(), stepType.getBytes().toArray()); + switch (stepType.getEvent()) { + case SLEEP_EVENT: events.put(counter++, new SleepEvent(1000)); break; + case SEND_EVENT: events.put(counter++, new SendEvent(ByteBufUtils.serializableList(stepType.getBytes()))); break; + case WAIT_FOR_MESSAGE_EVENT: events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializableList(stepType.getBytes()))); break; + } + } + return events; + } + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenarios.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenarios.java new file mode 100644 index 00000000..5fcaa80e --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenarios.java @@ -0,0 +1,51 @@ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for anonymous complex type. + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "scenario" +}) +@XmlRootElement(name = "scenarios") +public class Scenarios { + + @XmlElement(required = true) + protected List scenario; + + /** + * Gets the value of the scenario property. + * + *

            + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the scenario property. + * + *

            + * For example, to add a new item, do as follows: + *

            +     *    getScenario().add(newItem);
            +     * 
            + *

            + * Objects of the following type(s) are allowed in the list + * {@link Scenario } + */ + public List getScenario() { + if (scenario == null) { + scenario = new ArrayList<>(); + } + return this.scenario; + } + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java index 9318d231..98934f08 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java @@ -31,9 +31,7 @@ public class SendEvent implements ClientEvent { */ public SendEvent(byte[] msgToSend) { this.msgToSend = new byte[msgToSend.length]; - for (int i = 0; i < msgToSend.length; i++) { - this.msgToSend[i] = msgToSend[i]; - } + System.arraycopy(msgToSend, 0, this.msgToSend, 0, msgToSend.length); } @Override diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java index 98a6e1ff..21afc08b 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java @@ -25,7 +25,7 @@ public class SimpleClientInitializer extends ChannelInitializer { private SettableFuture isOnlineFuture; - private boolean secured; + private final boolean secured; private ScenarioHandler scenarioHandler; /** diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Step.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Step.java new file mode 100644 index 00000000..82e15ab5 --- /dev/null +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Step.java @@ -0,0 +1,108 @@ + +package org.opendaylight.openflowjava.protocol.impl.clients; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

            Java class for stepType complex type. + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "step", propOrder = { + "order", + "name", + "event", + "bytes" +}) +public class Step { + + protected short order; + @XmlElement(required = true) + protected String name; + @XmlElement(required = true) + @XmlSchemaType(name = "string") + protected EventType event; + @XmlList + @XmlElement(type = Short.class) + @XmlSchemaType(name = "anySimpleType") + protected List bytes; + + /** + * Gets the value of the order property. + */ + public short getOrder() { + return order; + } + + /** + * Sets the value of the order property. + */ + public void setOrder(short value) { + this.order = value; + } + + /** + * Gets the value of the name property. + * @return possible object is {@link String } + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * @param value allowed object is {@link String } + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the event property. + * @return possible object is {@link EventType } + */ + public EventType getEvent() { + return event; + } + + /** + * Sets the value of the event property. + * @param value allowed object is {@link EventType } + */ + public void setEvent(EventType value) { + this.event = value; + } + + /** + * Gets the value of the bytes property. + * + *

            + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the bytes property. + * + *

            + * For example, to add a new item, do as follows: + *

            +     *    getBytes().add(newItem);
            +     * 
            + *

            + * Objects of the following type(s) are allowed in the list + * {@link Short } + */ + public List getBytes() { + if (bytes == null) { + bytes = new ArrayList<>(); + } + return this.bytes; + } + +} diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java index f57b738f..0854a279 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java @@ -29,9 +29,7 @@ public class WaitForMessageEvent implements ClientEvent { */ public WaitForMessageEvent(byte[] headerExpected) { this.headerExpected = new byte[headerExpected.length]; - for (int i = 0; i < headerExpected.length; i++) { - this.headerExpected[i] = headerExpected[i]; - } + System.arraycopy(headerExpected, 0, this.headerExpected, 0, headerExpected.length); } @Override @@ -56,9 +54,7 @@ public boolean eventExecuted() { public void setHeaderReceived(byte[] headerReceived) { if (headerReceived != null) { this.headerReceived = new byte[headerReceived.length]; - for (int i = 0; i < headerReceived.length; i++) { - this.headerReceived[i] = headerReceived[i]; - } + System.arraycopy(headerReceived, 0, this.headerReceived, 0, headerReceived.length); } } } diff --git a/simple-client/src/main/resources/scenario.xml b/simple-client/src/main/resources/scenario.xml new file mode 100644 index 00000000..a446cadb --- /dev/null +++ b/simple-client/src/main/resources/scenario.xml @@ -0,0 +1,42 @@ + + + + + 1 + send Hello + sendEvent + 04 00 00 08 00 00 00 01 + + + 2 + wait for Hello_21 + waitForMessageEvent + 04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12 + + + 3 + wait for features request + waitForMessageEvent + 04 05 00 08 00 00 00 02 + + + 4 + features reply + sendEvent + 04 06 00 20 00 00 00 02 00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03 + + + 5 + wait for barrier + waitForMessageEvent + 04 14 00 08 00 00 00 00 + + + 6 + barrier reply + sendEvent + 04 15 00 08 00 00 00 04 + + + + diff --git a/simple-client/src/main/resources/scenario.xsd b/simple-client/src/main/resources/scenario.xsd new file mode 100644 index 00000000..59727ca3 --- /dev/null +++ b/simple-client/src/main/resources/scenario.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8ccfef64270abb747fae6cb0a9dcefadb21de856 Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Fri, 4 Nov 2016 13:25:21 +0100 Subject: [PATCH 263/285] Fix bug on ByteBufUtils method serializeList Also - optimize imports - add test to serializeList method Change-Id: I046e62729676a476818463a5034217778b4295f7 Signed-off-by: Jozef Bacigal --- .../openflowjava/util/ByteBufUtils.java | 15 +++++------ .../openflowjava/util/ByteBufUtilsTest.java | 27 +++++++++++++------ .../impl/clients/ScenarioServiceImpl.java | 26 +++++++++--------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 66c4272e..6be2ee39 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -15,10 +15,8 @@ import com.google.common.primitives.UnsignedBytes; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; - -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.ObjectOutputStream; +import java.nio.ByteBuffer; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -371,10 +369,11 @@ public static MacAddress readIetfMacAddress(final ByteBuf buf) { return IetfYangUtil.INSTANCE.macAddressFor(tmp); } - public static byte[] serializableList(final List list) throws IOException{ - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); - objectOutputStream.writeObject(list); - return byteArrayOutputStream.toByteArray(); + public static byte[] serializeList(final List list) throws IOException{ + ByteBuffer byteBuffer = ByteBuffer.allocate(list.size() * 2); + for (Short aShort : list) { + byteBuffer.putShort(aShort); + } + return byteBuffer.array(); } } diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 7113eb06..8196e69b 100644 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -11,16 +11,14 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.PooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator; - +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; @@ -30,7 +28,8 @@ */ public class ByteBufUtilsTest { - private byte[] expected = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff}; + private final byte[] EXPECTED = new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, (byte) 0xff}; + private final byte[] EXPECTEDVALUES1AND255 = new byte[]{0x00, 0x01, 0x00, (byte) 0xff}; /** * Test of {@link org.opendaylight.openflowjava.util.ByteBufUtils#hexStringToBytes(String)} @@ -39,7 +38,7 @@ public class ByteBufUtilsTest { public void testHexStringToBytes() { byte[] data = ByteBufUtils.hexStringToBytes("01 02 03 04 05 ff"); - Assert.assertArrayEquals(expected, data); + Assert.assertArrayEquals(EXPECTED, data); } /** @@ -49,7 +48,7 @@ public void testHexStringToBytes() { public void testHexStringToBytes2() { byte[] data = ByteBufUtils.hexStringToBytes("0102030405ff", false); - Assert.assertArrayEquals(expected, data); + Assert.assertArrayEquals(EXPECTED, data); } /** @@ -59,7 +58,7 @@ public void testHexStringToBytes2() { public void testHexStringToByteBuf() { ByteBuf bb = ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff"); - Assert.assertArrayEquals(expected, byteBufToByteArray(bb)); + Assert.assertArrayEquals(EXPECTED, byteBufToByteArray(bb)); } /** @@ -70,7 +69,7 @@ public void testHexStringToGivenByteBuf() { ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer(); ByteBufUtils.hexStringToByteBuf("01 02 03 04 05 ff", buffer); - Assert.assertArrayEquals(expected, byteBufToByteArray(buffer)); + Assert.assertArrayEquals(EXPECTED, byteBufToByteArray(buffer)); } private static byte[] byteBufToByteArray(ByteBuf bb) { @@ -437,4 +436,16 @@ public void testReadIpv6Address() { buffer.writeShort(10); ipv4Address = ByteBufUtils.readIpv6Address(buffer2); } + + @Test + public void testSerializeList() throws IOException { + + List shorts = new ArrayList<>(); + shorts.add((short) 1); + shorts.add((short) 255); + + final byte[] bytes = ByteBufUtils.serializeList(shorts); + Assert.assertTrue(bytes.length == shorts.size()*2); + Assert.assertArrayEquals(EXPECTEDVALUES1AND255, bytes); + } } diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java index 897cc698..9e1df907 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java @@ -1,20 +1,20 @@ package org.opendaylight.openflowjava.protocol.impl.clients; import com.google.common.base.Preconditions; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.SAXException; - +import java.io.File; +import java.io.IOException; +import java.util.SortedMap; +import java.util.TreeMap; import javax.xml.XMLConstants; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; -import java.io.File; -import java.io.IOException; -import java.util.*; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; /** * @author Jozef Bacigal @@ -67,12 +67,12 @@ public SortedMap getEventsFromScenario(Scenario scenario) Preconditions.checkNotNull(scenario, "Scenario name not found. Check XML file, scenario name or directories."); SortedMap events = new TreeMap<>(); Integer counter = 0; - for (Step stepType : scenario.getStep()) { - LOG.debug("Step {}: {}, type {}, bytes {}", stepType.getOrder(), stepType.getName(), stepType.getEvent().value(), stepType.getBytes().toArray()); - switch (stepType.getEvent()) { + for (Step step : scenario.getStep()) { + LOG.debug("Step {}: {}, type {}, bytes {}", step.getOrder(), step.getName(), step.getEvent().value(), step.getBytes().toArray()); + switch (step.getEvent()) { case SLEEP_EVENT: events.put(counter++, new SleepEvent(1000)); break; - case SEND_EVENT: events.put(counter++, new SendEvent(ByteBufUtils.serializableList(stepType.getBytes()))); break; - case WAIT_FOR_MESSAGE_EVENT: events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializableList(stepType.getBytes()))); break; + case SEND_EVENT: events.put(counter++, new SendEvent(ByteBufUtils.serializeList(step.getBytes()))); break; + case WAIT_FOR_MESSAGE_EVENT: events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializeList(step.getBytes()))); break; } } return events; From 82da3d09728a0a8110d16659d537f87762392825 Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Fri, 4 Nov 2016 13:29:07 +0100 Subject: [PATCH 264/285] Change Java version to 1.8 Change-Id: I34a6851c162fe0f6bf9c900773b4dbb2452d97a7 Signed-off-by: Jozef Bacigal --- parent/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 5822d278..1d42e379 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -104,11 +104,6 @@ org.apache.maven.plugins maven-compiler-plugin - true - - 1.7 - 1.7 - maven-source-plugin From 4231959d8488d0e5e50199703c5619d50428a962 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Fri, 11 Nov 2016 11:09:47 +0100 Subject: [PATCH 265/285] Add methods that allows registering any serializer Add new methods to SwitchConnectionProviderImpl that will allow us to register any type of OFSerializer and OFDeserializer, so we will be able to for example register serializers for OpenflowPlugin models directly in OpenflowPlugin, without requiring changes in OpenflowJava. Change HeaderSerializer and HeaderDeserializer to require DataContainer instead of DataObject. See also: bug 7136 Change-Id: I002cb787a6db61d864e205d99fafa54692e220a6 Signed-off-by: Tomas Slusny --- .../DeserializerExtensionProvider.java | 15 +++++++++++++++ .../api/extensibility/HeaderDeserializer.java | 4 ++-- .../api/extensibility/HeaderSerializer.java | 4 ++-- .../SerializerExtensionProvider.java | 16 ++++++++++++++++ .../impl/core/SwitchConnectionProviderImpl.java | 9 +++++++++ .../SwitchConnectionProviderImpl02Test.java | 8 ++++++++ 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index b227453e..6de50c31 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -33,6 +34,20 @@ */ public interface DeserializerExtensionProvider { + /** + * Registers deserializer. + * Throws IllegalStateException when there is + * a deserializer already registered under given key. + *

            + * If the deserializer implements {@link DeserializerRegistryInjector} interface, + * the deserializer is injected with DeserializerRegistry instance. + * + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerDeserializer(MessageCodeKey key, + OFGeneralDeserializer deserializer); + /** * Unregisters custom deserializer * @param key used for deserializer lookup diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index a0fe9391..c80df7b9 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -8,13 +8,13 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; import io.netty.buffer.ByteBuf; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * @author michal.polkorab * @param output message type */ -public interface HeaderDeserializer extends OFGeneralDeserializer { +public interface HeaderDeserializer extends OFGeneralDeserializer { /** * Deserializes byte message headers diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index b8b8a029..427d84ce 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -8,14 +8,14 @@ package org.opendaylight.openflowjava.protocol.api.extensibility; import io.netty.buffer.ByteBuf; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataContainer; /** * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) * @author michal.polkorab * @param input message type */ -public interface HeaderSerializer extends OFGeneralSerializer { +public interface HeaderSerializer extends OFGeneralSerializer { /** * Serializes object headers (e.g. for Multipart message - Table Features) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index f108b7c8..366cd3ab 100755 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; @@ -34,6 +35,21 @@ */ public interface SerializerExtensionProvider { + /** + * Registers serializer + * Throws IllegalStateException when there is + * a serializer already registered under given key. + * + * If the serializer implements {@link SerializerRegistryInjector} interface, + * the serializer is injected with SerializerRegistry instance. + * + * @param serializer key type + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer); + /** * Unregisters custom serializer * @param key used for serializer lookup diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 7ecc39e1..d65a623a 100755 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -301,4 +301,13 @@ public ConnectionConfiguration getConfiguration() { return this.connConfig; } + @Override + public void registerSerializer(MessageTypeKey key, OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(key, serializer); + } + + @Override + public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) { + deserializerRegistry.registerDeserializer(key, deserializer); + } } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 5b9dc17c..03cc3f99 100755 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -29,6 +29,8 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.core.ServerFacade; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; @@ -241,6 +243,12 @@ public void testUnregisterExistingKeys(){ provider.registerMatchEntrySerializer(key16, serializer); Assert.assertTrue("Wrong -- unregister MatchEntrySerializer", provider.unregisterSerializer(key16)); Assert.assertFalse("Wrong -- unregister MatchEntrySerializer by not existing key", provider.unregisterSerializer(key15)); + // -- registerSerializer + final MessageTypeKey key17 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, TestSubType.class); + provider.registerSerializer(key17, serializer); + // -- registerDeserializer + final MessageCodeKey key18 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 42, TestSubType.class); + provider.registerDeserializer(key18, deserializer); } private static class TestSubType extends ExperimenterActionSubType { From ce9898d3e25c7cecae6a21290be1eb3c74061737 Mon Sep 17 00:00:00 2001 From: Andrej Leitner Date: Thu, 1 Dec 2016 16:17:58 +0100 Subject: [PATCH 266/285] Remove bundle extension (de)serializers - moved to OFP extensions https://git.opendaylight.org/gerrit/#/c/48896/ https://git.opendaylight.org/gerrit/#/c/48897 Change-Id: Ib2cba9a989daea9f85d7a53280bfcc5f4ad6a753 Signed-off-by: Andrej Leitner --- .../protocol/api/util/EncodeConstants.java | 4 - .../yang/openflow-approved-extensions.yang | 199 ------------------ .../MessageDeserializerInitializer.java | 8 - .../experimenter/BundleControlFactory.java | 96 --------- .../OnfExperimenterErrorFactory.java | 72 ------- .../MessageFactoryInitializer.java | 16 -- .../AbstractBundleMessageFactory.java | 80 ------- .../experimenter/BundleAddMessageFactory.java | 55 ----- .../experimenter/BundleControlFactory.java | 29 --- .../util/CommonMessageRegistryHelper.java | 11 - .../SimpleDeserializerRegistryHelper.java | 24 --- .../BundleControlFactoryTest.java | 100 --------- .../OnfExperimenterErrorFactoryTest.java | 140 ------------ .../AbstractBundleMessageFactoryTest.java | 82 -------- .../BundleAddMessageFactoryTest.java | 105 --------- .../BundleControlFactoryTest.java | 97 --------- .../ExperimenterDeserializerKeyFactory.java | 11 - .../ExperimenterSerializerKeyFactory.java | 11 - 18 files changed, 1140 deletions(-) delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java delete mode 100644 openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java delete mode 100644 openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java index 8c6539b6..58d6ccd4 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/EncodeConstants.java @@ -68,10 +68,6 @@ public abstract class EncodeConstants { public static final long ONF_EXPERIMENTER_ID = 0x4F4E4600; /** ONFOXM_ET_TCP_FLAGS value */ public static final int ONFOXM_ET_TCP_FLAGS = 42; - /** ONF_ET_BUNDLE_CONTROL message type */ - public static final int ONF_ET_BUNDLE_CONTROL = 2300; - /** ONF_ET_BUNDLE_ADD_MESSAGE message type */ - public static final int ONF_ET_BUNDLE_ADD_MESSAGE = 2301; private EncodeConstants() { //not called diff --git a/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang index 17c89408..29a20351 100644 --- a/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang +++ b/openflow-protocol-api/src/main/yang/openflow-approved-extensions.yang @@ -3,13 +3,6 @@ module openflow-approved-extensions { prefix "ofext"; import yang-ext {prefix ext;} - import ietf-inet-types {prefix inet;} - import ietf-yang-types {prefix yang;} - - import openflow-types {prefix oft;} - import openflow-protocol {prefix ofproto;} - import openflow-action {prefix ofaction;} - import openflow-instruction {prefix ofinstruction;} import openflow-extensible-match {prefix oxm;} import openflow-augments {prefix aug;} @@ -18,78 +11,6 @@ module openflow-approved-extensions { } //ONF Approved OpenFlow Extensions - - // ONF experimenter error codes - typedef onf-experimenter-error-code { - description "Error codes for experimenter error type."; - type enumeration { - enum ONFERR_ET_UNKNOWN { - description "Unspecified error."; - value 2300; - } - enum ONFERR_ET_EPERM { - description "Permissions error."; - value 2301; - } - enum ONFERR_ET_BAD_ID { - description "Bundle ID doesn’t exist."; - value 2302; - } - enum ONFERR_ET_BUNDLE_EXIST { - description "Bundle ID already exist."; - value 2303; - } - enum ONFERR_ET_BUNDLE_CLOSED { - description "Bundle ID is closed."; - value 2304; - } - enum ONFERR_ET_OUT_OF_BUNDLES { - description "Too many bundles IDs."; - value 2305; - } - enum ONFERR_ET_BAD_TYPE { - description "Unsupported or unknown message control type."; - value 2306; - } - enum ONFERR_ET_BAD_FLAGS { - description "Unsupported, unknown, or inconsistent flags."; - value 2307; - } - enum ONFERR_ET_MSG_BAD_LEN { - description "Length problem in included message."; - value 2308; - } - enum ONFERR_ET_MSG_BAD_XID { - description "Inconsistent or duplicate XID."; - value 2309; - } - enum ONFERR_ET_MSG_UNSUP { - description "Unsupported message in this bundle."; - value 2310; - } - enum ONFERR_ET_MSG_CONFLICT { - description "Unsupported message combination in this bundle."; - value 2311; - } - enum ONFERR_ET_MSG_TOO_MANY { - description "Can not handle this many messages in bundle."; - value 2312; - } - enum ONFERR_ET_MSG_FAILED { - description "One message in bundle failed."; - value 2313; - } - enum ONFERR_ET_TIMEOUT { - description "Bundle is taking too long."; - value 2314; - } - enum ONFERR_ET_BUNDLE_IN_PROGRESS { - description "Bundle is locking the resource."; - value 2315; - } - } - } - // Extension 109 - TCP FLAGS identity tcp_flags { base oxm:match-field; @@ -108,124 +29,4 @@ module openflow-approved-extensions { } } - // Extension 230 - Bundle Extension (experimenterID 0x4F4E4600) - typedef bundle-id { - description "Identify the bundle."; - type uint32; - } - - typedef bundle-control-type { - description "Bundle control message type."; - type enumeration { - enum ONF_BCT_OPEN_REQUEST { - value 0; - } - enum ONF_BCT_OPEN_REPLY { - value 1; - } - enum ONF_BCT_CLOSE_REQUEST { - value 2; - } - enum ONF_BCT_CLOSE_REPLY { - value 3; - } - enum ONF_BCT_COMMIT_REQUEST { - value 4; - } - enum ONF_BCT_COMMIT_REPLY { - value 5; - } - enum ONF_BCT_DISCARD_REQUEST { - value 6; - } - enum ONF_BCT_DISCARD_REPLY { - value 7; - } - } - } - - typedef bundle-flags { - description "Bundle configuration flags."; - type bits { - bit atomic { - description "Execute atomically."; - position 0; - } - bit ordered { - description "Execute in specified order."; - position 1; - } - } - } - - typedef bundle-property-type { - description "Bundle property types."; - type enumeration { - enum ONF_ET_BPT_EXPERIMENTER { - description "Experimenter property."; - value 65535; //0xFFFF - } - } - } - - grouping bundle-properties { - list bundle-property { - description "Bundle properties list."; - leaf type { - type bundle-property-type; - } - choice bundle-property-entry { - case bundle-experimenter-property { - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - choice bundle-experimenter-property-data { - // to be augmented by vendors - } - } - } - } - } - - augment "/ofproto:experimenter/ofproto:input/ofproto:experimenter-data-of-choice" { - case bundle-control { - description "ONF_ET_BUNDLE_CONTROL message in OpenFlow Switch Extension 230."; - leaf bundle-id { - type bundle-id; - } - leaf type { - type bundle-control-type; - } - leaf flags { - type bundle-flags; - } - uses bundle-properties; - } - case bundle-add-message { - description "ONF_ET_BUNDLE_ADD_MESSAGE in OpenFlow Switch Extension 230."; - leaf bundle-id { - type bundle-id; - } - leaf flags { - type bundle-flags; - } - // Inner message - choice message { - description "Message added to the bundle."; - case flow-mod-case { - uses ofproto:flow-mod; - } - case group-mod-case { - uses ofproto:group-mod; - } - case port-mod-case { - uses ofproto:port-mod; - } - } - uses bundle-properties; - } - } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 488db9c6..79873cc1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -9,8 +9,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.BundleControlFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.OnfExperimenterErrorFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory; import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory; @@ -103,12 +101,6 @@ public static void registerMessageDeserializers(final DeserializerRegistry regis helper.registerDeserializer(25, RoleRequestOutput.class, new RoleReplyMessageFactory()); helper.registerDeserializer(27, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); - // register ONF approved experimenter serializers - helper.registerExperimenterErrorDeserializer(EncodeConstants.ONF_EXPERIMENTER_ID, - new OnfExperimenterErrorFactory()); - helper.registerExperimenterDeserializer(EncodeConstants.ONF_EXPERIMENTER_ID, - EncodeConstants.ONF_ET_BUNDLE_CONTROL, new BundleControlFactory()); - // register OF v1.4 message deserializers helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF14_VERSION_ID, registry); helper.registerDeserializer(0, HelloMessage.class, new HelloMessageFactory()); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java deleted file mode 100644 index 0d52e0c8..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; - -import io.netty.buffer.ByteBuf; -import java.util.ArrayList; -import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundlePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterPropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControlBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; - -/** - * Translates BundleControl messages (OpenFlow v1.3 extension #230). - */ -public class BundleControlFactory implements OFDeserializer, DeserializerRegistryInjector { - - private DeserializerRegistry deserializerRegistry; - - @Override - public BundleControl deserialize(ByteBuf message) { - BundleId bundleId = new BundleId(message.readUnsignedInt()); - BundleControlType type = BundleControlType.forValue(message.readUnsignedShort()); - BundleFlags flags = createBundleFlags(message.readUnsignedShort()); - BundleControlBuilder builder = new BundleControlBuilder(); - List properties = createBundleProperties(message); - return builder.setBundleId(bundleId) - .setType(type) - .setFlags(flags) - .setBundleProperty(properties) - .build(); - } - - private static BundleFlags createBundleFlags(final int flags) { - Boolean isAtomic = (flags & (1 << 0)) != 0; - Boolean isOrdered = (flags & (1 << 1)) != 0; - return new BundleFlags(isAtomic, isOrdered); - } - - private List createBundleProperties(final ByteBuf message) { - List properties = new ArrayList<>(); - while (message.readableBytes() > 0) { - BundlePropertyType type = BundlePropertyType.forValue(message.readUnsignedShort()); - int length = message.readUnsignedShort(); - if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) { - properties.add(createExperimenterBundleProperty(length, message)); - } else { - message.skipBytes(length); - } - } - return properties; - } - - private BundleProperty createExperimenterBundleProperty(final int length, final ByteBuf message) { - BundleExperimenterPropertyBuilder experimenterProperty = new BundleExperimenterPropertyBuilder(); - long experimenterId = message.readUnsignedInt(); - long expType = message.readUnsignedInt(); - experimenterProperty.setExperimenter(new ExperimenterId(experimenterId)); - experimenterProperty.setExpType(expType); - - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createBundlePropertyDeserializerKey(EncodeConstants.OF13_VERSION_ID, - experimenterId, expType)); - experimenterProperty.setBundleExperimenterPropertyData(deserializer.deserialize(message.readBytes(length - 12))); - - return new BundlePropertyBuilder().setType(BundlePropertyType.ONFETBPTEXPERIMENTER) - .setBundlePropertyEntry(experimenterProperty.build()) - .build(); - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.deserializerRegistry = deserializerRegistry; - } - -} - - diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java deleted file mode 100644 index a104531d..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.OnfExperimenterErrorCode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdError; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdErrorBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Translates (ONF approved) experimenter error messages. - */ -public class OnfExperimenterErrorFactory implements OFDeserializer { - - private static final Logger LOG = LoggerFactory.getLogger(OnfExperimenterErrorFactory.class); - private static final String UNKNOWN_TYPE = "UNKNOWN_TYPE"; - private static final String UNKNOWN_CODE = "UNKNOWN_CODE"; - - @Override - public ErrorMessage deserialize(ByteBuf message) { - ErrorMessageBuilder builder = new ErrorMessageBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(message.readUnsignedInt()); - - int type = message.readUnsignedShort(); - ErrorType errorType = ErrorType.forValue(type); - if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) { - builder.setType(errorType.getIntValue()); - builder.setTypeString(errorType.getName()); - } else { - LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(), - this.getClass().getCanonicalName()); - builder.setType(type); - builder.setTypeString(UNKNOWN_TYPE); - } - - int code = message.readUnsignedShort(); - OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code); - if (errorCode != null) { - builder.setCode(errorCode.getIntValue()); - builder.setCodeString(errorCode.getName()); - } else { - builder.setCode(code); - builder.setCodeString(UNKNOWN_CODE); - } - - builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder() - .setExperimenter(new ExperimenterId(message.readUnsignedInt())) - .build()); - - if (message.readableBytes() > 0) { - byte[] data = new byte[message.readableBytes()]; - message.readBytes(data); - builder.setData(data); - } - return builder.build(); - } -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 08b9bc54..23551bb7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -9,8 +9,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleAddMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleControlFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory; @@ -39,9 +37,6 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.factories.VendorInputMessageFactory; import org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.FlowModCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.GroupModCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput; @@ -116,16 +111,5 @@ public static void registerMessageSerializers(SerializerRegistry serializerRegis registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); - - // register ONF approved experimenter serializers - registryHelper.registerExperimenterSerializer(EncodeConstants.ONF_EXPERIMENTER_ID, - EncodeConstants.ONF_ET_BUNDLE_CONTROL, new BundleControlFactory()); - registryHelper.registerExperimenterSerializer(EncodeConstants.ONF_EXPERIMENTER_ID, - EncodeConstants.ONF_ET_BUNDLE_ADD_MESSAGE, new BundleAddMessageFactory()); - - // register serializers for inner messages of BundleAddMessage - registryHelper.registerSerializer(FlowModCase.class, new FlowModInputMessageFactory()); - registryHelper.registerSerializer(GroupModCase.class, new GroupModInputMessageFactory()); - registryHelper.registerSerializer(PortModCase.class, new PortModInputMessageFactory()); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java deleted file mode 100644 index 3fc2896a..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yangtools.yang.binding.DataContainer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract class for common stuff of bundle messages. - */ -public abstract class AbstractBundleMessageFactory implements OFSerializer, - SerializerRegistryInjector { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractBundleMessageFactory.class); - protected SerializerRegistry serializerRegistry; - - @Override - public void serialize(T input, ByteBuf outBuffer) { - // to be extended - } - - @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { - this.serializerRegistry = serializerRegistry; - } - - protected static void writeBundleFlags(final BundleFlags bundleFlags, final ByteBuf outBuffer) { - int flagsBitMap = ByteBufUtils.fillBitMask(0, bundleFlags.isAtomic(), bundleFlags.isOrdered()); - outBuffer.writeShort(flagsBitMap); - } - - protected void writeBundleProperties(final List properties, final ByteBuf outBuffer) { - for (BundleProperty property : properties) { - BundlePropertyType type = property.getType(); - if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(type.getIntValue()); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - writeBundleExperimenterProperty(property, outBuffer); - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } else { - LOG.warn("lTrying to serialize unknown bundle property (type: {}), skipping", type.getIntValue() ); - } - } - } - - protected void writeBundleExperimenterProperty(final BundleProperty bundleProperty, final ByteBuf outBuffer) { - BundleExperimenterProperty property = (BundleExperimenterProperty) bundleProperty.getBundlePropertyEntry(); - int experimenterId = property.getExperimenter().getValue().intValue(); - int expType = property.getExpType().intValue(); - outBuffer.writeInt(experimenterId); - outBuffer.writeInt(expType); - OFSerializer serializer = serializerRegistry.getSerializer( - ExperimenterSerializerKeyFactory.createBundlePropertySerializerKey(EncodeConstants.OF13_VERSION_ID, - experimenterId, expType)); - serializer.serialize(property.getBundleExperimenterPropertyData(), outBuffer); - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java deleted file mode 100644 index 9ceec4de..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import java.util.List; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.Message; -import org.opendaylight.yangtools.yang.binding.DataContainer; - -/** - * Translates BundleAddMessage messages (OpenFlow v1.3 extension #230). - */ -public class BundleAddMessageFactory extends AbstractBundleMessageFactory { - - @Override - public void serialize(BundleAddMessage input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getBundleId().getValue().intValue()); - outBuffer.writeZero(2); - writeBundleFlags(input.getFlags(), outBuffer); - - int msgStart = outBuffer.writerIndex(); - serializeInnerMessage(input.getMessage(), outBuffer, input.getMessage().getImplementedInterface()); - int msgLength = outBuffer.writerIndex() - msgStart; - - List bundleProperties = input.getBundleProperty(); - if (bundleProperties != null && !bundleProperties.isEmpty()) { - outBuffer.writeZero(paddingNeeded(msgLength)); - writeBundleProperties(input.getBundleProperty(), outBuffer); - } - } - - private void serializeInnerMessage(final Message innerMessage, final ByteBuf outBuffer, - final Class clazz) { - OFSerializer serializer = serializerRegistry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, clazz)); - serializer.serialize((T)innerMessage, outBuffer); - } - - private static int paddingNeeded(final int length) { - int paddingRemainder = length % EncodeConstants.PADDING; - return (paddingRemainder != 0) ? (EncodeConstants.PADDING - paddingRemainder) : 0; - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java deleted file mode 100644 index 069f34fe..00000000 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; - -/** - * Translates BundleControl messages (OpenFlow v1.3 extension #230). - */ -public class BundleControlFactory extends AbstractBundleMessageFactory { - - @Override - public void serialize(BundleControl input, ByteBuf outBuffer) { - outBuffer.writeInt(input.getBundleId().getValue().intValue()); - outBuffer.writeShort(input.getType().getIntValue()); - writeBundleFlags(input.getFlags(), outBuffer); - if (input.getBundleProperty() != null) { - writeBundleProperties(input.getBundleProperty(), outBuffer); - } - } - -} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java index 260d1b3f..15bc5971 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java @@ -39,15 +39,4 @@ public void registerSerializer(Class msgType, OFGeneralSerializer serializer) serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); } - /** - * Registers experimenter serializer in registry. - * @param experimenterId experimenterID of experimenter message - * @param type type of experimenter message - * @param serializer serializer instance - */ - public void registerExperimenterSerializer(final long experimenterId, final long type, - final OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(ExperimenterSerializerKeyFactory - .createExperimenterMessageSerializerKey(version, experimenterId, type), serializer); - } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 752ac3e3..6d527c4a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -10,7 +10,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; /** * Helper class for deserializer registration. @@ -45,27 +44,4 @@ public void registerDeserializer(final int code, final Class deserializedObje } } - /** - * Register experimenter deserializer in registry. - * @param experimenterId experimenterID of experimenter message - * @param type type of experimenter message - * @param deserializer deserializer instance - */ - public void registerExperimenterDeserializer (final long experimenterId, final long type, - final OFGeneralDeserializer deserializer) { - registry.registerDeserializer(ExperimenterDeserializerKeyFactory - .createExperimenterMessageDeserializerKey(version, experimenterId, type), deserializer); - } - - /** - * Register experimenter error deserializer in registry. - * @param experimenterId experimenterID of experimenter message - * @param deserializer deserializer instance - */ - public void registerExperimenterErrorDeserializer (final long experimenterId, - final OFGeneralDeserializer deserializer) { - registry.registerDeserializer(ExperimenterDeserializerKeyFactory - .createExperimenterErrorDeserializerKey(version, experimenterId), deserializer); - } - } diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java deleted file mode 100644 index 77aca382..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/BundleControlFactoryTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; - -import io.netty.buffer.ByteBuf; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; - -/** - * Tests for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.BundleControlFactory}. - */ -@RunWith(MockitoJUnitRunner.class) -public class BundleControlFactoryTest { - - private OFDeserializer factory; - @Mock - DeserializerRegistry registry; - @Mock - OFDeserializer experimenterPropertyDeserializer; - - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - factory = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, EncodeConstants.ONF_ET_BUNDLE_CONTROL)); - } - - @Test - public void testDeserializeWithoutProperties() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 01 " // bundle ID - + "00 01 " // type - + "00 03"); // flags - BundleControl builtByFactory = factory.deserialize(buffer); - Assert.assertEquals(1, builtByFactory.getBundleId().getValue().intValue()); - BundleFlags flags = new BundleFlags(true, true); - Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getFlags().isAtomic()); - Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getFlags().isOrdered()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREPLY, builtByFactory.getType()); - Assert.assertTrue("Properties not empty", builtByFactory.getBundleProperty().isEmpty()); - } - - @Test - public void testDeserializeWithProperties() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 01 " // bundle ID - + "00 05 " // type - + "00 02 " // flags - + "ff ff " // type 1 - + "00 0c " // length 1 - + "00 00 00 01 " // experimenter ID 1 - + "00 00 00 02 " // experimenter type 1 - + "00 00 00 00 " // experimenter data 1 - + "00 00 " // type 2 - + "00 04 " // length 2 - + "00 00 00 00"); // data 2 - Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(experimenterPropertyDeserializer); - ((DeserializerRegistryInjector)factory).injectDeserializerRegistry(registry); - BundleControl builtByFactory = BufferHelper.deserialize(factory, buffer); - Assert.assertEquals(1, builtByFactory.getBundleId().getValue().intValue()); - BundleFlags flags = new BundleFlags(false, true); - Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getFlags().isAtomic()); - Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getFlags().isOrdered()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREPLY, builtByFactory.getType()); - BundleProperty property = builtByFactory.getBundleProperty().get(0); - Assert.assertEquals("Wrong bundle property type", BundlePropertyType.ONFETBPTEXPERIMENTER, property.getType()); - BundleExperimenterProperty experimenterProperty = (BundleExperimenterProperty) property.getBundlePropertyEntry(); - Assert.assertEquals("Wrong experimenter ID", 1, experimenterProperty.getExperimenter().getValue().intValue()); - Assert.assertEquals("Wrong experimenter type", 2, experimenterProperty.getExpType().longValue()); - Mockito.verify(experimenterPropertyDeserializer, Mockito.times(1)).deserialize(buffer); - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java deleted file mode 100644 index 69891413..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/experimenter/OnfExperimenterErrorFactoryTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter; - -import io.netty.buffer.ByteBuf; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdError; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; - -/** - * Tests for {@link org.opendaylight.openflowjava.protocol.impl.deserialization.experimenter.OnfExperimenterErrorFactory}. - */ -public class OnfExperimenterErrorFactoryTest { - - private OFDeserializer factory; - - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - factory = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID)); - } - - @Test - public void testVersion() { - ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 00 00 00 01"); - ErrorMessage builtByFactory = factory.deserialize(buffer); - BufferHelper.checkHeaderV13(builtByFactory); - } - - @Test - public void testDeserializeBase() { - ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 4f 4e 46 00"); - ErrorMessage builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong type", EncodeConstants.EXPERIMENTER_VALUE, builtByFactory.getType().intValue()); - Assert.assertEquals("Wrong type string", "EXPERIMENTER", builtByFactory.getTypeString()); - Assert.assertEquals("Wrong experimenter ID", EncodeConstants.ONF_EXPERIMENTER_ID, - builtByFactory.getAugmentation(ExperimenterIdError.class).getExperimenter().getValue().intValue()); - Assert.assertNull("Data is not null", builtByFactory.getData()); - } - - @Test - public void testDeserializeCodes() { - ByteBuf buffer = BufferHelper.buildBuffer("ff ff 08 fc 00 00 00 01"); - ErrorMessage builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2300, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_UNKNOWN", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 08 fd 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2301, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_EPERM", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 08 fe 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2302, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_ID", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 08 ff 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2303, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_EXIST", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 00 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2304, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_CLOSED", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 01 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2305, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_OUT_OF_BUNDLES", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 02 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2306, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_TYPE", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 03 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2307, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BAD_FLAGS", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 04 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2308, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_BAD_LEN", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 05 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2309, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_BAD_XID", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 06 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2310, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_UNSUP", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 07 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2311, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_CONFLICT", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 08 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2312, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_TOO_MANY", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 09 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2313, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_MSG_FAILED", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 0a 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2314, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_TIMEOUT", builtByFactory.getCodeString()); - - buffer = BufferHelper.buildBuffer("ff ff 09 0b 00 00 00 01"); - builtByFactory = factory.deserialize(buffer); - Assert.assertEquals("Wrong code", 2315, builtByFactory.getCode().intValue()); - Assert.assertEquals("Wrong code string", "ONFERR_ET_BUNDLE_IN_PROGRESS", builtByFactory.getCodeString()); - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java deleted file mode 100644 index 3de49975..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/AbstractBundleMessageFactoryTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundleProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.BundlePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.BundleExperimenterPropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.message.PortModCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yangtools.yang.binding.DataContainer; - -/** - * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.AbstractBundleMessageFactory} - * and util methods. - */ -public class AbstractBundleMessageFactoryTest { - - @Test - public void writeBundleFlags() throws Exception { - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - AbstractBundleMessageFactory.writeBundleFlags(new BundleFlags(true, true), out); - Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort()); - } - - public static List createListWithBundleExperimenterProperty(BundleExperimenterPropertyData data) { - BundlePropertyBuilder propertyBuilder = new BundlePropertyBuilder(); - propertyBuilder.setType(BundlePropertyType.ONFETBPTEXPERIMENTER); - BundleExperimenterPropertyBuilder experimenterPropertyBuilder = new BundleExperimenterPropertyBuilder(); - experimenterPropertyBuilder.setExperimenter(new ExperimenterId(1L)); - experimenterPropertyBuilder.setExpType(2L); - - experimenterPropertyBuilder.setBundleExperimenterPropertyData(data); - propertyBuilder.setBundlePropertyEntry(experimenterPropertyBuilder.build()); - return new ArrayList<>(Collections.singleton(propertyBuilder.build())); - } - - public static BundleExperimenterPropertyData createBundleExperimenterPropertyData() { - return new BundleExperimenterPropertyData() { - @Override - public Class getImplementedInterface() { - return null; - } - }; - } - - public static PortModCase createPortModCase() { - PortModCaseBuilder caseBuilder = new PortModCaseBuilder(); - caseBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - caseBuilder.setXid(3L); - caseBuilder.setPortNo(new PortNumber(9L)); - caseBuilder.setHwAddress(new MacAddress("08:00:27:00:B0:EB")); - caseBuilder.setConfig(new PortConfig(true, false, true, false)); - caseBuilder.setMask(new PortConfig(false, true, false, true)); - caseBuilder.setAdvertise(new PortFeatures(true, false, false, false, - false, false, false, true, - false, false, false, false, - false, false, false, false)); - return caseBuilder.build(); - } -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java deleted file mode 100644 index 9e662519..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleAddMessageFactoryTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleAddMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.bundle.add.message.Message; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortMod; - -/** - * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleAddMessageFactory}. - */ -@RunWith(MockitoJUnitRunner.class) -public class BundleAddMessageFactoryTest { - - private OFSerializer factory; - @Mock - SerializerRegistry registry; - @Mock - OFSerializer portModSerializer; - @Mock - OFSerializer propertySerializer; - - @Before - public void setUp() { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - factory = registry.getSerializer(ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, - EncodeConstants.ONF_ET_BUNDLE_ADD_MESSAGE)); - } - - @Test - public void testSerializeWithoutProperties() { - BundleAddMessageBuilder builder = new BundleAddMessageBuilder(); - builder.setBundleId(new BundleId(1L)); - builder.setFlags(new BundleFlags(true, false)); - - Message innerMessage = AbstractBundleMessageFactoryTest.createPortModCase(); - builder.setMessage(innerMessage); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))).thenReturn(portModSerializer); - ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt()); - long padding = out.readUnsignedShort(); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - Mockito.verify(portModSerializer, Mockito.times(1)).serialize((PortMod)innerMessage, out); - } - - @Test - public void testSerializeWithExperimenterProperty() { - BundleAddMessageBuilder builder = new BundleAddMessageBuilder(); - builder.setBundleId(new BundleId(2L)); - builder.setFlags(new BundleFlags(true, false)); - - Message innerMessage = AbstractBundleMessageFactoryTest.createPortModCase(); - builder.setMessage(innerMessage); - - BundleExperimenterPropertyData data = AbstractBundleMessageFactoryTest.createBundleExperimenterPropertyData(); - builder.setBundleProperty(AbstractBundleMessageFactoryTest.createListWithBundleExperimenterProperty(data)); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))) - .thenReturn(portModSerializer) - .thenReturn(propertySerializer); - ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 2L, out.readUnsignedInt()); - long padding = out.readUnsignedShort(); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - Mockito.verify(portModSerializer, Mockito.times(1)).serialize((PortMod)innerMessage, out); - Mockito.verify(propertySerializer, Mockito.times(1)).serialize(data, out); - } - -} \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java deleted file mode 100644 index 180d915a..00000000 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/experimenter/BundleControlFactoryTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.experimenter; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ExperimenterSerializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleControlType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundleId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.BundlePropertyType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.experimenter.input.experimenter.data.of.choice.BundleControlBuilder; - -/** - * Test for {@link org.opendaylight.openflowjava.protocol.impl.serialization.experimenter.BundleControlFactory}. - */ -@RunWith(MockitoJUnitRunner.class) -public class BundleControlFactoryTest { - - private OFSerializer factory; - @Mock - SerializerRegistry registry; - @Mock - OFSerializer serializer; - - @Before - public void setUp() throws Exception { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - factory = registry.getSerializer(ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF13_VERSION_ID, EncodeConstants.ONF_EXPERIMENTER_ID, EncodeConstants.ONF_ET_BUNDLE_CONTROL)); - } - - @Test - public void testSerializeWithoutProperties() { - BundleControlBuilder builder = new BundleControlBuilder(); - builder.setBundleId(new BundleId(1L)); - builder.setType(BundleControlType.ONFBCTOPENREQUEST); - builder.setFlags(new BundleFlags(true, true)); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREQUEST.getIntValue(), out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort()); - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } - - @Test - public void testSerializeWithExperimenterProperty() { - BundleControlBuilder builder = new BundleControlBuilder(); - builder.setBundleId(new BundleId(3L)); - builder.setType(BundleControlType.ONFBCTCOMMITREQUEST); - builder.setFlags(new BundleFlags(false, true)); - - BundleExperimenterPropertyData data = AbstractBundleMessageFactoryTest.createBundleExperimenterPropertyData(); - builder.setBundleProperty(AbstractBundleMessageFactoryTest.createListWithBundleExperimenterProperty(data)); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - Mockito.when(registry.getSerializer(Matchers.any(MessageTypeKey.class))).thenReturn(serializer); - ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry); - factory.serialize(builder.build(), out); - - Assert.assertEquals("Wrong bundle ID", 3L, out.readUnsignedInt()); - Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREQUEST.getIntValue(), out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong property type", BundlePropertyType.ONFETBPTEXPERIMENTER.getIntValue(), out.readUnsignedShort()); - int length = out.readUnsignedShort(); - Assert.assertEquals("Wrong experimenter ID", 1, out.readUnsignedInt()); - Assert.assertEquals("Wrong experimenter type", 2, out.readUnsignedInt()); - Mockito.verify(serializer, Mockito.times(1)).serialize(data, out); - } - -} \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index 75ada6fb..6e285f95 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -10,7 +10,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -108,14 +107,4 @@ public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); } - /** - * @param version openflow wire version - * @param experimenterId experimenter ID - * @param type experimenter type according to vendor implementation - * @return key instance - */ - public static ExperimenterIdTypeDeserializerKey createBundlePropertyDeserializerKey( - short version, long experimenterId, long type) { - return new ExperimenterIdTypeDeserializerKey(version, experimenterId, type, BundleExperimenterPropertyData.class); - } } \ No newline at end of file diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 24e78deb..ea0a69ce 100755 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -11,7 +11,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdMeterSubTypeSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdSerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.bundle.properties.bundle.property.bundle.property.entry.bundle.experimenter.property.BundleExperimenterPropertyData; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterMeterBandSubType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -69,14 +68,4 @@ public static ExperimenterIdSerializerKey createMeter return new ExperimenterIdMeterSubTypeSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class, meterSubType); } - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter ID - * @param type experimenter type according to vendor implementation - * @return key instance - */ - public static ExperimenterIdSerializerKey createBundlePropertySerializerKey( - short msgVersion, long experimenterId, long type) { - return new ExperimenterIdTypeSerializerKey<>(msgVersion, experimenterId, type, BundleExperimenterPropertyData.class); - } } \ No newline at end of file From 27286e9d023c4ac7692fb30a8e8cbdf2cd92f9f7 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Mon, 12 Dec 2016 11:10:22 +0100 Subject: [PATCH 267/285] Add methods for modifying deserializer mapping Add new methods to SwitchConnectionProviderImpl that will allow us to modify type to class mapping of deserializers for top level messages (like FlowMod, PortMod) to be able to register deserializers for custom top level types without needing changes in OpenflowJava. Change-Id: I0f0d0f25a971660e6601069fc6f9f59e8206f2e7 Signed-off-by: Tomas Slusny --- .../DeserializerExtensionProvider.java | 15 ++++++++ .../protocol/api/keys}/TypeToClassKey.java | 2 +- .../api/keys}/TypeToClassKeyTest.java | 3 +- .../core/SwitchConnectionProviderImpl.java | 11 ++++++ .../DeserializationFactory.java | 36 ++++++++++++++----- .../TypeToClassMapInitializer.java | 2 +- .../impl/util/TypeToClassInitHelper.java | 1 + .../TypeToClassMapInitializerTest.java | 2 +- 8 files changed, 58 insertions(+), 14 deletions(-) rename {openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util => openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys}/TypeToClassKey.java (95%) rename {openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization => openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys}/TypeToClassKeyTest.java (90%) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 6de50c31..5a0658eb 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -14,6 +14,7 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; @@ -127,4 +128,18 @@ void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, */ void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, OFDeserializer deserializer); + + /** + * Registers type to class mapping used to assign return type when deserializing message + * @param key type to class key + * @param clazz return class + */ + void registerDeserializerMapping(TypeToClassKey key, Class clazz); + + /** + * Unregisters type to class mapping used to assign return type when deserializing message + * @param key type to class key + * @return true if mapping was successfully removed + */ + boolean unregisterDeserializerMapping(TypeToClassKey key); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKey.java similarity index 95% rename from openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java rename to openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKey.java index 0f6b9caf..71eed094 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKey.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.util; +package org.opendaylight.openflowjava.protocol.api.keys; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKeyTest.java similarity index 90% rename from openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java rename to openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKeyTest.java index a9ebcf43..8b6192d3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/TypeToClassKeyTest.java @@ -6,12 +6,11 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.openflowjava.protocol.impl.deserialization; +package org.opendaylight.openflowjava.protocol.api.keys; import org.junit.Assert; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; /** * * @author madamjak diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index d65a623a..afa47644 100755 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -38,6 +38,7 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -310,4 +311,14 @@ public void registerSerializer(MessageTypeKey key, OFGeneralSerializer se public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) { deserializerRegistry.registerDeserializer(key, deserializer); } + + @Override + public void registerDeserializerMapping(final TypeToClassKey key, final Class clazz) { + deserializationFactory.registerMapping(key, clazz); + } + + @Override + public boolean unregisterDeserializerMapping(final TypeToClassKey key) { + return deserializationFactory.unregisterMapping(key); + } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java index bf535b2d..de631b11 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java @@ -8,15 +8,14 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization; -import com.google.common.collect.ImmutableMap; import io.netty.buffer.ByteBuf; -import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; import org.opendaylight.yangtools.yang.binding.DataObject; /** @@ -26,20 +25,17 @@ */ public class DeserializationFactory { - private final Map> messageClassMap; + private final Map> messageClassMap = new ConcurrentHashMap<>(); private DeserializerRegistry registry; /** * Constructor */ public DeserializationFactory() { - final Map> temp = new HashMap<>(); - TypeToClassMapInitializer.initializeTypeToClassMap(temp); + TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); // Register type to class map for additional deserializers - TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(temp); - - messageClassMap = ImmutableMap.copyOf(temp); + TypeToClassMapInitializer.initializeAdditionalTypeToClassMap(messageClassMap); } /** @@ -60,6 +56,28 @@ public DataObject deserialize(final ByteBuf rawMessage, final short version) { return dataObject; } + /** + * Register new type to class mapping used to assign return type when deserializing message + * @param key type to class key + * @param clazz return class + */ + public void registerMapping(final TypeToClassKey key, final Class clazz) { + messageClassMap.put(key, clazz); + } + + /** + * Unregister type to class mapping used to assign return type when deserializing message + * @param key type to class key + * @return true if mapping was successfully removed + */ + public boolean unregisterMapping(final TypeToClassKey key) { + if (key == null) { + throw new IllegalArgumentException("TypeToClassKey is null"); + } + + return messageClassMap.remove(key) != null; + } + /** * @param registry */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index 61cce25d..61fe027f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -10,7 +10,7 @@ import java.util.Map; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index 339edd18..b360f89f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowjava.protocol.impl.util; import java.util.Map; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; /** * @author michal.polkorab diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index 9ff6e9e7..dfa01580 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -14,7 +14,7 @@ import java.util.Map; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; From 626211a64722224cf7c139ebc3e01d3a775bca88 Mon Sep 17 00:00:00 2001 From: Daniel Farrell Date: Wed, 14 Dec 2016 17:02:56 -0500 Subject: [PATCH 268/285] Remove duplicate controller.mdsal.version field Change-Id: I5d85e1e2bb2871b517603fea947a82951fd7aa73 Signed-off-by: Daniel Farrell --- features/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/features/pom.xml b/features/pom.xml index 099cebe7..e14cb2ae 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -17,7 +17,6 @@ 0.6.0-SNAPSHOT 1.5.0-SNAPSHOT 2.2.0-SNAPSHOT - 1.5.0-SNAPSHOT 0.10.0-SNAPSHOT From a694a3f78d4274fb27c9a411c999eddd870c127f Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 23 Jan 2017 19:58:43 +0100 Subject: [PATCH 269/285] Replace mockito-all by mockito-core (see Bug 7662) Change-Id: Ic6cfde3f29b167040ae1588df7622f2505663b5e Signed-off-by: Michael Vorburger --- openflow-protocol-api/pom.xml | 2 +- openflow-protocol-impl/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 3d815745..7eb15821 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -75,7 +75,7 @@ org.mockito - mockito-all + mockito-core diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index e91846e0..c97c7acb 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -144,7 +144,7 @@ org.mockito - mockito-all + mockito-core org.opendaylight.controller From 41c94f361e680fd1676cb2552dddce2896632e88 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Thu, 26 Jan 2017 11:59:01 +0100 Subject: [PATCH 270/285] Add isComplete callback to commitEntry This callback will determine, if processed message is completed or not. Change-Id: I29a0faeaa1b3965a88e4d4516e19aee34bc5bf71 Signed-off-by: Tomas Slusny --- .../api/connection/OutboundQueue.java | 36 ++++++++++++++++++- .../AbstractStackedOutboundQueue.java | 14 +++++++- .../core/connection/OutboundQueueEntry.java | 32 +++++++++++++---- .../core/connection/StackedOutboundQueue.java | 9 +++-- .../StackedOutboundQueueNoBarrier.java | 15 ++++++-- 5 files changed, 92 insertions(+), 14 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java index 3212078c..3b9e7752 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OutboundQueue.java @@ -9,6 +9,7 @@ import com.google.common.annotations.Beta; import com.google.common.util.concurrent.FutureCallback; +import java.util.function.Function; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; @@ -44,5 +45,38 @@ public interface OutboundQueue { * @param callback Callback to be invoked, or null if no callback should be invoked. * @throws IllegalArgumentException if the slot is already committed or was never reserved. */ - void commitEntry(@Nonnull Long xid, @Nullable OfHeader message, @Nullable FutureCallback callback); + void commitEntry( + @Nonnull Long xid, + @Nullable OfHeader message, + @Nullable FutureCallback callback); + + /** + * Commit the specified offset using a message. Specified callback will + * be invoked once we know how it has resolved, either with a normal response, + * implied completion via a barrier, or failure (such as connection drop). For + * multipart responses, {@link FutureCallback#onSuccess(Object)} will be invoked + * multiple times as the corresponding responses arrive. If the request is completed + * with a response, the object reported will be non-null. If the request's completion + * is implied by a barrier, the object reported will be null. + * + * If this request fails on the remote device, {@link FutureCallback#onFailure(Throwable)} + * will be called with an instance of {@link DeviceRequestFailedException}. + * + * If the request fails due to local reasons, {@link FutureCallback#onFailure(Throwable)} + * will be called with an instance of {@link OutboundQueueException}. In particular, if + * this request failed because the device disconnected, {@link OutboundQueueException#DEVICE_DISCONNECTED} + * will be reported. + * + * @param xid Previously-reserved XID + * @param message Message which should be sent out, or null if the reservation + * should be cancelled. + * @param callback Callback to be invoked, or null if no callback should be invoked. + * @param isComplete Function to determine if OfHeader is processing is complete + * @throws IllegalArgumentException if the slot is already committed or was never reserved. + */ + void commitEntry( + @Nonnull Long xid, + @Nullable OfHeader message, + @Nullable FutureCallback callback, + @Nullable Function isComplete); } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java index 16106a1a..b4356ee4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java @@ -10,23 +10,30 @@ import com.google.common.base.Preconditions; import com.google.common.base.Verify; +import com.google.common.util.concurrent.FutureCallback; + import io.netty.channel.Channel; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import java.util.function.Function; + import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; + import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; abstract class AbstractStackedOutboundQueue implements OutboundQueue { private static final Logger LOG = LoggerFactory.getLogger(AbstractStackedOutboundQueue.class); - protected static final AtomicLongFieldUpdater LAST_XID_OFFSET_UPDATER = AtomicLongFieldUpdater .newUpdater(AbstractStackedOutboundQueue.class, "lastXid"); @@ -55,6 +62,11 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue { unflushedSegments.add(firstSegment); } + @Override + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + commitEntry(xid, message, callback, OutboundQueueEntry.DEFAULT_IS_COMPLETE); + } + @GuardedBy("unflushedSegments") protected void ensureSegment(final StackedSegment first, final int offset) { final int segmentOffset = offset / StackedSegment.SEGMENT_SIZE; diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 72efc18a..d88566b8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -10,24 +10,47 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; + +import java.util.function.Function; + import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; final class OutboundQueueEntry { private static final Logger LOG = LoggerFactory.getLogger(OutboundQueueEntry.class); + public static final Function DEFAULT_IS_COMPLETE = new Function() { + + @Override + public Boolean apply(final OfHeader message) { + if (message instanceof MultipartReplyMessage) { + return !((MultipartReplyMessage) message).getFlags().isOFPMPFREQMORE(); + } + + return true; + } + + }; + private FutureCallback callback; private OfHeader message; private boolean completed; private boolean barrier; private volatile boolean committed; private OutboundQueueException lastException = null; + private Function isCompletedFunction = DEFAULT_IS_COMPLETE; void commit(final OfHeader message, final FutureCallback callback) { + commit(message, callback, DEFAULT_IS_COMPLETE); + } + + void commit(final OfHeader message, final FutureCallback callback, + final Function isCompletedFunction) { if (this.completed) { LOG.warn("Can't commit a completed message."); if (callback != null) { @@ -37,6 +60,7 @@ void commit(final OfHeader message, final FutureCallback callback) { this.message = message; this.callback = callback; this.barrier = message instanceof BarrierInput; + this.isCompletedFunction = isCompletedFunction; // Volatile write, needs to be last this.committed = true; @@ -90,13 +114,7 @@ boolean complete(final OfHeader response) { // Multipart requests are special, we have to look at them to see // if there is something outstanding and adjust ourselves accordingly - final boolean reallyComplete; - if (response instanceof MultipartReplyMessage) { - reallyComplete = !((MultipartReplyMessage) response).getFlags().isOFPMPFREQMORE(); - LOG.debug("Multipart reply {}", response); - } else { - reallyComplete = true; - } + final boolean reallyComplete = isCompletedFunction.apply(response); completed = reallyComplete; if (callback != null) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index cafd114c..dd1e9520 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -8,8 +8,12 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.util.concurrent.FutureCallback; + import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import java.util.function.Function; + import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,10 +31,11 @@ final class StackedOutboundQueue extends AbstractStackedOutboundQueue { * This method is expected to be called from multiple threads concurrently */ @Override - public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback, + final Function isCompletedFunction) { final OutboundQueueEntry entry = getEntry(xid); - entry.commit(message, callback); + entry.commit(message, callback, isCompletedFunction); if (entry.isBarrier()) { long my = xid; for (;;) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java index 2917631a..76b1243a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java @@ -9,10 +9,17 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection; import com.google.common.util.concurrent.FutureCallback; + import io.netty.channel.Channel; + +import java.util.function.Function; + import javax.annotation.Nonnull; + import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,14 +39,15 @@ public class StackedOutboundQueueNoBarrier extends AbstractStackedOutboundQueue * This method is expected to be called from multiple threads concurrently */ @Override - public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback) { + public void commitEntry(final Long xid, final OfHeader message, final FutureCallback callback, + final Function isCompletedFunction) { final OutboundQueueEntry entry = getEntry(xid); if (message instanceof FlowModInput) { callback.onSuccess(null); - entry.commit(message, null); + entry.commit(message, null, isCompletedFunction); } else { - entry.commit(message, callback); + entry.commit(message, callback, isCompletedFunction); } LOG.trace("Queue {} committed XID {}", this, xid); @@ -111,4 +119,5 @@ int writeEntries(@Nonnull final Channel channel, final long now) { return entries; } + } From 37b396c43ec3d71120f0948016cdc7c278a8c6c8 Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Tue, 7 Feb 2017 16:04:53 +0100 Subject: [PATCH 271/285] Migrate to karaf4. Change-Id: Idf1bccf8f4802871a24207c26d6624edeb55ce79 Signed-off-by: Jozef Bacigal --- features/features-openflowjava/pom.xml | 180 ++++++++++++++++++ .../src/main/features/features.xml | 6 +- features/features4-openflowjava/pom.xml | 33 ++++ features/odl-openflowjava-all/pom.xml | 31 +++ features/odl-openflowjava-protocol/pom.xml | 142 ++++++++++++++ .../src/main/features/features.xml | 9 + features/pom.xml | 176 +---------------- 7 files changed, 408 insertions(+), 169 deletions(-) create mode 100644 features/features-openflowjava/pom.xml rename features/{ => features-openflowjava}/src/main/features/features.xml (92%) create mode 100644 features/features4-openflowjava/pom.xml create mode 100644 features/odl-openflowjava-all/pom.xml create mode 100644 features/odl-openflowjava-protocol/pom.xml create mode 100644 features/odl-openflowjava-protocol/src/main/features/features.xml diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml new file mode 100644 index 00000000..e14cb2ae --- /dev/null +++ b/features/features-openflowjava/pom.xml @@ -0,0 +1,180 @@ + + + 4.0.0 + + org.opendaylight.odlparent + features-parent + 1.8.0-SNAPSHOT + + + + org.opendaylight.openflowjava + features-openflowjava + 0.9.0-SNAPSHOT + jar + + + 0.6.0-SNAPSHOT + 1.5.0-SNAPSHOT + 2.2.0-SNAPSHOT + 0.10.0-SNAPSHOT + + + + + + + org.opendaylight.openflowjava + openflowjava-artifacts + ${project.version} + import + pom + + + + + org.opendaylight.odlparent + odlparent-artifacts + 1.8.0-SNAPSHOT + import + pom + + + + + org.opendaylight.mdsal + mdsal-artifacts + ${mdsal.version} + import + pom + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${mdsal.model.version} + import + pom + + + + + org.opendaylight.controller + config-artifacts + ${config.version} + import + pom + + + org.opendaylight.controller + mdsal-artifacts + ${controller.mdsal.version} + import + pom + + + + + + + + + org.opendaylight.mdsal + features-mdsal + ${mdsal.version} + features + xml + + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} + features + xml + + + org.opendaylight.controller + features-config + features + xml + + + org.opendaylight.controller + features-mdsal + ${controller.mdsal.version} + features + xml + + + org.opendaylight.odlparent + features-odlparent + features + xml + + + + + org.opendaylight.openflowjava + openflow-protocol-api + + + org.opendaylight.openflowjava + openflow-protocol-spi + + + org.opendaylight.openflowjava + openflow-protocol-impl + + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + config + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + legacyConfig + + + + org.opendaylight.openflowjava + openflowjava-util + + + ${project.groupId} + openflowjava-config + xml + configstats + + + io.netty + netty-codec + + + io.netty + netty-handler + + + io.netty + netty-common + + + io.netty + netty-buffer + + + io.netty + netty-transport + + + io.netty + netty-transport-native-epoll + + linux-x86_64 + + + + diff --git a/features/src/main/features/features.xml b/features/features-openflowjava/src/main/features/features.xml similarity index 92% rename from features/src/main/features/features.xml rename to features/features-openflowjava/src/main/features/features.xml index 63be9313..f1b58ba6 100644 --- a/features/src/main/features/features.xml +++ b/features/features-openflowjava/src/main/features/features.xml @@ -1,8 +1,8 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features mvn:org.opendaylight.controller/features-config/{{VERSION}}/xml/features mvn:org.opendaylight.mdsal/features-mdsal/{{VERSION}}/xml/features @@ -27,4 +27,4 @@ mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig - + \ No newline at end of file diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml new file mode 100644 index 00000000..a5a28e6d --- /dev/null +++ b/features/features4-openflowjava/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + org.opendaylight.odlparent + feature-repo-parent + 1.8.0-SNAPSHOT + + + + org.opendaylight.openflowjava + features4-openflowjava + 0.9.0-SNAPSHOT + feature + + + + ${project.groupId} + odl-openflowjava-all + ${project.version} + xml + features + + + ${project.groupId} + odl-openflowjava-protocol + ${project.version} + xml + features + + + + diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml new file mode 100644 index 00000000..67a750e4 --- /dev/null +++ b/features/odl-openflowjava-all/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.opendaylight.odlparent + single-feature-parent + 1.8.0-SNAPSHOT + + + + org.opendaylight.openflowjava + odl-openflowjava-all + 0.9.0-SNAPSHOT + feature + + OpenDaylight :: Openflow Java :: All + + + + org.opendaylight.openflowjava + odl-openflowjava-protocol + ${project.version} + xml + features + + + + diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml new file mode 100644 index 00000000..e709f752 --- /dev/null +++ b/features/odl-openflowjava-protocol/pom.xml @@ -0,0 +1,142 @@ + + + + 4.0.0 + + org.opendaylight.odlparent + single-feature-parent + 1.8.0-SNAPSHOT + + + + org.opendaylight.openflowjava + odl-openflowjava-protocol + 0.9.0-SNAPSHOT + feature + + OpenDaylight :: Openflow Java :: Protocol + + + 0.6.0-SNAPSHOT + 1.5.0-SNAPSHOT + 2.2.0-SNAPSHOT + 0.10.0-SNAPSHOT + 1.8.0-SNAPSHOT + + + + + + + + org.opendaylight.openflowjava + openflowjava-artifacts + ${project.version} + import + pom + + + + + org.opendaylight.odlparent + odl-netty-4 + ${odlparent.netty} + import + pom + + + + + org.opendaylight.mdsal + mdsal-artifacts + ${mdsal.version} + import + pom + + + + org.opendaylight.mdsal.model + mdsal-model-artifacts + ${mdsal.model.version} + import + pom + + + + + org.opendaylight.controller + config-artifacts + ${config.version} + import + pom + + + org.opendaylight.controller + mdsal-artifacts + ${controller.mdsal.version} + import + pom + + + + + + + + org.opendaylight.mdsal + odl-mdsal-binding-base + xml + features + + + org.opendaylight.mdsal.model + odl-mdsal-models + xml + features + + + org.opendaylight.controller + odl-config-api + xml + features + + + org.opendaylight.controller + odl-mdsal-common + xml + features + + + org.opendaylight.odlparent + odl-netty-4 + xml + features + + + + org.opendaylight.openflowjava + openflow-protocol-api + + + org.opendaylight.openflowjava + openflow-protocol-spi + + + org.opendaylight.openflowjava + openflow-protocol-impl + + + org.opendaylight.openflowjava + openflowjava-blueprint-config + xml + config + + + org.opendaylight.openflowjava + openflowjava-util + + + + diff --git a/features/odl-openflowjava-protocol/src/main/features/features.xml b/features/odl-openflowjava-protocol/src/main/features/features.xml new file mode 100644 index 00000000..b1261d3f --- /dev/null +++ b/features/odl-openflowjava-protocol/src/main/features/features.xml @@ -0,0 +1,9 @@ + + + + + mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config + mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig + + diff --git a/features/pom.xml b/features/pom.xml index e14cb2ae..a1ef0fd9 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -3,178 +3,22 @@ 4.0.0 org.opendaylight.odlparent - features-parent + odlparent-lite 1.8.0-SNAPSHOT org.opendaylight.openflowjava - features-openflowjava + features-aggregator 0.9.0-SNAPSHOT - jar + pom - - 0.6.0-SNAPSHOT - 1.5.0-SNAPSHOT - 2.2.0-SNAPSHOT - 0.10.0-SNAPSHOT - - - - - - - org.opendaylight.openflowjava - openflowjava-artifacts - ${project.version} - import - pom - - - - - org.opendaylight.odlparent - odlparent-artifacts - 1.8.0-SNAPSHOT - import - pom - - - - - org.opendaylight.mdsal - mdsal-artifacts - ${mdsal.version} - import - pom - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${mdsal.model.version} - import - pom - - - - - org.opendaylight.controller - config-artifacts - ${config.version} - import - pom - - - org.opendaylight.controller - mdsal-artifacts - ${controller.mdsal.version} - import - pom - - - - - - - - - org.opendaylight.mdsal - features-mdsal - ${mdsal.version} - features - xml - - - org.opendaylight.mdsal.model - features-mdsal-model - ${mdsal.model.version} - features - xml - - - org.opendaylight.controller - features-config - features - xml - - - org.opendaylight.controller - features-mdsal - ${controller.mdsal.version} - features - xml - - - org.opendaylight.odlparent - features-odlparent - features - xml - - - - - org.opendaylight.openflowjava - openflow-protocol-api - - - org.opendaylight.openflowjava - openflow-protocol-spi - - - org.opendaylight.openflowjava - openflow-protocol-impl - - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - config - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - legacyConfig - - - - org.opendaylight.openflowjava - openflowjava-util - - - ${project.groupId} - openflowjava-config - xml - configstats - - - io.netty - netty-codec - - - io.netty - netty-handler - - - io.netty - netty-common - - - io.netty - netty-buffer - - - io.netty - netty-transport - - - io.netty - netty-transport-native-epoll - - linux-x86_64 - - + + features-openflowjava + features4-openflowjava + odl-openflowjava-protocol + odl-openflowjava-all + + From 95ebf4e412c17c30adca24757e3c5dc51e1ae492 Mon Sep 17 00:00:00 2001 From: "miroslav.macko" Date: Thu, 9 Feb 2017 17:01:47 +0100 Subject: [PATCH 272/285] Update OF header lenght - Set OF header length base on the writer index Change-Id: I48358e22a92ce400df8917a7e23a0a085b2b0a95 Signed-off-by: miroslav.macko --- .../factories/FlowModInputMessageFactory.java | 3 ++- .../factories/FlowRemovedMessageFactory.java | 3 ++- .../factories/GroupModInputMessageFactory.java | 3 ++- .../factories/PortModInputMessageFactory.java | 3 ++- .../FlowModInputMessageFactoryTest.java | 11 +++++++++++ .../FlowRemovedMessageFactoryTest.java | 11 +++++++++++ .../GroupModInputMessageFactoryTest.java | 11 +++++++++++ .../PortModInputMessageFactoryTest.java | 11 +++++++++++ .../openflowjava/util/ByteBufUtils.java | 9 +++++++++ .../openflowjava/util/ByteBufUtilsTest.java | 18 ++++++++++++++++++ 10 files changed, 79 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java index 62fab014..336b3d03 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactory.java @@ -38,6 +38,7 @@ public class FlowModInputMessageFactory implements OFSerializer, Serial @Override public void serialize(final FlowMod message, final ByteBuf outBuffer) { + int index = outBuffer.writerIndex(); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeLong(message.getCookieMask().longValue()); @@ -54,7 +55,7 @@ public void serialize(final FlowMod message, final ByteBuf outBuffer) { registry.>getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)) .serialize(message.getMatch(), outBuffer); ListSerializer.serializeList(message.getInstruction(), INSTRUCTION_KEY_MAKER, registry, outBuffer); - ByteBufUtils.updateOFHeaderLength(outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer, index); } @Override diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java index 7e7c4848..11c2948b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactory.java @@ -33,6 +33,7 @@ public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { @Override public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { + int index = outBuffer.writerIndex(); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeShort(message.getPriority()); @@ -47,7 +48,7 @@ public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { OFSerializer matchSerializer = registry .> getSerializer(new MessageTypeKey<>(message.getVersion(), Match.class)); matchSerializer.serialize(message.getMatch(), outBuffer); - ByteBufUtils.updateOFHeaderLength(outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer, index); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java index 95a3b7db..db8142a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactory.java @@ -34,13 +34,14 @@ public class GroupModInputMessageFactory implements OFSerializer, Seri @Override public void serialize(GroupMod message, ByteBuf outBuffer) { + int index = outBuffer.writerIndex(); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeShort(message.getCommand().getIntValue()); outBuffer.writeByte(message.getType().getIntValue()); outBuffer.writeZero(PADDING_IN_GROUP_MOD_MESSAGE); outBuffer.writeInt(message.getGroupId().getValue().intValue()); serializerBuckets(message.getBucketsList(), outBuffer); - ByteBufUtils.updateOFHeaderLength(outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer, index); } private void serializerBuckets(List buckets, ByteBuf outBuffer) { diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java index ded3af6d..03c39887 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactory.java @@ -33,6 +33,7 @@ public class PortModInputMessageFactory implements OFSerializer { @Override public void serialize(final PortMod message, final ByteBuf outBuffer) { + int index = outBuffer.writerIndex(); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getPortNo().getValue().intValue()); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01); @@ -42,7 +43,7 @@ public void serialize(final PortMod message, final ByteBuf outBuffer) { outBuffer.writeInt(createPortConfigBitmask(message.getMask())); outBuffer.writeInt(createPortFeaturesBitmask(message.getAdvertise())); outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03); - ByteBufUtils.updateOFHeaderLength(outBuffer); + ByteBufUtils.updateOFHeaderLength(outBuffer, index); } /** diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java index edf21a2c..a3a72a27 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java @@ -154,8 +154,19 @@ public void testFlowModInputMessageFactory() throws Exception { FlowModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + + // simulate parent message + out.writeInt(1); + out.writeZero(2); + out.writeShort(3); + flowModFactory.serialize(message, out); + // read parent message + out.readInt(); + out.skipBytes(2); + out.readShort(); + BufferHelper.checkHeaderV13(out,(byte) 14, 128); cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; out.readBytes(cookie); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java index 616b289b..0ba90a23 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowRemovedMessageFactoryTest.java @@ -94,8 +94,19 @@ public void testSerialize() throws Exception { builder.setMatch(matchBuilder.build()); FlowRemovedMessage message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); + + // simulate parent message + serializedBuffer.writeInt(1); + serializedBuffer.writeZero(2); + serializedBuffer.writeShort(3); + factory.serialize(message, serializedBuffer); + // read parent message + serializedBuffer.readInt(); + serializedBuffer.skipBytes(2); + serializedBuffer.readShort(); + BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72); Assert.assertEquals("Wrong cookie", message.getCookie().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong priority", message.getPriority().intValue(), serializedBuffer.readShort()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java index 37396655..6e75130f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/GroupModInputMessageFactoryTest.java @@ -69,8 +69,19 @@ public void testGroupModInputMessage() throws Exception { GroupModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + + // simulate parent message + out.writeInt(1); + out.writeZero(2); + out.writeShort(3); + groupModFactory.serialize(message, out); + // read parent message + out.readInt(); + out.skipBytes(2); + out.readShort(); + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 32); Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort()); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte()); diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java index 3aebd727..f9319019 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/PortModInputMessageFactoryTest.java @@ -70,8 +70,19 @@ public void testPortModInput() throws Exception { PortModInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + + // simulate parent message + out.writeInt(1); + out.writeZero(2); + out.writeShort(3); + portModFactory.serialize(message, out); + // read parent message + out.readInt(); + out.skipBytes(2); + out.readShort(); + BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH); Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt()); out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01); diff --git a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java index 6be2ee39..5d6869cf 100644 --- a/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java +++ b/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java @@ -136,6 +136,15 @@ public static void updateOFHeaderLength(final ByteBuf out) { out.setShort(EncodeConstants.OFHEADER_LENGTH_INDEX, out.readableBytes()); } + /** + * Write length OF header + * @param out writing buffer + * @param index writing index + */ + public static void updateOFHeaderLength(final ByteBuf out, int index) { + out.setShort(index + EncodeConstants.OFHEADER_LENGTH_INDEX, out.writerIndex() - index); + } + /** * Fills the bitmask from boolean map where key is bit position * @param booleanMap bit to boolean mapping diff --git a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java index 8196e69b..b7f0f593 100644 --- a/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java +++ b/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java @@ -448,4 +448,22 @@ public void testSerializeList() throws IOException { Assert.assertTrue(bytes.length == shorts.size()*2); Assert.assertArrayEquals(EXPECTEDVALUES1AND255, bytes); } + + @Test + public void testUpdateHeader() throws IOException { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeInt(1); + int start = buffer.writerIndex(); + buffer.writeShort(4); + buffer.writeShort(EncodeConstants.EMPTY_LENGTH); + buffer.writeLong(8); + int end = buffer.writerIndex(); + + ByteBufUtils.updateOFHeaderLength(buffer, start); + Assert.assertEquals(buffer.readInt(), 1); + Assert.assertEquals(buffer.readShort(), 4); + Assert.assertEquals(buffer.readShort(), 12); + Assert.assertEquals(buffer.readLong(), 8l); + Assert.assertEquals(buffer.getShort(start + EncodeConstants.OFHEADER_LENGTH_INDEX), end - start); + } } From 2af60245e9fc7678e9d9fe2908b29a4fb5f18557 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Wed, 1 Mar 2017 00:03:12 +0100 Subject: [PATCH 273/285] Bug 7182 related: Remove M2E lifecycle mapping These should never be in individual projects anymore now, we handle this centrally, either in odlparent, or https://github.com/vorburger/opendaylight-eclipse-setup, or by appropriate lifecycle-mapping-metadata.xml in a Maven plugin (that's what Bug 7182 does for the yang-maven-plugin). Change-Id: I9923116894c0fa2c2f45ab8dfbe25ff3ef7a0296 Signed-off-by: Michael Vorburger --- parent/pom.xml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 1d42e379..931ecda0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -251,19 +251,6 @@ - - - org.opendaylight.yangtools - yang-maven-plugin - [0.5,) - - generate-sources - - - - - - org.codehaus.groovy.maven From 69c734409b0609704deaaad95dd0c1708431077e Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 7 Mar 2017 15:34:46 +0100 Subject: [PATCH 274/285] BUG-6859 - Binding generator v1 refactoring Change-Id: If8f5ace6ba7734ae866d7ed5c096ea24bd280d1a Signed-off-by: Michael Vorburger --- openflow-protocol-impl/pom.xml | 4 ++-- openflow-protocol-spi/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index c97c7acb..35c45c92 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -52,12 +52,12 @@ - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl ${salGeneratorPath} - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + org.opendaylight.mdsal.binding.yang.unified.doc.generator.maven.DocumentationGeneratorImpl ${project.build.directory}/site/models diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 2e7057b6..42dcab3f 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -50,12 +50,12 @@ - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl ${salGeneratorPath} - org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + org.opendaylight.mdsal.binding.yang.unified.doc.generator.maven.DocumentationGeneratorImpl ${project.build.directory}/site/models From 7833b2cadf13b97d4cd735755b60d195fe8467b0 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Tue, 11 Apr 2017 11:45:51 +1000 Subject: [PATCH 275/285] Bump versions by x.(y+1).z for next dev cycle Change-Id: I39929fd1d32cf53c045db31393eb8519465f6aeb Signed-off-by: Anil Belur --- artifacts/pom.xml | 4 ++-- features/features-openflowjava/pom.xml | 14 +++++++------- features/features4-openflowjava/pom.xml | 4 ++-- features/odl-openflowjava-all/pom.xml | 4 ++-- features/odl-openflowjava-protocol/pom.xml | 14 +++++++------- features/pom.xml | 4 ++-- openflow-protocol-api/pom.xml | 8 ++++---- openflow-protocol-impl/pom.xml | 2 +- openflow-protocol-it/pom.xml | 2 +- openflow-protocol-spi/pom.xml | 2 +- openflowjava-blueprint-config/pom.xml | 2 +- openflowjava-config/pom.xml | 2 +- openflowjava-util/pom.xml | 2 +- parent/pom.xml | 14 +++++++------- pom.xml | 2 +- simple-client/pom.xml | 2 +- 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index a54a33e0..42397cd0 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,13 +14,13 @@ org.opendaylight.odlparent odlparent-lite - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-artifacts - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT pom diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml index e14cb2ae..ceab1384 100644 --- a/features/features-openflowjava/pom.xml +++ b/features/features-openflowjava/pom.xml @@ -4,20 +4,20 @@ org.opendaylight.odlparent features-parent - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava features-openflowjava - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT jar - 0.6.0-SNAPSHOT - 1.5.0-SNAPSHOT - 2.2.0-SNAPSHOT - 0.10.0-SNAPSHOT + 0.7.0-SNAPSHOT + 1.6.0-SNAPSHOT + 2.3.0-SNAPSHOT + 0.11.0-SNAPSHOT @@ -35,7 +35,7 @@ org.opendaylight.odlparent odlparent-artifacts - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT import pom diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml index a5a28e6d..63278712 100644 --- a/features/features4-openflowjava/pom.xml +++ b/features/features4-openflowjava/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent feature-repo-parent - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava features4-openflowjava - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT feature diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml index 67a750e4..7369a077 100644 --- a/features/odl-openflowjava-all/pom.xml +++ b/features/odl-openflowjava-all/pom.xml @@ -7,13 +7,13 @@ org.opendaylight.odlparent single-feature-parent - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava odl-openflowjava-all - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT feature OpenDaylight :: Openflow Java :: All diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index e709f752..c87fc847 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -7,23 +7,23 @@ org.opendaylight.odlparent single-feature-parent - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava odl-openflowjava-protocol - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT feature OpenDaylight :: Openflow Java :: Protocol - 0.6.0-SNAPSHOT - 1.5.0-SNAPSHOT - 2.2.0-SNAPSHOT - 0.10.0-SNAPSHOT - 1.8.0-SNAPSHOT + 0.7.0-SNAPSHOT + 1.6.0-SNAPSHOT + 2.3.0-SNAPSHOT + 0.11.0-SNAPSHOT + 1.9.0-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index a1ef0fd9..01f496b0 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent odlparent-lite - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava features-aggregator - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT pom diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 7eb15821..6576cec1 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -4,12 +4,12 @@ org.opendaylight.mdsal binding-parent - 0.10.0-SNAPSHOT + 0.11.0-SNAPSHOT org.opendaylight.openflowjava openflow-protocol-api - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT bundle Openflow Protocol Library - API @@ -18,8 +18,8 @@ - 2.2.0-SNAPSHOT - 0.10.0-SNAPSHOT + 2.3.0-SNAPSHOT + 0.11.0-SNAPSHOT diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 35c45c92..19258fa8 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent openflow-protocol-impl diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index b93ba9e6..d55f9a15 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent openflow-protocol-it diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 42dcab3f..0679503e 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent openflow-protocol-spi diff --git a/openflowjava-blueprint-config/pom.xml b/openflowjava-blueprint-config/pom.xml index c3e6c6ca..d3a9b9d5 100644 --- a/openflowjava-blueprint-config/pom.xml +++ b/openflowjava-blueprint-config/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent openflowjava-blueprint-config diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index 1f7bc3e0..dc0b29b6 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent openflowjava-config diff --git a/openflowjava-util/pom.xml b/openflowjava-util/pom.xml index 27ffc9bc..e9b4465a 100644 --- a/openflowjava-util/pom.xml +++ b/openflowjava-util/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent bundle diff --git a/parent/pom.xml b/parent/pom.xml index 1d42e379..802ded07 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,13 +4,13 @@ org.opendaylight.odlparent odlparent - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT pom openflowjava @@ -51,13 +51,13 @@ UTF-8 ${project.build.directory}/yang-gen-config - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT ${project.build.directory}/yang-gen-sal - 0.6.0-SNAPSHOT - 1.5.0-SNAPSHOT - 0.10.0-SNAPSHOT - 1.1.0-SNAPSHOT + 0.7.0-SNAPSHOT + 1.6.0-SNAPSHOT + 0.11.0-SNAPSHOT + 1.2.0-SNAPSHOT 0.7.0 diff --git a/pom.xml b/pom.xml index 0ed98352..e3eda8b0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT parent diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 76dd3575..87665c76 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.openflowjava openflowjava-parent - 0.9.0-SNAPSHOT + 0.10.0-SNAPSHOT ../parent simple-client From a6c95ee03c6e53fc4e8b59c2a2c4d656d02a63aa Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Wed, 3 May 2017 09:15:02 +0200 Subject: [PATCH 276/285] Increase startup and shutdown timeouts for udpHandler test Startup timeout: 2s -> 10s Shutdown timeout: inf. -> 10s + minor cosmetic changes (IDE warnings cleanup) Change-Id: I95b604641d7dbec73ab9770640f50a71a310127f Signed-off-by: Michal Rehak --- .../impl/core/connection/UdpHandlerTest.java | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java index ff36181f..72bbe8e0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; +import com.google.common.util.concurrent.ListenableFuture; import java.io.IOException; import java.net.InetAddress; import java.util.concurrent.ExecutionException; @@ -19,16 +20,20 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.openflowjava.protocol.impl.core.UdpChannelInitializer; import org.opendaylight.openflowjava.protocol.impl.core.UdpHandler; - -import com.google.common.util.concurrent.ListenableFuture; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author madamjak * */ public class UdpHandlerTest { - @Mock UdpChannelInitializer udpChannelInitializerMock; - UdpHandler udpHandler; + + private static final Logger LOG = LoggerFactory.getLogger(UdpHandlerTest.class); + + @Mock + private UdpChannelInitializer udpChannelInitializerMock; + private UdpHandler udpHandler; /** * Mock init */ @@ -44,12 +49,12 @@ public void startUp() { * @throws IOException */ @Test - public void testWithEmptyAddress() throws InterruptedException, ExecutionException, IOException { + public void testWithEmptyAddress() throws Exception { udpHandler = new UdpHandler(null, 0); udpHandler.setChannelInitializer(udpChannelInitializerMock); Assert.assertTrue("Wrong - start server", startupServer(false)); try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500, TimeUnit.MILLISECONDS)); } catch (TimeoutException e) { Assert.fail("Wrong - getIsOnlineFuture timed out"); } @@ -64,12 +69,12 @@ public void testWithEmptyAddress() throws InterruptedException, ExecutionExcepti * @throws IOException */ @Test - public void testWithEmptyAddressOnEpoll() throws InterruptedException, ExecutionException, IOException { + public void testWithEmptyAddressOnEpoll() throws Exception { udpHandler = new UdpHandler(null, 0); udpHandler.setChannelInitializer(udpChannelInitializerMock); Assert.assertTrue("Wrong - start server", startupServer(true)); try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); } catch (TimeoutException e) { Assert.fail("Wrong - getIsOnlineFuture timed out"); } @@ -84,13 +89,13 @@ public void testWithEmptyAddressOnEpoll() throws InterruptedException, Execution * @throws IOException */ @Test - public void testWithAddressAndPort() throws InterruptedException, ExecutionException, IOException{ + public void testWithAddressAndPort() throws Exception{ int port = 9874; udpHandler = new UdpHandler(InetAddress.getLocalHost(), port); udpHandler.setChannelInitializer(udpChannelInitializerMock); Assert.assertTrue("Wrong - start server", startupServer(false)); try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); } catch (TimeoutException e) { Assert.fail("Wrong - getIsOnlineFuture timed out"); } @@ -105,13 +110,13 @@ public void testWithAddressAndPort() throws InterruptedException, ExecutionExcep * @throws IOException */ @Test - public void testWithAddressAndPortOnEpoll() throws InterruptedException, ExecutionException, IOException{ + public void testWithAddressAndPortOnEpoll() throws Exception { int port = 9874; udpHandler = new UdpHandler(InetAddress.getLocalHost(), port); udpHandler.setChannelInitializer(udpChannelInitializerMock); Assert.assertTrue("Wrong - start server", startupServer(true)); try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS).booleanValue()); + Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); } catch (TimeoutException e) { Assert.fail("Wrong - getIsOnlineFuture timed out"); } @@ -119,25 +124,28 @@ public void testWithAddressAndPortOnEpoll() throws InterruptedException, Executi shutdownServer(); } - private Boolean startupServer(boolean isEpollEnabled) throws InterruptedException, IOException, ExecutionException { + private Boolean startupServer(final boolean isEpollEnabled) throws InterruptedException, IOException, ExecutionException { ListenableFuture online = udpHandler.getIsOnlineFuture(); /** * Test EPoll based native transport if isEpollEnabled is true. * Else use Nio based transport. */ udpHandler.initiateEventLoopGroups(null, isEpollEnabled); - (new Thread(udpHandler)).start(); - int retry = 0; - while (online.isDone() != true && retry++ < 20) { - Thread.sleep(100); - } - return online.isDone() ; + (new Thread(udpHandler)).start(); + + boolean startedSuccessfully = false; + try { + startedSuccessfully = online.get(10, TimeUnit.SECONDS); + } catch (TimeoutException e) { + LOG.warn("Timeout while waiting for UDP handler to start", e); + } + + return online.isDone(); } - private void shutdownServer() throws InterruptedException, ExecutionException { + private void shutdownServer() throws InterruptedException, ExecutionException, TimeoutException { ListenableFuture shutdownRet = udpHandler.shutdown() ; - while ( shutdownRet.isDone() != true ) - Thread.sleep(100) ; - Assert.assertTrue("Wrong - shutdown failed", shutdownRet.get()); + final Boolean shutdownSucceeded = shutdownRet.get(10, TimeUnit.SECONDS); + Assert.assertTrue("Wrong - shutdown failed", shutdownSucceeded); } } From e6b30328aa2f6dcd61db039b6dddfb7115747775 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 23 May 2017 13:31:41 +0200 Subject: [PATCH 277/285] Add target-ide/ to .gitignore Change-Id: Ic58b9795c1388cb0bf7e783e3e2c69340d1a70be Signed-off-by: Michael Vorburger --- .gitignore | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 49e9ad86..87966d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ -target/ -.classpath -.project -.settings/ -.externalToolBuilders/ -maven-eclipse.xml -.checkstyle -.idea -*.iws -*.iml +target/ +target-ide/ +.classpath +.project +.settings/ +.externalToolBuilders/ +maven-eclipse.xml +.checkstyle +.idea +*.iws +*.iml From 109461a1622b2de1f9c68030047213b4184cc215 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Fri, 3 Mar 2017 15:18:22 +1000 Subject: [PATCH 278/285] Add missing fields for pom.xml files This is used by autorelease scripts to automatically parse which project is failing a build and report to the mailing list automatically. We need names in the format: ODL :: :: This patch formats in the same format as found in the startup archetypes patch found here: https://git.opendaylight.org/gerrit/52522 Change-Id: If1f9c01f9c3a0cf3a9672e1d795a2c1d55b38a25 Signed-off-by: Anil Belur --- artifacts/pom.xml | 4 +++- features/features-openflowjava/pom.xml | 3 +++ features/features4-openflowjava/pom.xml | 3 +++ features/odl-openflowjava-all/pom.xml | 4 +++- features/odl-openflowjava-protocol/pom.xml | 4 +++- features/pom.xml | 4 +++- openflow-protocol-api/pom.xml | 4 +++- openflow-protocol-impl/pom.xml | 4 +++- openflow-protocol-it/pom.xml | 4 +++- openflow-protocol-spi/pom.xml | 4 +++- openflowjava-blueprint-config/pom.xml | 4 +++- openflowjava-config/pom.xml | 4 +++- openflowjava-util/pom.xml | 3 +++ parent/pom.xml | 4 +++- simple-client/pom.xml | 4 +++- 15 files changed, 45 insertions(+), 12 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 42397cd0..794cb0ad 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -22,6 +22,9 @@ openflowjava-artifacts 0.10.0-SNAPSHOT pom + + ODL :: openflowjava :: ${project.artifactId} @@ -94,4 +97,3 @@ - diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml index ceab1384..2f496307 100644 --- a/features/features-openflowjava/pom.xml +++ b/features/features-openflowjava/pom.xml @@ -12,6 +12,9 @@ features-openflowjava 0.10.0-SNAPSHOT jar + + ODL :: openflowjava :: ${project.artifactId} 0.7.0-SNAPSHOT diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml index 63278712..8e3e2e58 100644 --- a/features/features4-openflowjava/pom.xml +++ b/features/features4-openflowjava/pom.xml @@ -12,6 +12,9 @@ features4-openflowjava 0.10.0-SNAPSHOT feature + + ODL :: openflowjava :: ${project.artifactId} diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml index 7369a077..a132071f 100644 --- a/features/odl-openflowjava-all/pom.xml +++ b/features/odl-openflowjava-all/pom.xml @@ -16,7 +16,9 @@ 0.10.0-SNAPSHOT feature - OpenDaylight :: Openflow Java :: All + + ODL :: openflowjava :: ${project.artifactId} diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index c87fc847..ea905e10 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -16,7 +16,9 @@ 0.10.0-SNAPSHOT feature - OpenDaylight :: Openflow Java :: Protocol + + ODL :: openflowjava :: ${project.artifactId} 0.7.0-SNAPSHOT diff --git a/features/pom.xml b/features/pom.xml index 01f496b0..192c031f 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -12,6 +12,9 @@ features-aggregator 0.10.0-SNAPSHOT pom + + ODL :: openflowjava :: ${project.artifactId} features-openflowjava @@ -21,4 +24,3 @@ - diff --git a/openflow-protocol-api/pom.xml b/openflow-protocol-api/pom.xml index 6576cec1..5a2777d0 100644 --- a/openflow-protocol-api/pom.xml +++ b/openflow-protocol-api/pom.xml @@ -11,7 +11,9 @@ openflow-protocol-api 0.10.0-SNAPSHOT bundle - Openflow Protocol Library - API + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflow-protocol-impl/pom.xml b/openflow-protocol-impl/pom.xml index 19258fa8..62c2ddd3 100644 --- a/openflow-protocol-impl/pom.xml +++ b/openflow-protocol-impl/pom.xml @@ -8,7 +8,9 @@ openflow-protocol-impl bundle - Openflow Protocol Library - IMPL + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflow-protocol-it/pom.xml b/openflow-protocol-it/pom.xml index d55f9a15..58628b30 100644 --- a/openflow-protocol-it/pom.xml +++ b/openflow-protocol-it/pom.xml @@ -8,7 +8,9 @@ openflow-protocol-it bundle - Openflow Protocol Integration Test + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflow-protocol-spi/pom.xml b/openflow-protocol-spi/pom.xml index 0679503e..67a9aa90 100644 --- a/openflow-protocol-spi/pom.xml +++ b/openflow-protocol-spi/pom.xml @@ -9,7 +9,9 @@ openflow-protocol-spi bundle - Openflow Protocol Library - SPI + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflowjava-blueprint-config/pom.xml b/openflowjava-blueprint-config/pom.xml index d3a9b9d5..71efa0d2 100644 --- a/openflowjava-blueprint-config/pom.xml +++ b/openflowjava-blueprint-config/pom.xml @@ -17,7 +17,9 @@ openflowjava-blueprint-config Blueprint configuration files for openflowjava statistics bundle - Openflow Protocol Library - Blueprint Config + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index dc0b29b6..419a0609 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -17,7 +17,9 @@ openflowjava-config Configuration files for openflowjava statistics jar - Openflow Protocol Library - CONFIG + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD diff --git a/openflowjava-util/pom.xml b/openflowjava-util/pom.xml index e9b4465a..c296e5a7 100644 --- a/openflowjava-util/pom.xml +++ b/openflowjava-util/pom.xml @@ -10,6 +10,9 @@ bundle openflowjava-util + + ODL :: openflowjava :: ${project.artifactId} diff --git a/parent/pom.xml b/parent/pom.xml index 20a352de..34aeb642 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -12,7 +12,9 @@ openflowjava-parent 0.10.0-SNAPSHOT pom - openflowjava + + ODL :: openflowjava :: ${project.artifactId} Openflow protocol library - serializes and deserializes openflow messages + handles connections with openflow devices. diff --git a/simple-client/pom.xml b/simple-client/pom.xml index 87665c76..b399646e 100644 --- a/simple-client/pom.xml +++ b/simple-client/pom.xml @@ -8,7 +8,9 @@ simple-client bundle - Openflow Protocol Simple Client + + ODL :: openflowjava :: ${project.artifactId} https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main HEAD From 97613675ac818cf3f155632dfcca171b1976d4e4 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 23 May 2017 13:51:00 +0200 Subject: [PATCH 279/285] Add missing configuration to build-helper-maven-plugin This makes openflowjava work e.g. in Eclipse IDE out-of-the-box (using https://github.com/vorburger/opendaylight-eclipse-setup configuration), without any red. Without this, the paths with the generated code are not automatically source folder in IDE, so not on classpath, so there's red errors. This is how all other projects do it; I just copy/pasted from elsewhere. PS: In an ideal world, this should be inherited from some parent POM e.g. in controller, but let's at least already do an ad-hoc fix here. Change-Id: Ib0b8258de329345422d044f5fea4e9981b67da93 Signed-off-by: Michael Vorburger --- parent/pom.xml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index 802ded07..577acb33 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -130,7 +130,7 @@ org.apache.maven.plugins - maven-checkstyle-plugin + maven-checkstyle-plugin ${checkstyle.version} false @@ -159,6 +159,21 @@ org.codehaus.mojo build-helper-maven-plugin + + + add-yang-sources + generate-sources + + add-source + + + + ${jmxGeneratorPath} + ${salGeneratorPath} + + + + From 31b07d0b2e2f21cca65eaeb0ccea15ad47829665 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Fri, 9 Jun 2017 14:10:03 -0400 Subject: [PATCH 280/285] Migrate to odlparent 1.8.0-Carbon Per request of odlparent project we are downgrading all Nitrogen projects to use the released odlparent 1.8.0-Carbon to allow for the odlparent project to start performing semver style releases. Change-Id: I052f5a03008c82346548dd43983f539d5de4c274 Jira: RELENG-159 RT: 41406 Signed-off-by: Thanh Ha --- artifacts/pom.xml | 2 +- features/features-openflowjava/pom.xml | 4 ++-- features/features4-openflowjava/pom.xml | 2 +- features/odl-openflowjava-all/pom.xml | 2 +- features/odl-openflowjava-protocol/pom.xml | 4 ++-- features/pom.xml | 2 +- parent/pom.xml | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 794cb0ad..9f47949e 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,7 +14,7 @@ org.opendaylight.odlparent odlparent-lite - 1.9.0-SNAPSHOT + 1.8.0-Carbon diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml index 2f496307..395eaec2 100644 --- a/features/features-openflowjava/pom.xml +++ b/features/features-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent features-parent - 1.9.0-SNAPSHOT + 1.8.0-Carbon @@ -38,7 +38,7 @@ org.opendaylight.odlparent odlparent-artifacts - 1.9.0-SNAPSHOT + 1.8.0-Carbon import pom diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml index 8e3e2e58..e821ea4d 100644 --- a/features/features4-openflowjava/pom.xml +++ b/features/features4-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 1.9.0-SNAPSHOT + 1.8.0-Carbon diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml index a132071f..91ad0a29 100644 --- a/features/odl-openflowjava-all/pom.xml +++ b/features/odl-openflowjava-all/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.9.0-SNAPSHOT + 1.8.0-Carbon diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index ea905e10..52ae65cf 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.9.0-SNAPSHOT + 1.8.0-Carbon @@ -25,7 +25,7 @@ 1.6.0-SNAPSHOT 2.3.0-SNAPSHOT 0.11.0-SNAPSHOT - 1.9.0-SNAPSHOT + 1.8.0-Carbon diff --git a/features/pom.xml b/features/pom.xml index 192c031f..d6995783 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 1.9.0-SNAPSHOT + 1.8.0-Carbon diff --git a/parent/pom.xml b/parent/pom.xml index 498b2015..7c9e4409 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent - 1.9.0-SNAPSHOT + 1.8.0-Carbon @@ -53,7 +53,6 @@ UTF-8 ${project.build.directory}/yang-gen-config - 1.9.0-SNAPSHOT ${project.build.directory}/yang-gen-sal 0.7.0-SNAPSHOT From e7e9481d7ed14a41da06b4143bf80a8ca87a1e36 Mon Sep 17 00:00:00 2001 From: melserngawy Date: Thu, 1 Jun 2017 13:35:07 -0400 Subject: [PATCH 281/285] Check for transport protocol confi For some reason the TransportProtocol config has a null value at the following jenkins job https://jenkins.opendaylight.org/releng/job/aaa-distribution-check-nitrogen/139/console - flipped equals, now null is on slow path Change-Id: I38c2bb0676d4553452f9ae630554b6c99d445ef4 Signed-off-by: melserngawy Signed-off-by: Michal Rehak --- .../protocol/impl/core/SwitchConnectionProviderImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index afa47644..612afcb7 100755 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -142,7 +142,7 @@ private ServerFacade createAndConfigureServer() { // TODO : Add option to disable Epoll. boolean isEpollEnabled = Epoll.isAvailable(); - if (transportProtocol.equals(TransportProtocol.TCP) || transportProtocol.equals(TransportProtocol.TLS)) { + if ((TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol))) { server = new TcpHandler(connConfig.getAddress(), connConfig.getPort()); final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer(); ((TcpHandler) server).setChannelInitializer(channelInitializer); @@ -152,7 +152,7 @@ private ServerFacade createAndConfigureServer() { connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled); connectionInitializer.setChannelInitializer(channelInitializer); connectionInitializer.run(); - } else if (transportProtocol.equals(TransportProtocol.UDP)){ + } else if (TransportProtocol.UDP.equals(transportProtocol)){ server = new UdpHandler(connConfig.getAddress(), connConfig.getPort()); ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled); ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer()); From c0d2b2e3f6b3da9c9e1f4c91e23bc72d26106e39 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Tue, 13 Jun 2017 16:26:27 -0400 Subject: [PATCH 282/285] Migrate to odlparent 1.9.0 Change-Id: I95874664e56e30c6c4da2cd575dc7015182a2e2f Signed-off-by: Thanh Ha --- artifacts/pom.xml | 2 +- features/features-openflowjava/pom.xml | 4 ++-- features/features4-openflowjava/pom.xml | 2 +- features/odl-openflowjava-all/pom.xml | 2 +- features/odl-openflowjava-protocol/pom.xml | 4 ++-- features/pom.xml | 2 +- parent/pom.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 9f47949e..bcf62e1f 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,7 +14,7 @@ org.opendaylight.odlparent odlparent-lite - 1.8.0-Carbon + 1.9.0 diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml index 395eaec2..09d56933 100644 --- a/features/features-openflowjava/pom.xml +++ b/features/features-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent features-parent - 1.8.0-Carbon + 1.9.0 @@ -38,7 +38,7 @@ org.opendaylight.odlparent odlparent-artifacts - 1.8.0-Carbon + 1.9.0 import pom diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml index e821ea4d..11f44198 100644 --- a/features/features4-openflowjava/pom.xml +++ b/features/features4-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 1.8.0-Carbon + 1.9.0 diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml index 91ad0a29..38f886c6 100644 --- a/features/odl-openflowjava-all/pom.xml +++ b/features/odl-openflowjava-all/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.8.0-Carbon + 1.9.0 diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index 52ae65cf..371d8552 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.8.0-Carbon + 1.9.0 @@ -25,7 +25,7 @@ 1.6.0-SNAPSHOT 2.3.0-SNAPSHOT 0.11.0-SNAPSHOT - 1.8.0-Carbon + 1.9.0 diff --git a/features/pom.xml b/features/pom.xml index d6995783..2c07ddc6 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 1.8.0-Carbon + 1.9.0 diff --git a/parent/pom.xml b/parent/pom.xml index 7c9e4409..418743ef 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent - 1.8.0-Carbon + 1.9.0 From 149db3077b7582ed94963ca2bf897bd23d417446 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 14 Jun 2017 16:13:04 +0200 Subject: [PATCH 283/285] Copy initial configuration file in Karaf 4 Fix copying of initial configuration file in Karaf 4. Problem was that karaf .xml file that was supposed to handle this was incorrectly located at `src/main/features/features.xml` but was supposed to be at `src/main/feature/feature.xml` to work properly in Karaf 4. Resolves: bug 8692 Change-Id: I9923a2b2598e05e95bb68a01cde5a8894679e534 Signed-off-by: Tomas Slusny --- features/odl-openflowjava-protocol/pom.xml | 15 ++++++++++++++- .../features.xml => feature/feature.xml} | 0 2 files changed, 14 insertions(+), 1 deletion(-) rename features/odl-openflowjava-protocol/src/main/{features/features.xml => feature/feature.xml} (100%) diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index 371d8552..5779f1c9 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -129,6 +129,17 @@ org.opendaylight.openflowjava openflow-protocol-impl + + org.opendaylight.openflowjava + openflowjava-util + + + + org.opendaylight.openflowjava + openflowjava-config + xml + configstats + org.opendaylight.openflowjava openflowjava-blueprint-config @@ -137,7 +148,9 @@ org.opendaylight.openflowjava - openflowjava-util + openflowjava-blueprint-config + xml + legacyConfig diff --git a/features/odl-openflowjava-protocol/src/main/features/features.xml b/features/odl-openflowjava-protocol/src/main/feature/feature.xml similarity index 100% rename from features/odl-openflowjava-protocol/src/main/features/features.xml rename to features/odl-openflowjava-protocol/src/main/feature/feature.xml From 7e8e7b82d01ad684b3260c12cde7cb68f087d6fe Mon Sep 17 00:00:00 2001 From: Jozef Bacigal Date: Thu, 22 Jun 2017 10:23:42 +0200 Subject: [PATCH 284/285] Bump to odlparent 2.0.0 Change-Id: I9ec83c0f0e28f22185ffa0c50a055a6daa951fa6 Signed-off-by: Jozef Bacigal Signed-off-by: Robert Varga --- artifacts/pom.xml | 2 +- features/features-openflowjava/pom.xml | 165 +----------------- .../src/main/features/features.xml | 30 ---- features/features4-openflowjava/pom.xml | 36 ---- features/odl-openflowjava-all/pom.xml | 2 +- features/odl-openflowjava-protocol/pom.xml | 2 +- features/pom.xml | 3 +- parent/pom.xml | 2 +- 8 files changed, 14 insertions(+), 228 deletions(-) delete mode 100644 features/features-openflowjava/src/main/features/features.xml delete mode 100644 features/features4-openflowjava/pom.xml diff --git a/artifacts/pom.xml b/artifacts/pom.xml index bcf62e1f..54204e90 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -14,7 +14,7 @@ org.opendaylight.odlparent odlparent-lite - 1.9.0 + 2.0.0 diff --git a/features/features-openflowjava/pom.xml b/features/features-openflowjava/pom.xml index 09d56933..036501c4 100644 --- a/features/features-openflowjava/pom.xml +++ b/features/features-openflowjava/pom.xml @@ -3,180 +3,33 @@ 4.0.0 org.opendaylight.odlparent - features-parent - 1.9.0 + feature-repo-parent + 2.0.0 org.opendaylight.openflowjava features-openflowjava 0.10.0-SNAPSHOT - jar + feature ODL :: openflowjava :: ${project.artifactId} - - 0.7.0-SNAPSHOT - 1.6.0-SNAPSHOT - 2.3.0-SNAPSHOT - 0.11.0-SNAPSHOT - - - - - - - org.opendaylight.openflowjava - openflowjava-artifacts - ${project.version} - import - pom - - - - - org.opendaylight.odlparent - odlparent-artifacts - 1.9.0 - import - pom - - - - - org.opendaylight.mdsal - mdsal-artifacts - ${mdsal.version} - import - pom - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${mdsal.model.version} - import - pom - - - - - org.opendaylight.controller - config-artifacts - ${config.version} - import - pom - - - org.opendaylight.controller - mdsal-artifacts - ${controller.mdsal.version} - import - pom - - - - - - - org.opendaylight.mdsal - features-mdsal - ${mdsal.version} - features - xml - - - org.opendaylight.mdsal.model - features-mdsal-model - ${mdsal.model.version} - features - xml - - - org.opendaylight.controller - features-config - features + ${project.groupId} + odl-openflowjava-all + ${project.version} xml - - - org.opendaylight.controller - features-mdsal - ${controller.mdsal.version} features - xml - - - org.opendaylight.odlparent - features-odlparent - features - xml - - - - - org.opendaylight.openflowjava - openflow-protocol-api - - - org.opendaylight.openflowjava - openflow-protocol-spi - - - org.opendaylight.openflowjava - openflow-protocol-impl - - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - config - - - org.opendaylight.openflowjava - openflowjava-blueprint-config - xml - legacyConfig - - - - org.opendaylight.openflowjava - openflowjava-util ${project.groupId} - openflowjava-config + odl-openflowjava-protocol + ${project.version} xml - configstats - - - io.netty - netty-codec - - - io.netty - netty-handler - - - io.netty - netty-common - - - io.netty - netty-buffer - - - io.netty - netty-transport - - - io.netty - netty-transport-native-epoll - - linux-x86_64 + features diff --git a/features/features-openflowjava/src/main/features/features.xml b/features/features-openflowjava/src/main/features/features.xml deleted file mode 100644 index f1b58ba6..00000000 --- a/features/features-openflowjava/src/main/features/features.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - mvn:org.opendaylight.yangtools/features-yangtools/{{VERSION}}/xml/features - mvn:org.opendaylight.controller/features-config/{{VERSION}}/xml/features - mvn:org.opendaylight.mdsal/features-mdsal/{{VERSION}}/xml/features - mvn:org.opendaylight.controller/features-mdsal/{{VERSION}}/xml/features - mvn:org.opendaylight.mdsal.model/features-mdsal-model/{{VERSION}}/xml/features - mvn:org.opendaylight.odlparent/features-odlparent/{{VERSION}}/xml/features - - odl-openflowjava-protocol - - - odl-mdsal-binding-base - odl-mdsal-models - odl-config-api - odl-mdsal-common - odl-netty - mvn:org.opendaylight.openflowjava/openflow-protocol-api/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflow-protocol-spi/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflow-protocol-impl/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflowjava-util/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/{{VERSION}} - mvn:org.opendaylight.openflowjava/openflowjava-config/${project.version}/xml/configstats - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config - mvn:org.opendaylight.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig - - \ No newline at end of file diff --git a/features/features4-openflowjava/pom.xml b/features/features4-openflowjava/pom.xml deleted file mode 100644 index 11f44198..00000000 --- a/features/features4-openflowjava/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - - org.opendaylight.odlparent - feature-repo-parent - 1.9.0 - - - - org.opendaylight.openflowjava - features4-openflowjava - 0.10.0-SNAPSHOT - feature - - ODL :: openflowjava :: ${project.artifactId} - - - - ${project.groupId} - odl-openflowjava-all - ${project.version} - xml - features - - - ${project.groupId} - odl-openflowjava-protocol - ${project.version} - xml - features - - - - diff --git a/features/odl-openflowjava-all/pom.xml b/features/odl-openflowjava-all/pom.xml index 38f886c6..38d7c4fe 100644 --- a/features/odl-openflowjava-all/pom.xml +++ b/features/odl-openflowjava-all/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.9.0 + 2.0.0 diff --git a/features/odl-openflowjava-protocol/pom.xml b/features/odl-openflowjava-protocol/pom.xml index 5779f1c9..9092873c 100644 --- a/features/odl-openflowjava-protocol/pom.xml +++ b/features/odl-openflowjava-protocol/pom.xml @@ -7,7 +7,7 @@ org.opendaylight.odlparent single-feature-parent - 1.9.0 + 2.0.0 diff --git a/features/pom.xml b/features/pom.xml index 2c07ddc6..44633fb4 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 1.9.0 + 2.0.0 @@ -18,7 +18,6 @@ features-openflowjava - features4-openflowjava odl-openflowjava-protocol odl-openflowjava-all diff --git a/parent/pom.xml b/parent/pom.xml index 418743ef..4238e080 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent - 1.9.0 + 2.0.0 From 76c83901c7a265e0d00c537d34f3f093c636129c Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Thu, 29 Jun 2017 15:11:39 +0200 Subject: [PATCH 285/285] Add method to register listener for unknown msg Add method to ConnectionAdapter that will allow to register listener for unknown (alien) messages received from switch. See also: bug 8772 Change-Id: I3c4e48d0ddfd0a1220850bec5f75aa84e0e662c6 Signed-off-by: Tomas Slusny --- .../api/connection/ConnectionAdapter.java | 8 ++++++++ .../extensibility/AlienMessageListener.java | 19 +++++++++++++++++++ .../connection/ConnectionAdapterImpl.java | 18 +++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/AlienMessageListener.java diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java index 89cd461f..a61ea513 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ConnectionAdapter.java @@ -10,6 +10,7 @@ import com.google.common.annotations.Beta; import java.net.InetSocketAddress; import java.util.concurrent.Future; +import org.opendaylight.openflowjava.protocol.api.extensibility.AlienMessageListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; @@ -35,6 +36,7 @@ public interface ConnectionAdapter extends OpenflowProtocolService { * @return address of the remote end - address of a switch if connected */ InetSocketAddress getRemoteAddress(); + /** * @param messageListener here will be pushed all messages from switch */ @@ -45,6 +47,12 @@ public interface ConnectionAdapter extends OpenflowProtocolService { */ void setSystemListener(SystemNotificationsListener systemListener); + /** + * Set handler for alien messages received from device + * @param alienMessageListener here will be pushed all alien messages from switch + */ + void setAlienMessageListener(AlienMessageListener alienMessageListener); + /** * Throws exception if any of required listeners is missing */ diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/AlienMessageListener.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/AlienMessageListener.java new file mode 100644 index 00000000..a3cd7c6c --- /dev/null +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/AlienMessageListener.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.api.extensibility; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +public interface AlienMessageListener { + + /** + * Handler for alien but successfully deserialized messages for device + * @param message alien message + */ + void onAlienMessage(OfHeader message); +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java index 8d9c8746..e9de9ca2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImpl.java @@ -15,6 +15,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; +import org.opendaylight.openflowjava.protocol.api.extensibility.AlienMessageListener; import org.opendaylight.openflowjava.protocol.impl.core.OFVersionDetector; import org.opendaylight.openflowjava.protocol.impl.core.PipelineHandlers; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; @@ -47,6 +48,7 @@ public class ConnectionAdapterImpl extends AbstractConnectionAdapterStatistics i private ConnectionReadyListener connectionReadyListener; private OpenflowProtocolListener messageListener; private SystemNotificationsListener systemListener; + private AlienMessageListener alienMessageListener; private AbstractOutboundQueueManager outputManager; private OFVersionDetector versionDetector; @@ -80,6 +82,11 @@ public void setSystemListener(final SystemNotificationsListener systemListener) this.systemListener = systemListener; } + @Override + public void setAlienMessageListener(final AlienMessageListener alienMessageListener) { + this.alienMessageListener = alienMessageListener; + } + @Override public void consumeDeviceMessage(final DataObject message) { LOG.debug("ConsumeIntern msg on {}", channel); @@ -131,19 +138,24 @@ public void consumeDeviceMessage(final DataObject message) { } } else if (message instanceof OfHeader) { LOG.debug("OF header msg received"); + boolean found = false; if (outputManager == null || !outputManager.onMessage((OfHeader) message)) { final RpcResponseKey key = createRpcResponseKey((OfHeader) message); final ResponseExpectedRpcListener listener = findRpcResponse(key); if (listener != null) { + found = true; LOG.debug("Corresponding rpcFuture found"); - listener.completed((OfHeader)message); + listener.completed((OfHeader) message); LOG.debug("After setting rpcFuture"); responseCache.invalidate(key); - } else { - LOG.warn("received unexpected rpc response: {}", key); } } + + if (!found && alienMessageListener != null) { + LOG.debug("Alien message {} received", message.getImplementedInterface()); + alienMessageListener.onAlienMessage((OfHeader) message); + } } else { LOG.warn("message listening not supported for type: {}", message.getClass()); }